GNU bug report logs - #6157
narrow-to-defun fix when point is on function beginning

Previous Next

Package: emacs;

Reported by: Lennart Borgman <lennart.borgman <at> gmail.com>

Date: Mon, 10 May 2010 14:52:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 24.2

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6157 in the body.
You can then email your comments to 6157 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6157; Package emacs. (Mon, 10 May 2010 14:52:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 10 May 2010 14:52:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Emacs Bugs <bug-gnu-emacs <at> gnu.org>
Subject: narrow-to-defun fix when point is on function beginning
Date: Mon, 10 May 2010 16:51:11 +0200
`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))




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6157; Package emacs. (Mon, 10 May 2010 17:07:01 GMT) Full text and rfc822 format available.

Message #8 received at 6157 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6157 <at> debbugs.gnu.org
Subject: Re: bug#6157: narrow-to-defun fix when point is on function beginning
Date: Mon, 10 May 2010 13:06:13 -0400
> `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:

Looks good, thank you (tho I'd use (eolp) rather than (eobp), and I'd
write "Therefore" rather than "Therefor").


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6157; Package emacs. (Wed, 21 Sep 2011 20:08:02 GMT) Full text and rfc822 format available.

Message #11 received at 6157 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6157 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: narrow-to-defun fix when point is on function beginning
Date: Wed, 21 Sep 2011 22:03:24 +0200
Lennart Borgman <lennart.borgman <at> 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?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6157; Package emacs. (Wed, 21 Sep 2011 20:25:02 GMT) Full text and rfc822 format available.

Message #14 received at 6157 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 6157 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: 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 <at> gnus.org> wrote:
> Lennart Borgman <lennart.borgman <at> 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...)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6157; Package emacs. (Wed, 11 Apr 2012 02:13:01 GMT) Full text and rfc822 format available.

Message #17 received at 6157 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 6157 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6157: narrow-to-defun fix when point is on function beginning
Date: Wed, 11 Apr 2012 04:11:37 +0200
Lennart Borgman <lennart.borgman <at> gmail.com> writes:

> 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...)

I've now applied it to the trunk.

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




Added tag(s) fixed. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 11 Apr 2012 02:13:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.2, send any further explanations to 6157 <at> debbugs.gnu.org and Lennart Borgman <lennart.borgman <at> gmail.com> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 11 Apr 2012 02:13:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6157; Package emacs. (Wed, 11 Apr 2012 09:49:02 GMT) Full text and rfc822 format available.

Message #24 received at 6157 <at> debbugs.gnu.org (full text, mbox):

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 6157 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#6157: narrow-to-defun fix when point is on function beginning
Date: Wed, 11 Apr 2012 11:47:10 +0200
On Wed, Apr 11, 2012 at 04:11, Lars Magne Ingebrigtsen <larsi <at> gnus.org> wrote:
> Lennart Borgman <lennart.borgman <at> gmail.com> writes:
>
>> 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...)
>
> I've now applied it to the trunk.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 May 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 7 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.