Commit 050cc68b authored by Lennart Borgman's avatar Lennart Borgman Committed by Lars Magne Ingebrigtsen
Browse files

`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
parent effed0c2
2012-04-11 Lennart Borgman <lennart.borgman@gmail.com>
* 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' (bug#6157).
2012-04-11 Glenn Morris <rgm@gnu.org>
* vc/vc-bzr.el (vc-bzr-status): Handle all errors,
......
......@@ -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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment