GNU bug report logs -
#77746
[PATCH] sh-mode: Fix incorrect word syntax for punctuation in sh-mode
Previous Next
Reported by: James Cherti <contact <at> jamescherti.com>
Date: Fri, 11 Apr 2025 14:56:02 UTC
Severity: normal
Tags: patch
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 77746 <at> debbugs.gnu.org (full text, mbox):
>> In sh and Bash, the characters !%^~:.,= and are not valid in variable or
>> function names.
I'm not positive about all of them, but at least some of those can
appear in the names of commands.
>> Assigning them the "_" syntax causes Emacs to treat them as word
>> constituents,
Not quite: it makes them appear as "symbol constituents".
>> disrupting navigation and completion (e.g. dabbrev-expand,
>> forward-word, etc.).
`forward-word` for example shouldn't be affected (unless you enable
`superword-mode`). `dabbrev-expand` OTOH is affected, indeed.
>> The attached patch updates the syntax table in sh-mode to mark
>> these characters as punctuation, correcting the issue.
> TBH, such a change sounds scary, as it could cause all kinds of
> unintended changes in behavior.
It's indeed risky/delicate. The syntax-tables are a fairly crude tool,
so we often need to use different tables at different places.
Rather than go straight to changing the syntax-table, I suggest you
start by providing some concrete examples of behaviors you consider
incorrect with the current code. Maybe changing the main syntax-table
of that mode will be the better option, but if so, it'll probably
require changing other code to keep using the current
syntax-table there.
[ I haven't tested it, but I'd expect trouble with your patch either in
font-lock or indentation if you have commands with names like
`if-config`. ]
Stefan
This bug report was last modified 107 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.