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: Lennart Borgman
Subject: bug#6157: narrow-to-defun fix when point is on function beginning
Date: Wed, 21 Sep 2011 22:19:37 +0200

On Wed, Sep 21, 2011 at 22:03, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Lennart Borgman <lennart.borgman@gmail.com> 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?

I think it was correct, but the problem is that I never submit
anything to the repository. (Since I did not trust myself to make the
submission in a correct way...)





reply via email to

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