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 #104 received at 77746 <at> debbugs.gnu.org (full text, mbox):
On 2025-04-15 16:46, Stefan Monnier via Bug reports for GNU Emacs, the
Swiss army knife of text editors wrote:
>> In my view, variables and functions are the two most
>> significant types of symbols when developing shell scripts.
>
> I know. But the fact is, we don't really have any maintainer for
> that code. I'm probably one of those most familiar with it (from back
> when I implemented the SMIE-based indentation code), and I'm not sure
> what kind of impact your change could have, so I'm uneasy accepting
> your patch.
Hello Stefan,
I fully understand your desire to be certain before accepting it.
> I added Dmitry to the Cc because AFAICT he's the last one to have
> changed that syntax-table and he seems to have changed it for the same
> kind of reasons as you:
Excellent. Thanks. This will help move the discussion about this
patch forward.
I hope we can make progress toward getting this (or a variation
of it) merged into Emacs.
> commit f6277911eb2c520aec8f0efd80c91999226e3322
> Author: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Fri Oct 2 07:11:56 2020 +0200
>
> Make xref work better on variables in shell-script-mode
>
> * lisp/progmodes/sh-script.el (sh-mode-syntax-table): Classify "/"
> as punctuation so that `M-.' on $foo/bar works on the $foo part
> (bug#25585).
>
> diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
> --- a/lisp/progmodes/sh-script.el
> +++ b/lisp/progmodes/sh-script.el
> @@ -370,26 +370,27 @@
> (defvar sh-mode-syntax-table
> [...]
> ?= "."
> + ?/ "."
> ?\; "."
> ?| "."
>
> Apparently this change hasn't brought any trouble over the last 5 years,
> so that's encouraging.
Yes, that's encouraging.
(For those who haven’t read the previous email: I’ve been
using Emacs with this patch applied for over a year without
encountering any issues in my sh-mode/bash-ts-mode
workflow. I generally search for the symbol at point,
highlight the symbol at point, complete using dabbrev, and
a few other methods...)
> AFAICT the chars you want to change have had the symbol-constituent
> syntax "forever", i.e. since the first commit:
>
> commit ac59aed83fbdfd298f58a1a7e638264b0c3b0caa
> Author: Richard M. Stallman <rms <at> gnu.org>
> Date: Tue Mar 22 05:43:25 1994 +0000
>
> entered into RCS
>
> diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
> --- /dev/null
> +++ b/lisp/progmodes/sh-script.el
> [...]
> +(defvar sh-mode-syntax-table
> + (let ((table (copy-syntax-table)))
> + (modify-syntax-entry ?\# "<" table)
> + (modify-syntax-entry ?\^l ">#" table)
> + (modify-syntax-entry ?\n ">#" table)
> + (modify-syntax-entry ?\" "\"\"" table)
> + (modify-syntax-entry ?\' "\"'" table)
> + (modify-syntax-entry ?\` "$`" table)
> + (modify-syntax-entry ?$ "_" table)
> + (modify-syntax-entry ?! "_" table)
> + (modify-syntax-entry ?% "_" table)
> + (modify-syntax-entry ?: "_" table)
> + (modify-syntax-entry ?. "_" table)
> + (modify-syntax-entry ?^ "_" table)
> + (modify-syntax-entry ?~ "_" table)
> + table)
> + "Syntax table in use in Shell-Script mode.")
>
> That can be taken to mean that we have 30 years of experience with that
> setting as being "the right one". Of course it can also be taken to
It's interesting to see how many years this syntax table has
remained unchanged.
> mean that it was just an accident that simply bites rarely enough that
> nobody bothered to fix it yet.
Or, as in my case before submitting this patch, developers
may have simply patched Emacs locally for months, either by
modifying the source or adjusting the syntax table via Elisp.
Many users prefer to address annoyances like the one this
patch fixes by "patching" locally through their init files,
rather than going through the process of submitting an actual
patch.
>
>
> Stefan
--
James Cherti
GitHub: https://github.com/jamescherti
Website: https://www.jamescherti.com/
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.