diff options
author | Lennart Borgman <lennart.borgman@gmail.com> | 2012-04-11 04:12:20 +0200 |
---|---|---|
committer | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2012-04-11 04:12:20 +0200 |
commit | 050cc68b402f5998193a6026d0eeeecb9d2cb9c4 (patch) | |
tree | 65bdc1a9ae8b7aee4b9a59ec93304662bed5ad95 /lisp/emacs-lisp/lisp.el | |
parent | effed0c27e6cbc7fb80054dcb4a75debaaf01cf4 (diff) | |
download | emacs-050cc68b402f5998193a6026d0eeeecb9d2cb9c4.tar.gz emacs-050cc68b402f5998193a6026d0eeeecb9d2cb9c4.tar.bz2 emacs-050cc68b402f5998193a6026d0eeeecb9d2cb9c4.zip |
`narrow-to-defun' fixup
* emacs-lisp/lisp.el (narrow-to-defun): `beginning-of-defun' goes
to previous function when point is on the first character of a
function. Take care of that in `narrow-to-defun'.
Fixes: debbugs:6157
Diffstat (limited to 'lisp/emacs-lisp/lisp.el')
-rw-r--r-- | lisp/emacs-lisp/lisp.el | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 4efdc3240cd..bcb7fab026b 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -447,7 +447,21 @@ Optional ARG is ignored." ;; Try first in this order for the sake of languages with nested ;; functions where several can end at the same place as with ;; the offside rule, e.g. Python. - (beginning-of-defun) + + ;; Finding the start of the function is a bit problematic since + ;; `beginning-of-defun' when we are on the first character of + ;; the function might go to the previous function. + ;; + ;; Therefore we first move one character forward and then call + ;; `beginning-of-defun'. However now we must check that we did + ;; not move into the next function. + (let ((here (point))) + (unless (eolp) + (forward-char)) + (beginning-of-defun) + (when (< (point) here) + (goto-char here) + (beginning-of-defun))) (setq beg (point)) (end-of-defun) (setq end (point)) |