bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24542: 25.1.50; The symbol `@' and sexp scanning


From: npostavs
Subject: bug#24542: 25.1.50; The symbol `@' and sexp scanning
Date: Mon, 02 Jan 2017 15:37:28 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Michael Heerdegen <michael_heerdegen@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)
            {






reply via email to

[Prev in Thread] Current Thread [Next in Thread]