GNU bug report logs -
#24542
25.1.50; The symbol `@' and sexp scanning
Previous Next
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 #14 received at 24542 <at> debbugs.gnu.org (full text, mbox):
npostavs <at> 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.
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.