GNU bug report logs - #24542
25.1.50; The symbol `@' and sexp scanning

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Sun, 25 Sep 2016 17:43:02 UTC

Severity: minor

Tags: confirmed

Merged with 11314

Found in versions 24.1.50, 25.1.50, 27.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


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

From: npostavs <at> users.sourceforge.net
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 24542 <at> debbugs.gnu.org
Subject: Re: bug#24542: 25.1.50; The symbol `@' and sexp scanning
Date: Mon, 02 Jan 2017 15:37:28 -0500
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Michael Heerdegen <michael_heerdegen <at> web.de> writes:
>
>> insert
>>
>>     (eq element '@)
>>
>> in an elisp mode buffer (e.g. scratch).  Put point at the quote or the
>> "@".  Eval
>>
>>     (goto-char (scan-sexps (point) 1))
>>
>> and you get an error like:
>>
>>
>> Debugger entered--Lisp error: (scan-error "Containing expression ends
>> prematurely" 15 16)
>
> It seems that you can replace the symbol `@' in this recipe with any
> symbol whose name has the form "@+", i.e. `@@' or `@@@' or...  When the
> symbol contains only one character different from "@", it doesn't seem
> to happen.

`@' has the prefix syntax flag, the elisp manual says `(elisp) Syntax Flags':

   * `p' identifies an additional prefix character for Lisp syntax.
     These characters are treated as whitespace when they appear between
                          ^^^^^^^^^^^^^^^^^^^^^
     expressions.  When they appear within an expression, they are
     handled according to their usual syntax classes.

So (eq element '@) acts the same as (eq element ' ).  This could be
changed with something the following patch, but I'm not sure if it's the
right thing for non-Lisp languages...

diff --git i/src/syntax.c w/src/syntax.c
index 0ee1c74..253d3fb 100644
--- i/src/syntax.c
+++ w/src/syntax.c
@@ -2681,7 +2681,16 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
 	    }
 
 	  if (prefix)
-	    continue;
+            {
+              int next_c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
+              int next_syntax = SYNTAX_WITH_FLAGS (next_c);
+              bool next_prefix = SYNTAX_FLAGS_PREFIX (next_syntax);
+              enum syntaxcode next_code = syntax_multibyte (next_c, multibyte_symbol_p);
+              if (next_prefix
+                  || next_code == Ssymbol
+                  || next_code == Sword)
+                continue;
+            }
 
 	  switch (code)
 	    {





This bug report was last modified 1 year and 40 days ago.

Previous Next


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