GNU bug report logs - #44592
In sh-script-mode, should the syntax of . and / be made symbol?

Previous Next

Package: emacs;

Reported by: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>

Date: Thu, 12 Nov 2020 13:50:01 UTC

Severity: normal

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44592 in the body.
You can then email your comments to 44592 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Thu, 12 Nov 2020 13:50:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 12 Nov 2020 13:50:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: In sh-script-mode, should the syntax of . and / be made symbol?
Date: Thu, 12 Nov 2020 14:49:32 +0100
In the syntax table of sh-script-mode, the syntax of . and / is
punctuation.  This has the advantage of being able to use, e.g.,
kill-sexp to kill one component of a path.  However, it also has the
disadvantage of not correctly indenting line continuations when a path
to a command is given.

As an example, consider:

    relative-path/to/configure --prefix=$prefix             \
                               --with-x                     \
                               --with-x-toolkit=gtk3        \
                               --with-cairo

(This is how I would expect it to be indented.)  Currently,
sh-script-mode would consider only relative-path to be the first sexp on
the leading line and therefore indent it as:

    relative-path/to/configure --prefix=$prefix     \
                 --with-x                           \
                 --with-x-toolkit=gtk3              \
                 --with-cairo

Changing the syntax of . and / to symbol would make the entire
relative-path/to/configure be considered the first sexp and therefore
give the correct indentation show above.

Moreover, one would then be able to use, e.g., kill-sexp to kill a full
path as opposed to just one component.

What do you think?  Alternatively, we could work on fixing only the
SMIE-provided indentation and leave the syntax as it is.

Best regards,
Dario

-- 
$ keyserver=hkps://hkps.pool.sks-keyservers.net
$ keyid=744A4F0B4F1C9371
$ gpg --keyserver $keyserver --search-keys $keyid




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Sat, 14 Nov 2020 16:45:02 GMT) Full text and rfc822 format available.

Message #8 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
Cc: 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Sat, 14 Nov 2020 17:44:17 +0100
Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com> writes:

> Changing the syntax of . and / to symbol would make the entire
> relative-path/to/configure be considered the first sexp and therefore
> give the correct indentation show above.
>
> Moreover, one would then be able to use, e.g., kill-sexp to kill a full
> path as opposed to just one component.

I think that sounds like a too drastic change in how the mode works,
perhaps -- how the killing commands (etc) works gets into your muscle
memory.

> What do you think?  Alternatively, we could work on fixing only the
> SMIE-provided indentation and leave the syntax as it is.

I think that sounds like a better solution.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Wed, 23 Dec 2020 16:06:02 GMT) Full text and rfc822 format available.

Message #11 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Wed, 23 Dec 2020 17:05:39 +0100
>> What do you think?  Alternatively, we could work on fixing only the
>> SMIE-provided indentation and leave the syntax as it is.
>
> I think that sounds like a better solution.

The simplest solution I can think of is to change the

    (skip-syntax-backward "w_'")

in ‘sh-smie--default-backward-token’ to

    (skip-syntax-backward ".w_'").

This fixes the issue, but I’m not sure about unwanted effects.
Any ideas if it could cause something to misbehave?

Best regards,
Dario

-- 
$ keyserver=hkps://hkps.pool.sks-keyservers.net
$ keyid=744A4F0B4F1C9371
$ gpg --keyserver $keyserver --search-keys $keyid




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Wed, 23 Dec 2020 22:25:02 GMT) Full text and rfc822 format available.

Message #14 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Wed, 23 Dec 2020 23:24:40 +0100
Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com> writes:

>>> What do you think?  Alternatively, we could work on fixing only the
>>> SMIE-provided indentation and leave the syntax as it is.
>>
>> I think that sounds like a better solution.
>
> The simplest solution I can think of is to change the
>
>     (skip-syntax-backward "w_'")
>
> in ‘sh-smie--default-backward-token’ to
>
>     (skip-syntax-backward ".w_'").
>
> This fixes the issue, but I’m not sure about unwanted effects.
> Any ideas if it could cause something to misbehave?

Perhaps Stefan has some comments here; added to the CCs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Thu, 24 Dec 2020 04:00:02 GMT) Full text and rfc822 format available.

Message #17 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>, 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Wed, 23 Dec 2020 22:59:14 -0500
>> The simplest solution I can think of is to change the
>>
>>     (skip-syntax-backward "w_'")
>>
>> in ‘sh-smie--default-backward-token’ to
>>
>>     (skip-syntax-backward ".w_'").
>>
>> This fixes the issue, but I’m not sure about unwanted effects.
>> Any ideas if it could cause something to misbehave?
>
> Perhaps Stefan has some comments here; added to the CCs.

I can't remember enough of how the syntax tables of sh-mode are setup.
So I suggest you just try it and see how it fares.

W.r.t only tweaking the SMIE behavior vs affecting `kill-sexp`, I think we
have `kill-word` for smaller chunks, so I don't see a convincing need to
use `kill-sexp` to stop at `/` boundaries.

But please add regression tests when you do that (and when you find
that it introduces new problems, please add those cases as additional
tests).


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Fri, 27 Aug 2021 17:10:02 GMT) Full text and rfc822 format available.

Message #20 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>, 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Fri, 27 Aug 2021 19:09:04 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>> The simplest solution I can think of is to change the
>>>
>>>     (skip-syntax-backward "w_'")
>>>
>>> in ‘sh-smie--default-backward-token’ to
>>>
>>>     (skip-syntax-backward ".w_'").
>>>
>>> This fixes the issue, but I’m not sure about unwanted effects.
>>> Any ideas if it could cause something to misbehave?
>>
>> Perhaps Stefan has some comments here; added to the CCs.
>
> I can't remember enough of how the syntax tables of sh-mode are setup.
> So I suggest you just try it and see how it fares.
>
> W.r.t only tweaking the SMIE behavior vs affecting `kill-sexp`, I think we
> have `kill-word` for smaller chunks, so I don't see a convincing need to
> use `kill-sexp` to stop at `/` boundaries.
>
> But please add regression tests when you do that (and when you find
> that it introduces new problems, please add those cases as additional
> tests).

I've now applied Dario's change to Emacs 28 (and added a test case).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 44592 <at> debbugs.gnu.org and Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 27 Aug 2021 17:10:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Sat, 28 Aug 2021 09:46:02 GMT) Full text and rfc822 format available.

Message #25 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Sat, 28 Aug 2021 11:44:59 +0200
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I've now applied Dario's change to Emacs 28 (and added a test case).

I wonder, would it make sense to also add ){ and (} to handle cases with
${braces}?  E.g. I'd like this indentation:

${path_to_root}/configure --prefix=$prefix\
                          --with-x

but right now (55e77a811) I am getting this:

${path_to_root}/configure --prefix=$prefix\
               --with-x

I'm don't know all that much about syntax classes and SMIE; still,
here's a "monkey see; monkey do" patch that works for me:

[further.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Sun, 29 Aug 2021 18:30:02 GMT) Full text and rfc822 format available.

Message #28 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Cc: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Sun, 29 Aug 2021 20:29:03 +0200
Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:

> -            (progn (skip-syntax-backward ".w_'")
> +            (progn (skip-syntax-backward ".w_'){(}")

I don't think that's quite correct -- { and } aren't syntax classes.
But just adding ( and ) seems to make the test case indent correctly, so
I've now pushed that to the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44592; Package emacs. (Sun, 29 Aug 2021 21:23:02 GMT) Full text and rfc822 format available.

Message #31 received at 44592 <at> debbugs.gnu.org (full text, mbox):

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 44592 <at> debbugs.gnu.org
Subject: Re: bug#44592: In sh-script-mode, should the syntax of . and / be
 made symbol?
Date: Sun, 29 Aug 2021 23:22:44 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
>
>> -            (progn (skip-syntax-backward ".w_'")
>> +            (progn (skip-syntax-backward ".w_'){(}")
>
> I don't think that's quite correct -- { and } aren't syntax classes.
> But just adding ( and ) seems to make the test case indent correctly, so
> I've now pushed that to the trunk.

Ah, right!  I had naively used C-u C-x = to check what syntax classes {
and } belonged to, and that told me "(}" and "){", respectively.

Thanks for your amendment!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 27 Sep 2021 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 281 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.