Subject: Re: bug#77746: [PATCH] sh-mode: Fix incorrect word syntax for punctuation in sh-mode

From: Dmitry Gutov <[email-masked]>
Date: Thu, 17 Apr 2025 02:43:14 +0300

Hi! Regarding this:

On 15/04/2025 23:46, Stefan Monnier via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> 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:
> 
>      commit f6277911eb2c520aec8f0efd80c91999226e3322
>      Author: Dmitry Gutov<[email-masked]>
>      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.

Sorry to say, I don't have much more experience with these files. The 
'/' character seemed safe enough, since it sounds silly to define 
symbols including it, given how prevalent its other use in scripts.

A lot of the questions that have been brought up in this thread seem 
very good. In particular, is there a more urgent subset of the 
characters that we would want to change, and what are the code examples 
that would be affected? Even if we just list the positive cases. But 
preferably realistic.

E.g. this one from the screenshot:

   var%name=1

What is such code supposed to do? Is that an assignment inside the 
modulo operation?

More generally, a good argument for a wholesale change could be made 
with be an analysis of some larger body of shell scripts. For example, 
the Git codebase has a lot of .sh files (even if a lot of them are in 
the 't' directory). Better examples welcome.