Commit e3772e98 authored by Leo Liu's avatar Leo Liu

* progmodes/octave.el (octave-goto-function-definition): Improve

and fix callers.
parent c46c57b0
2013-05-15 Leo Liu <>
* progmodes/octave.el (octave-goto-function-definition): Improve
and fix callers.
2013-05-15 Stefan Monnier <>
* emacs-lisp/cl-extra.el (cl-getf): Return the proper value in
......@@ -928,13 +928,21 @@ directory and makes this the current buffer's default directory."
nil nil nil nil def)))
(defun octave-goto-function-definition ()
"Go to the first function definition."
(defun octave-goto-function-definition (fn)
"Go to the function definition of FN in current buffer."
(goto-char (point-min))
(if (not (re-search-forward octave-function-header-regexp nil t))
(forward-comment (point-max))
(goto-char (match-beginning 3))
(match-string 3)))
(let ((search
(lambda (re sub)
(let (done)
(while (and (not done) (re-search-forward re nil t))
(when (and (equal (match-string sub) fn)
(not (nth 8 (syntax-ppss))))
(setq done t)))
(or done (goto-char (point-min)))))))
(pcase (file-name-extension (buffer-file-name))
(`"cc" (funcall search
"\\_<DEFUN\\s-*(\\s-*\\(\\(?:\\sw\\|\\s_\\)+\\)" 1))
(t (funcall search octave-function-header-regexp 3)))))
(defun octave-function-file-p ()
"Return non-nil if the first token is \"function\".
......@@ -1686,7 +1694,7 @@ if iskeyword(\"%s\") disp(\"`%s' is a keyword\") else which(\"%s\") endif\n"
(setq file (funcall octave-find-definition-filename-function file))
(when file
(find-file file)
(octave-goto-function-definition fn)))))
(provide 'octave)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment