GNU bug report logs -
#15998
24.3; forward-sexp (scan-sexps) doesn't do well with some SEXPs
Previous Next
Reported by: Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Date: Fri, 29 Nov 2013 14:46:01 UTC
Severity: normal
Tags: moreinfo
Merged with 30132
Found in versions 24.3, 27.0.50
Fixed in version 29.1
Done: Lars 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 15998 in the body.
You can then email your comments to 15998 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Fri, 29 Nov 2013 14:46:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 29 Nov 2013 14:46:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
`forward-sexp', or `scan-sexps', doesn't seem to skip bool vectors correctly.
Bool vector's format is like #&N"XXX".
`forward-sexp' doesn't skip the whole bool vector, but stop before
double quotation.
And, maybe, just the same thing occurs for circular objects.
It skip only the label, and stop before the object.
Is the current behavior correct?
Regards,
Shigeru
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Fri, 29 Nov 2013 17:13:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 15998 <at> debbugs.gnu.org (full text, mbox):
> `forward-sexp', or `scan-sexps', doesn't seem to skip bool vectors correctly.
> Bool vector's format is like #&N"XXX".
> `forward-sexp' doesn't skip the whole bool vector, but stop before
> double quotation.
Indeed.
> And, maybe, just the same thing occurs for circular objects.
> It skip only the label, and stop before the object.
Indeed.
> Is the current behavior correct?
No, it's not. Patches welcome.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sun, 01 Dec 2013 20:09:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 15998 <at> debbugs.gnu.org (full text, mbox):
I tried to fix the issue, and seemingly successful.
But I found more to do newly, possibly. Those are,
1. #s(...) hash table
2. ^[...] ^^[...] char table
3. #@NUMBER comments
4. $! beginning of executable file
5. ## empty symbol
I think doing for 1, 2, 5 are practically sufficient.
Shigeru
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sun, 01 Dec 2013 20:45:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 15998 <at> debbugs.gnu.org (full text, mbox):
> I tried to fix the issue, and seemingly successful.
> But I found more to do newly, possibly. Those are,
> 1. #s(...) hash table
> 2. ^[...] ^^[...] char table
> 3. #@NUMBER comments
> 4. $! beginning of executable file
> 5. ## empty symbol
3 should only appear in .elc files and the mode used in .elc files
(emacs-lisp-byte-code-mode) already sets up syntax-propertize-function
to handle them correctly.
I don't know what 4 is. Or do you mean "#!" as the first two chars of
the file? We could setup syntax-propertize-function to mark them as
comments, indeed.
> I think doing for 1, 2, 5 are practically sufficient.
Sounds right.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Tue, 03 Dec 2013 09:48:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 15998 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> 2. ^[...] ^^[...] char table
Sorry, but it's #^[...] #^^[...]
>> 4. $! beginning of executable file
>I don't know what 4 is. Or do you mean "#!" as the first two chars of
>the file? We could setup syntax-propertize-function to mark them as
>comments, indeed.
It is just magic number of unix files.
(read-from-string "#!/usr/local/bin/emacs\n(pwd)") --> ((pwd) . 28)
see read1 in lread.c.
And, my changes to the latest emacs are,
1) add `scan-sexps' an optional argument, `elisp-syntax'.
2) pass `scan_lists' the optional argument.
3) `scan_lists' handles elisp specific handling when the argument is set.
4) `forward-sexp' calls `scan-sexps' with the optional argument non-nil
value when the current buffer's mode is elisp related mode.
Anso, do additional movement for labels of cyclic object, as is for
prefixes.
(Is a change in the last sentence above unnecessary?)
As a result, I seems doing expectedly on such an object as below.
(a b #&3"d" #&99"ZZZ" #1=a #2= b #1# #3= #40= (c) #40# #2# #10= #&10"A"
#s(dummy 1 2 3) #^^[dummy 1 2 3] #^[dummy 1 2 3] ## xyz)
Regards,
Shigeru
---------------------
ChangeLog
Add support for elisp syntax of bool vector, label of cyclic object,
hash table, char-table and empty symbol.
* lisp.el (forward-sexp)
* syntax.c (scan_lists, Fscan_lists, Fscan_sexps)
lisp.el
(defun forward-sexp (&optional arg)
"Move forward across one balanced expression (sexp).
With ARG, do it that many times. Negative arg -N means
move backward across N balanced expressions.
This command assumes point is not in a string or comment.
Calls `forward-sexp-function' to do the work, if that is non-nil."
(interactive "^p")
(let ((elisp (memq major-mode '(emacs-lisp-mode
;;eshell-mode
inferior-emacs-lisp-mode
lisp-interaction-mode))))
(or arg (setq arg 1))
(if forward-sexp-function
(funcall forward-sexp-function arg)
(goto-char (or (scan-sexps (point) arg elisp) (buffer-end arg)))
(when (< arg 0)
(when elisp
(save-match-data
(while (re-search-backward "#[0-9]+=\\s-*\\=" nil t))))
(backward-prefix-chars)))))
[syntax.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Tue, 03 Dec 2013 17:10:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 15998 <at> debbugs.gnu.org (full text, mbox):
> 1) add `scan-sexps' an optional argument, `elisp-syntax'.
I don't think I want to add such elisp-specific hacks to the
scan-sexps code. Better would be to change emacs-lisp-mode to set
forward-sexp-function to a function that handles those cases.
Stefan
Added tag(s) patch.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 04 Mar 2016 15:35:15 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Wed, 26 Jun 2019 15:24:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> 1) add `scan-sexps' an optional argument, `elisp-syntax'.
>
> I don't think I want to add such elisp-specific hacks to the
> scan-sexps code. Better would be to change emacs-lisp-mode to set
> forward-sexp-function to a function that handles those cases.
But do we want to implement a brand new forward-sexp just for Emacs
Lisp? I'm assuming that a Lisp-based implementation would be
uncomfortably slow...
To recap, the following doesn't forward-sexp correctly:
1. #s(...) hash table
2. ^[...] ^^[...] char table
5. ## empty symbol
9. #&N"XXX" bool vector
And especially 1) is rather annoying...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Wed, 26 Jun 2019 17:07:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 15998 <at> debbugs.gnu.org (full text, mbox):
> But do we want to implement a brand new forward-sexp just for Emacs Lisp?
No, but I think syntax-propertize can take care of those things.
> I'm assuming that a Lisp-based implementation would be
> uncomfortably slow...
>
> To recap, the following doesn't forward-sexp correctly:
>
> 1. #s(...) hash table
> 2. ^[...] ^^[...] char table
> 5. ## empty symbol
> 9. #&N"XXX" bool vector
[ I believe for (2) there's a missing # in there somewhere, right? ]
> And especially 1) is rather annoying...
I do wonder when/where these things show up, tho.
I'd expect those to appear in .elc files and in the output of M-: and
IELM buffers, but not in emacs-lisp-mode buffers.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Thu, 27 Jun 2019 10:31:01 GMT)
Full text and
rfc822 format available.
Message #31 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> I do wonder when/where these things show up, tho.
> I'd expect those to appear in .elc files and in the output of M-: and
> IELM buffers, but not in emacs-lisp-mode buffers.
That's true. Those things mostly show up when discussing Emacs Lisp and
not when writing Emacs Lisp -- so they're really more in text buffers
than in Lisp buffers...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sun, 07 Jul 2019 02:09:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 15998 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> But do we want to implement a brand new forward-sexp just for Emacs Lisp?
>
> No, but I think syntax-propertize can take care of those things.
The patch below seems to work, no new sexp movement commands needed?
[0001-Handle-elisp-syntax-better-Bug-15998.patch (text/x-diff, inline)]
From 463f98c55ff7d6bde576a9538d3ae3a33a576cf5 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 6 Jul 2019 21:55:03 -0400
Subject: [PATCH] Handle elisp #-syntax better (Bug#15998)
* elisp-mode.el (elisp-mode-syntax-propertize): New function.
(emacs-lisp-mode): Set it as syntax-propertize-function.
---
lisp/progmodes/elisp-mode.el | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index cb1b17b447..c86277a309 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -213,6 +213,20 @@ emacs-lisp-macroexpand
(if (bolp) (delete-char -1))
(indent-region start (point)))))
+(defun elisp-mode-syntax-propertize (start end)
+ (goto-char start)
+ (funcall
+ (syntax-propertize-rules
+ ("##" (0 (unless (nth 8 (syntax-ppss)) ; Empty symbol.
+ (string-to-syntax "_"))))
+ ((rx "#" (or (seq (group-n 1 (+ digit) "=")) ; Object label.
+ (seq (group-n 1 "&" (+ digit)) ?\") ; Bool-vector.
+ (seq (group-n 1 "s") "(") ; Record.
+ (seq (group-n 1 (+ "^")) "["))) ; Char-table.
+ (1 (unless (save-excursion (nth 8 (syntax-ppss (match-beginning 0))))
+ (string-to-syntax "'")))))
+ start end))
+
(defcustom emacs-lisp-mode-hook nil
"Hook run when entering Emacs Lisp mode."
:options '(eldoc-mode imenu-add-menubar-index checkdoc-minor-mode)
@@ -242,6 +256,7 @@ emacs-lisp-mode
#'elisp-eldoc-documentation-function)
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
(setq-local project-vc-external-roots-function #'elisp-load-path-roots)
+ (setq-local syntax-propertize-function #'elisp-mode-syntax-propertize)
(add-hook 'completion-at-point-functions
#'elisp-completion-at-point nil 'local)
(add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
--
2.11.0
Merged 15998 30132.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 07 Jul 2019 02:16:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sun, 07 Jul 2019 13:29:01 GMT)
Full text and
rfc822 format available.
Message #39 received at 15998 <at> debbugs.gnu.org (full text, mbox):
>> No, but I think syntax-propertize can take care of those things.
> The patch below seems to work, no new sexp movement commands needed?
It should work indeed, tho I'm not sure it'll fix the original problem,
because I don't know *where* the original problem happened and this
patch only fixes the case where we do such navigation in
emacs-lisp-mode, but things #s(...) and #&"..." are *very* rare in
those buffers.
So I'm not completely sure the cost imposed by this patch is worth
the benefit. Maybe we could start by adding those rules to the
elisp-byte-code-mode?
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sun, 07 Jul 2019 13:48:02 GMT)
Full text and
rfc822 format available.
Message #42 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>>> No, but I think syntax-propertize can take care of those things.
>> The patch below seems to work, no new sexp movement commands needed?
>
> It should work indeed, tho I'm not sure it'll fix the original problem,
> because I don't know *where* the original problem happened and this
> patch only fixes the case where we do such navigation in
> emacs-lisp-mode, but things #s(...) and #&"..." are *very* rare in
> those buffers.
I tend to end up with those things in my *scratch* buffer, after
evaluating various expressions (more so the #s(...) than #&"...", I
don't have much call for messing with bool vectors). Michael bumped
into an instance of ## in org-list.el (see merged Bug#30132), although
that seems like a mistake in org.
> So I'm not completely sure the cost imposed by this patch is worth
> the benefit.
On the benefit side, it would allow removing the hack I put in for
indentation of #s(...) (that was for IELM, see Bug#31984). On the other
hand, this seems to be breaking some edebug tests, so that needs more
investigation before it could be installed.
Removed tag(s) patch.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 15 Apr 2020 01:26:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Fri, 06 May 2022 15:51:02 GMT)
Full text and
rfc822 format available.
Message #47 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Noam Postavsky <npostavs <at> gmail.com> writes:
> * elisp-mode.el (elisp-mode-syntax-propertize): New function.
> (emacs-lisp-mode): Set it as syntax-propertize-function.
I've tried the patch, and it seems to work well. However, it makes
edebug-tests-dotted-forms hang completely, and breaks other edebug
tests.
I've poked at this briefly, but I've been unable to see what makes
things hang here. It would be nice to get this to work -- did you get
any further in debugging these test problems, Noam?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 06 May 2022 15:52:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Fri, 06 May 2022 16:31:01 GMT)
Full text and
rfc822 format available.
Message #52 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> I've poked at this briefly, but I've been unable to see what makes
> things hang here. It would be nice to get this to work -- did you get
> any further in debugging these test problems, Noam?
The offending bit was this:
(seq (group-n 1 (+ digit) "=")) ; Object label.
Which is something that should never appear in Lisp files anyway. The
rest seem unproblematic (except possible performance problems), but
after testing it for a few minutes, I don't really see anything
noticeable.
So I'm pushing Noam's patch to Emacs 29 (with that object label thing
removed).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 29.1, send any further explanations to
30132 <at> debbugs.gnu.org and Michael Heerdegen <michael_heerdegen <at> web.de>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 06 May 2022 16:32:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sat, 07 May 2022 00:09:02 GMT)
Full text and
rfc822 format available.
Message #57 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
> > I've poked at this briefly, but I've been unable to see what makes
> > things hang here. It would be nice to get this to work -- did you get
> > any further in debugging these test problems, Noam?
>
> The offending bit was this:
>
> (seq (group-n 1 (+ digit) "=")) ; Object label.
I wonder why.
> Which is something that should never appear in Lisp files anyway.
> [...]
> So I'm pushing Noam's patch to Emacs 29 (with that object label thing
> removed).
Thanks. My original use case seems to be fixed.
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sat, 07 May 2022 04:06:01 GMT)
Full text and
rfc822 format available.
Message #60 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> > The offending bit was this:
> >
> > (seq (group-n 1 (+ digit) "=")) ; Object label.
>
> I wonder why.
Dunno how the Edebug tests are supposed to run...: When I load
edebug-tests.el and run those tests with M-x ert-run-tests-interactively
t RET, I always get lots of fails - also with what is installed now (and
even without the patch).
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15998
; Package
emacs
.
(Sat, 07 May 2022 10:18:02 GMT)
Full text and
rfc822 format available.
Message #63 received at 15998 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> Dunno how the Edebug tests are supposed to run...: When I load
> edebug-tests.el and run those tests with M-x ert-run-tests-interactively
> t RET, I always get lots of fails - also with what is installed now (and
> even without the patch).
I run them with "make check" or "make edebug-tests".
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 04 Jun 2022 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 14 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.