GNU bug report logs - #20761
beginning-of-defun matches column 0 paren inside string literal

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Sun, 7 Jun 2015 17:22:02 UTC

Severity: wishlist

Tags: fixed

Merged with 20284, 26642

Found in versions 25.0.50, 25.0.50.1, 25.1, 25.2

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

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 20761 in the body.
You can then email your comments to 20761 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 bug-gnu-emacs <at> gnu.org:
bug#20761; Package emacs. (Sun, 07 Jun 2015 17:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 07 Jun 2015 17:22:03 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50.1, beginning-of-defun matches inside string
Date: Sun, 07 Jun 2015 19:21:28 +0200
emacs -Q

With cursor at end of string below:

(defun asdf ()
  "
(defun foo1 (&optional beg end)
  sdsd"
)

;;;

C-M-a stops  inside string at "(defun foo1"

GNU Emacs 25.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.23) of 2015-06-07

Solution:

beginning-of-defun-raw must check if being inside string.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20761; Package emacs. (Sun, 07 Jun 2015 18:14:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 20761 <at> debbugs.gnu.org
Subject: Re: bug#20761: 25.0.50.1, beginning-of-defun matches inside string
Date: Sun, 07 Jun 2015 14:13:21 -0400
Andreas Röhler wrote:

> (defun asdf ()
>   "
> (defun foo1 (&optional beg end)
>   sdsd"
> )

Unescaped paren in column 0.




Severity set to 'minor' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 07 Jun 2015 18:14:03 GMT) Full text and rfc822 format available.

Added tag(s) notabug. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 07 Jun 2015 18:14:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20761; Package emacs. (Sun, 07 Jun 2015 18:42:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 20761 <at> debbugs.gnu.org
Subject: Re: bug#20761: 25.0.50.1, beginning-of-defun matches inside string
Date: Sun, 07 Jun 2015 20:41:28 +0200
Am 07.06.2015 um 20:13 schrieb Glenn Morris:
> Andreas Röhler wrote:
>
>> (defun asdf ()
>>    "
>> (defun foo1 (&optional beg end)
>>    sdsd"
>> )
> Unescaped paren in column 0.

Can't a string have that?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20761; Package emacs. (Mon, 08 Jun 2015 05:19:01 GMT) Full text and rfc822 format available.

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

From: Nicolas Richard <youngfrog <at> members.fsf.org>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: Glenn Morris <rgm <at> gnu.org>, 20761 <at> debbugs.gnu.org
Subject: Re: bug#20761: 25.0.50.1, beginning-of-defun matches inside string
Date: Mon, 08 Jun 2015 07:18:26 +0200
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
> Am 07.06.2015 um 20:13 schrieb Glenn Morris:
>> Andreas Röhler wrote:
>>
>>> (defun asdf ()
>>>    "
>>> (defun foo1 (&optional beg end)
>>>    sdsd"
>>> )
>> Unescaped paren in column 0.
>
> Can't a string have that?

They can, but the convention is to not do that :
(info "(emacs) Left Margin Paren")

It's also in the docstring of beginning-of-defun
> When `open-paren-in-column-0-is-defun-start' is non-nil, a defun
> is assumed to start where there is a char with open-parenthesis
> syntax at the beginning of a line.

-- 
Nico.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20761; Package emacs. (Mon, 08 Jun 2015 05:47:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Nicolas Richard <youngfrog <at> members.fsf.org>
Cc: Glenn Morris <rgm <at> gnu.org>, 20761 <at> debbugs.gnu.org
Subject: Re: bug#20761: 25.0.50.1, beginning-of-defun matches inside string
Date: Mon, 08 Jun 2015 07:45:40 +0200
Am 08.06.2015 um 07:18 schrieb Nicolas Richard:
> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>> Am 07.06.2015 um 20:13 schrieb Glenn Morris:
>>> Andreas Röhler wrote:
>>>
>>>> (defun asdf ()
>>>>     "
>>>> (defun foo1 (&optional beg end)
>>>>     sdsd"
>>>> )
>>> Unescaped paren in column 0.
>> Can't a string have that?
> They can, but the convention is to not do that :
> (info "(emacs) Left Margin Paren")

An oddity from times, where parse-partial-sexp was not available, time 
to get rid of that.


> It's also in the docstring of beginning-of-defun
>> When `open-paren-in-column-0-is-defun-start' is non-nil, a defun
>> is assumed to start where there is a char with open-parenthesis
>> syntax at the beginning of a line.

Ditto, just legacy, no need for that.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20761; Package emacs. (Mon, 08 Jun 2015 09:11:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#20761: 25.0.50.1, beginning-of-defun matches inside string
Date: Mon, 08 Jun 2015 11:09:35 +0200
Am 07.06.2015 um 19:21 schrieb Andreas Röhler:
> emacs -Q
>
> With cursor at end of string below:
>
> (defun asdf ()
>   "
> (defun foo1 (&optional beg end)
>   sdsd"
> )
>
> ;;;
>
> C-M-a stops  inside string at "(defun foo1"
>
> GNU Emacs 25.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.23) of 
> 2015-06-07
>
> Solution:
>
> beginning-of-defun-raw must check if being inside string.
>
>
>

This should fix it:

(defun ar-beginning-of-defun (&optional arg)
  "Move to the beginning of a function definition.

Returns position, if successful, nil otherwise

Calls `beginning-of-defun-function', when set "
  (interactive "P")
  (unless (bobp)
    (skip-chars-backward " \t\r\n\f")
    (forward-char -1)
    (let ((pos (car-safe (nth 9 (parse-partial-sexp (point-min) 
(point))))))
      (if beginning-of-defun-function
      (funcall beginning-of-defun-function arg)
    (and pos
         (goto-char pos))))))

Optional arg here is for special needs, switches between class and 
method defs for example.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20761; Package emacs. (Sun, 02 Apr 2017 05:17:01 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 20761 <at> debbugs.gnu.org
Subject: Re: bug#20761: 25.0.50.1, beginning-of-defun matches inside string
Date: Sun, 02 Apr 2017 01:18:06 -0400
retitle 20761 beginning-of-defun matches column 0 paren inside string literal
forcemerge 20761 20284
tags 20761 wontfix
quit

Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

> This should fix it:
>
> (defun ar-beginning-of-defun (&optional arg)
>   "Move to the beginning of a function definition.
>
> Returns position, if successful, nil otherwise
>
> Calls `beginning-of-defun-function', when set "
>   (interactive "P")
>   (unless (bobp)
>     (skip-chars-backward " \t\r\n\f")
>     (forward-char -1)
>     (let ((pos (car-safe (nth 9 (parse-partial-sexp (point-min) (point))))))
>       (if beginning-of-defun-function
>       (funcall beginning-of-defun-function arg)
>     (and pos
>          (goto-char pos))))))

M-x find-library org RET
M->
(benchmark 1 '(ar-beginning-of-defun)) ; Elapsed time: 0.414771s, also it puts point in the wrong place
(benchmark 1 '(beginning-of-defun))    ; Elapsed time: 0.000126s
M-: (setq open-paren-in-column-0-is-defun-start nil)
(benchmark 1 '(beginning-of-defun))    ; Elapsed time: 0.002505s




Changed bug title to 'beginning-of-defun matches column 0 paren inside string literal' from '25.0.50.1, beginning-of-defun matches inside string' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 02 Apr 2017 05:17:02 GMT) Full text and rfc822 format available.

Forcibly Merged 20284 20761. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 02 Apr 2017 05:17:02 GMT) Full text and rfc822 format available.

Added tag(s) wontfix. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 02 Apr 2017 05:17:02 GMT) Full text and rfc822 format available.

Merged 20284 20761 26642 27920. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 02 Aug 2017 17:15:02 GMT) Full text and rfc822 format available.

Disconnected #27920 from all other report(s). Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Wed, 29 Nov 2017 02:33:05 GMT) Full text and rfc822 format available.

Added tag(s) fixed; removed tag(s) notabug and wontfix. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Sat, 10 Feb 2018 13:59:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 20284 <at> debbugs.gnu.org and Tim Visher <tim.visher <at> gmail.com> Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Sat, 10 Feb 2018 13:59:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 11 Mar 2018 11:24:06 GMT) Full text and rfc822 format available.

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

Previous Next


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