bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6157: narrow-to-defun fix when point is on function beginning


From: Lars Magne Ingebrigtsen
Subject: bug#6157: narrow-to-defun fix when point is on function beginning
Date: Wed, 21 Sep 2011 22:03:24 +0200
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)

Lennart Borgman <address@hidden> writes:

> `beginning-of-defun' goes to previous function when point is on the
> first character of a function. This is not currently taken care of in
> `narrow-to-defun'. This patch fixes this:
>
> c:\emacs-lp\bld\emacs\emacsw32\lisp\emacs-lisp>bzr diff --old
> c:\emacs-lp\bld\emacs\trunk -p trunk/:patched/ lisp.el
> === modified file 'lisp/emacs-lisp/lisp.el'
> --- trunk/lisp/emacs-lisp/lisp.el     2010-04-27 17:57:32 +0000
> +++ patched/lisp/emacs-lisp/lisp.el   2010-05-10 14:21:59 +0000
> @@ -438,7 +438,20 @@
>        ;; 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.
> +      ;;
> +      ;; Therefor 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 (eobp) (forward-char))
> +        (beginning-of-defun)
> +        (when (< (point) here)
> +          (goto-char here)
> +          (beginning-of-defun)))
>        (setq beg (point))
>        (end-of-defun)
>        (setq end (point))

This patch was apparently approved by Stefan, but not applied, as far as
I can tell.  Did it turn out to not be correct after all?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]