GNU bug report logs -
#76985
Invert when symbol syntax class is used for ##
Previous Next
To reply to this bug, email your comments to 76985 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76985
; Package
emacs
.
(Wed, 12 Mar 2025 21:27:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jonas Bernoulli <jonas <at> bernoul.li>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 12 Mar 2025 21:27:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
The `llama' package uses the `##' symbol and encourages not putting any
space in between that and the following symbol.
Since it was added three years ago, `elisp-mode-syntax-propertize'
explicitly assigns the symbol syntax class to "##", which means that
code that relies on the syntax alone (such as complete-symbol), thinks
that ##foo is one symbol, when that are actually two symbols ## and foo.
For some reason [1: 6ccc4b6bc8a] limited assigning symbol syntax for ##
to when that appears in code. I propose we do the opposite: do NOT use
symbol syntax in code, but DO use symbol syntax in strings and comments.
Do the latter so that `##' is highlighted like other symbols would, when
quoted like that.
1: 2022-05-06 6ccc4b6bc8a14daca6b3e3250574752c90c1eb9b
Handle elisp #-syntax better in Emacs Lisp mode
I am opening this bug-report because Stefan Monnier commented on
llama.el's advice for `elisp-mode-syntax-propertize', to ask whether
such a bug-report exists:
>> + (syntax-propertize-rules
>> + ;; Empty symbol.
>> + ;; {{ Comment out to prevent the `##' from becoming part of
>> + ;; the following symbol when there is no space in between.
>> + ;; ("##" (0 (unless (nth 8 (syntax-ppss))
>> + ;; (string-to-syntax "_"))))
>> + ;; }}
>> + ;; {{ As for other symbols, use `font-lock-constant-face' in
>> + ;; docstrings and comments.
>> + ("##" (0 (when (nth 8 (syntax-ppss))
>> + (string-to-syntax "_"))))
>> + ;; }}
>
> BTW, is there a bug-report about this? It seems this issue is not
> really dependent on what ## is used for (except maybe for the fact that
> `llama.el` encourages the use a `##` immediately followed by another
> symbol without any intervening space).
>
> Stefan
Coming from an override advice, the above code includes "original
vs. advice" commentary. As a patch to Emacs, this change look like
this:
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
@@ -269,9 +269,12 @@ elisp-mode-syntax-propertize
(let ((case-fold-search nil))
(funcall
(syntax-propertize-rules
- ;; Empty symbol.
- ("##" (0 (unless (nth 8 (syntax-ppss))
- (string-to-syntax "_"))))
+ ;; Prevent ## (the empty symbol) from becoming part of a
+ ;; preceeding or following symbol by *not* explicitly assigning
+ ;; symbol syntax class here; except in comments and strings, so
+ ;; that `##' gets highlighted like other `symbols'.
+ ("##" (0 (and (nth 8 (syntax-ppss))
+ (string-to-syntax "_"))))
;; Prevent the @ from becoming part of a following symbol.
(",@" (0 (unless (nth 8 (syntax-ppss))
(string-to-syntax "'"))))
Jonas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76985
; Package
emacs
.
(Wed, 12 Mar 2025 22:16:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
> The `llama' package uses the `##' symbol and encourages not putting any
> space in between that and the following symbol.
>
> Since it was added three years ago, `elisp-mode-syntax-propertize'
> explicitly assigns the symbol syntax class to "##", which means that
> code that relies on the syntax alone (such as complete-symbol), thinks
> that ##foo is one symbol, when that are actually two symbols ## and foo.
Do you have specific behaviors w.r.t highlighting, navigation, or
indentation, that matter specifically?
To be "technically" more correct, I suspect `##` in code should be treated
in the syntax tables as some kind of "pair of an open-paren-like thingy
and close-paren-like thingy", so that navigation with M-C-f over `##foo`
skips it in two steps.
I suspect this will lead to indentation that's different from the
one you'd prefer, e.g.
(list (##foo
bar)
(##foo bar
baz))
instead of
(list (##foo
bar)
(##foo bar
baz))
But I think this is specific to llama's use of ## so ideally, we'd fix
that on the `llama.el` side with some `list-indent-function` magic.
> For some reason [1: 6ccc4b6bc8a] limited assigning symbol syntax for ##
> to when that appears in code. I propose we do the opposite: do NOT use
> symbol syntax in code, but DO use symbol syntax in strings and comments.
> Do the latter so that `##' is highlighted like other symbols would, when
> quoted like that.
Sounds good to me. I think we left ## untouched in text/comments
because we assumed that ## in comments would usually not represent ELisp
code but something else. With the use of ## for llama, this presumption
does not seem valid any more.
Stefan
This bug report was last modified 31 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.