diff options
author | Chong Yidong <cyd@gnu.org> | 2012-12-01 13:09:12 +0800 |
---|---|---|
committer | Chong Yidong <cyd@gnu.org> | 2012-12-01 13:09:12 +0800 |
commit | 9dffb5b69353cd041027b334a9c5aadf4163ec2d (patch) | |
tree | 36e5d76ed7301e1c5e757ecac62682e8619239e8 /lisp/emacs-lisp/lisp-mode.el | |
parent | ba03d0d932888f687ae9c9fb12e20908c6b0620f (diff) | |
download | emacs-9dffb5b69353cd041027b334a9c5aadf4163ec2d.tar.gz |
Fix last change.
* emacs-lisp/lisp-mode.el (lisp-current-defun-name):
* progmodes/m4-mode.el (m4-current-defun-name):
* progmodes/perl-mode.el (perl-current-defun-name):
* textmodes/tex-mode.el (tex-current-defun-name):
* textmodes/texinfo.el (texinfo-current-defun-name): Use save-excursion.
Diffstat (limited to 'lisp/emacs-lisp/lisp-mode.el')
-rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 11dd6dc6ee2..c0380c60e11 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -240,28 +240,29 @@ font-lock keywords will not be case sensitive." (defun lisp-current-defun-name () "Return the name of the defun at point, or nil." - (let ((location (point))) - ;; If we are now precisely at the beginning of a defun, make sure - ;; beginning-of-defun finds that one rather than the previous one. - (or (eobp) (forward-char 1)) - (beginning-of-defun) - ;; Make sure we are really inside the defun found, not after it. - (when (and (looking-at "\\s(") - (progn (end-of-defun) - (< location (point))) - (progn (forward-sexp -1) - (>= location (point)))) - (if (looking-at "\\s(") - (forward-char 1)) - ;; Skip the defining construct name, typically "defun" or - ;; "defvar". - (forward-sexp 1) - ;; The second element is usually a symbol being defined. If it - ;; is not, use the first symbol in it. - (skip-chars-forward " \t\n'(") - (buffer-substring-no-properties (point) - (progn (forward-sexp 1) - (point)))))) + (save-excursion + (let ((location (point))) + ;; If we are now precisely at the beginning of a defun, make sure + ;; beginning-of-defun finds that one rather than the previous one. + (or (eobp) (forward-char 1)) + (beginning-of-defun) + ;; Make sure we are really inside the defun found, not after it. + (when (and (looking-at "\\s(") + (progn (end-of-defun) + (< location (point))) + (progn (forward-sexp -1) + (>= location (point)))) + (if (looking-at "\\s(") + (forward-char 1)) + ;; Skip the defining construct name, typically "defun" or + ;; "defvar". + (forward-sexp 1) + ;; The second element is usually a symbol being defined. If it + ;; is not, use the first symbol in it. + (skip-chars-forward " \t\n'(") + (buffer-substring-no-properties (point) + (progn (forward-sexp 1) + (point))))))) (defvar lisp-mode-shared-map (let ((map (make-sparse-keymap))) |