aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Borgman2012-04-11 04:12:20 +0200
committerLars Magne Ingebrigtsen2012-04-11 04:12:20 +0200
commit050cc68b402f5998193a6026d0eeeecb9d2cb9c4 (patch)
tree65bdc1a9ae8b7aee4b9a59ec93304662bed5ad95
parenteffed0c27e6cbc7fb80054dcb4a75debaaf01cf4 (diff)
downloademacs-050cc68b402f5998193a6026d0eeeecb9d2cb9c4.tar.gz
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
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/emacs-lisp/lisp.el16
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 @@
12012-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
12012-04-11 Glenn Morris <rgm@gnu.org> 72012-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))