GNU bug report logs - #77746
[PATCH] sh-mode: Fix incorrect word syntax for punctuation in sh-mode

Previous Next

Package: emacs;

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


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: James Cherti <contact <at> jamescherti.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Dmitry Gutov <dgutov <at> yandex.ru>, 77746 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: bug#77746: [PATCH] sh-mode: Fix incorrect word syntax for punctuation in sh-mode
Date: Tue, 15 Apr 2025 16:46:32 -0400
> 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.

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 <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.

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
mean that it was just an accident that simply bites rarely enough that
nobody bothered to fix it yet.


        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.