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: Michael Heerdegen
Subject: bug#24542: 25.1.50; The symbol `@' and sexp scanning
Date: Tue, 03 Jan 2017 13:46:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux)

npostavs@users.sourceforge.net 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 ' ).

I don't agree with your interpretation.  `@' is an (textual
representation of an) expression in the above example, so "these
characters" don't "appear between expressions" in this case.  Could be
that this wording led to a wrong implementation, however.

> 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)
>           {

Thanks for the patch.  Can anyone judge whether we can do this?


Thanks,

Michael. 





reply via email to

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