From e3772e9833f971a450562350dc233bf00be7c5eb Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Wed, 15 May 2013 16:17:22 +0800 Subject: [PATCH] * progmodes/octave.el (octave-goto-function-definition): Improve and fix callers. --- lisp/ChangeLog | 5 +++++ lisp/progmodes/octave.el | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6c5de802fd5..ffcd36f4af1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 2fd2aadfc99..49c9c30d313 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -928,13 +928,21 @@ directory and makes this the current buffer's default directory." inferior-octave-completion-table 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 + "\\_