diff options
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp.el | 16 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37e014751d7..51afe08d9a4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-04-11 Lennart Borgman <lennart.borgman@gmail.com> | ||
| 2 | |||
| 3 | * emacs-lisp/lisp.el (narrow-to-defun): `beginning-of-defun' goes | ||
| 4 | to previous function when point is on the first character of a | ||
| 5 | function. Take care of that in `narrow-to-defun' (bug#6157). | ||
| 6 | |||
| 1 | 2012-04-11 Glenn Morris <rgm@gnu.org> | 7 | 2012-04-11 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * vc/vc-bzr.el (vc-bzr-status): Handle all errors, | 9 | * vc/vc-bzr.el (vc-bzr-status): Handle all errors, |
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." | |||
| 447 | ;; Try first in this order for the sake of languages with nested | 447 | ;; Try first in this order for the sake of languages with nested |
| 448 | ;; functions where several can end at the same place as with | 448 | ;; functions where several can end at the same place as with |
| 449 | ;; the offside rule, e.g. Python. | 449 | ;; the offside rule, e.g. Python. |
| 450 | (beginning-of-defun) | 450 | |
| 451 | ;; Finding the start of the function is a bit problematic since | ||
| 452 | ;; `beginning-of-defun' when we are on the first character of | ||
| 453 | ;; the function might go to the previous function. | ||
| 454 | ;; | ||
| 455 | ;; Therefore we first move one character forward and then call | ||
| 456 | ;; `beginning-of-defun'. However now we must check that we did | ||
| 457 | ;; not move into the next function. | ||
| 458 | (let ((here (point))) | ||
| 459 | (unless (eolp) | ||
| 460 | (forward-char)) | ||
| 461 | (beginning-of-defun) | ||
| 462 | (when (< (point) here) | ||
| 463 | (goto-char here) | ||
| 464 | (beginning-of-defun))) | ||
| 451 | (setq beg (point)) | 465 | (setq beg (point)) |
| 452 | (end-of-defun) | 466 | (end-of-defun) |
| 453 | (setq end (point)) | 467 | (setq end (point)) |