* bug#20761: 25.0.50.1, beginning-of-defun matches inside string
@ 2015-06-07 17:21 Andreas Röhler
2015-06-07 18:13 ` Glenn Morris
2015-06-08 9:09 ` Andreas Röhler
0 siblings, 2 replies; 7+ messages in thread
From: Andreas Röhler @ 2015-06-07 17:21 UTC (permalink / raw)
To: 20761
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20761: 25.0.50.1, beginning-of-defun matches inside string
2015-06-07 17:21 bug#20761: 25.0.50.1, beginning-of-defun matches inside string Andreas Röhler
@ 2015-06-07 18:13 ` Glenn Morris
2015-06-07 18:41 ` Andreas Röhler
2015-06-08 9:09 ` Andreas Röhler
1 sibling, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2015-06-07 18:13 UTC (permalink / raw)
To: Andreas Röhler; +Cc: 20761
Andreas Röhler wrote:
> (defun asdf ()
> "
> (defun foo1 (&optional beg end)
> sdsd"
> )
Unescaped paren in column 0.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20761: 25.0.50.1, beginning-of-defun matches inside string
2015-06-07 18:13 ` Glenn Morris
@ 2015-06-07 18:41 ` Andreas Röhler
2015-06-08 5:18 ` Nicolas Richard
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2015-06-07 18:41 UTC (permalink / raw)
To: Glenn Morris; +Cc: 20761
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?
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20761: 25.0.50.1, beginning-of-defun matches inside string
2015-06-07 18:41 ` Andreas Röhler
@ 2015-06-08 5:18 ` Nicolas Richard
2015-06-08 5:45 ` Andreas Röhler
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Richard @ 2015-06-08 5:18 UTC (permalink / raw)
To: Andreas Röhler; +Cc: 20761
Andreas Röhler <andreas.roehler@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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20761: 25.0.50.1, beginning-of-defun matches inside string
2015-06-08 5:18 ` Nicolas Richard
@ 2015-06-08 5:45 ` Andreas Röhler
0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2015-06-08 5:45 UTC (permalink / raw)
To: Nicolas Richard; +Cc: 20761
Am 08.06.2015 um 07:18 schrieb Nicolas Richard:
> Andreas Röhler <andreas.roehler@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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20761: 25.0.50.1, beginning-of-defun matches inside string
2015-06-07 17:21 bug#20761: 25.0.50.1, beginning-of-defun matches inside string Andreas Röhler
2015-06-07 18:13 ` Glenn Morris
@ 2015-06-08 9:09 ` Andreas Röhler
2017-04-02 5:18 ` npostavs
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2015-06-08 9:09 UTC (permalink / raw)
To: 20761
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20761: 25.0.50.1, beginning-of-defun matches inside string
2015-06-08 9:09 ` Andreas Röhler
@ 2017-04-02 5:18 ` npostavs
0 siblings, 0 replies; 7+ messages in thread
From: npostavs @ 2017-04-02 5:18 UTC (permalink / raw)
To: Andreas Röhler; +Cc: 20761
retitle 20761 beginning-of-defun matches column 0 paren inside string literal
forcemerge 20761 20284
tags 20761 wontfix
quit
Andreas Röhler <andreas.roehler@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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-04-02 5:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-07 17:21 bug#20761: 25.0.50.1, beginning-of-defun matches inside string Andreas Röhler
2015-06-07 18:13 ` Glenn Morris
2015-06-07 18:41 ` Andreas Röhler
2015-06-08 5:18 ` Nicolas Richard
2015-06-08 5:45 ` Andreas Röhler
2015-06-08 9:09 ` Andreas Röhler
2017-04-02 5:18 ` npostavs
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).