GNU bug report logs -
#52496
syntax highlighting problem on emacs shell-script mode
Previous Next
Reported by: Yilkal Argaw <yilkalargawworkneh <at> gmail.com>
Date: Wed, 15 Dec 2021 00:36:02 UTC
Severity: normal
Tags: moreinfo, patch
Fixed in version 29.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 52496 in the body.
You can then email your comments to 52496 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Wed, 15 Dec 2021 00:36:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Yilkal Argaw <yilkalargawworkneh <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 15 Dec 2021 00:36:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I don't know exactly how to explain it but emacs comments most of a
script if the script contains too many long strings. As an example
look at the syntax highlighting of the script at
https://gitlab.com/uppercat/tlbx/-/raw/master/tlbx and compare the
syntax highlighting for it in vim and emacs.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 12:56:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 52496 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Yilkal Argaw <yilkalargawworkneh <at> gmail.com> writes:
> I don't know exactly how to explain it but emacs comments most of a
> script if the script contains too many long strings. As an example
> look at the syntax highlighting of the script at
> https://gitlab.com/uppercat/tlbx/-/raw/master/tlbx and compare the
> syntax highlighting for it in vim and emacs.
You don't say what Emacs version this is with, or which parts you think
Emacs is displaying wrong. Is it the heredoc thing that's wrong, or
something else in addition?
[Message part 2 (image/png, inline)]
[Message part 3 (text/plain, inline)]
It seems like sh-mode isn't interpreting that "@" as the end of the
heredoc.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sun, 19 Dec 2021 12:56:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 13:31:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 52496 <at> debbugs.gnu.org (full text, mbox):
On Dez 19 2021, Lars Ingebrigtsen wrote:
> It seems like sh-mode isn't interpreting that "@" as the end of the
> heredoc.
ELISP> (let ((s " <<- @\n")) (string-match sh-here-doc-open-re s) (match-string 1 s))
"-"
ELISP> (let ((s " <<- EOF\n")) (string-match sh-here-doc-open-re s) (match-string 1 s))
"EOF"
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 13:34:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 52496 <at> debbugs.gnu.org (full text, mbox):
Andreas Schwab <schwab <at> linux-m68k.org> writes:
>> It seems like sh-mode isn't interpreting that "@" as the end of the
>> heredoc.
>
> ELISP> (let ((s " <<- @\n")) (string-match sh-here-doc-open-re s)
> ELISP> (match-string 1 s))
> "-"
> ELISP> (let ((s " <<- EOF\n")) (string-match sh-here-doc-open-re s)
> ELISP> (match-string 1 s))
> "EOF"
Right. I haven't real the shell documentation -- is "@" a valid heredoc
... separator?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 13:58:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 52496 <at> debbugs.gnu.org (full text, mbox):
On Dez 19 2021, Lars Ingebrigtsen wrote:
> Right. I haven't real the shell documentation -- is "@" a valid heredoc
> ... separator?
Any word is.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 14:11:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 52496 <at> debbugs.gnu.org (full text, mbox):
Andreas Schwab <schwab <at> linux-m68k.org> writes:
> On Dez 19 2021, Lars Ingebrigtsen wrote:
>
>> Right. I haven't real the shell documentation -- is "@" a valid heredoc
>> ... separator?
>
> Any word is.
But is @ word constituent?
It's not in sh-mode's word definition, anyway. The following tweak
fixes this particular problem, but I have no idea whether it was what
what originally reported.
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index c6b6f83471..01bebe4a23 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -867,7 +867,7 @@ sh-here-doc-syntax
"\\(?:\\(?:.*[^\\\n]\\)?\\(?:\\\\\\\\\\)*\\\\\n\\)*.*")
(defconst sh-here-doc-open-re
- (concat "[^<]<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)"
+ (concat "[^<]<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._@]\\)+\\)"
sh-escaped-line-re "\\(\n\\)")))
(defun sh--inside-noncommand-expression (pos)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) patch.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sun, 19 Dec 2021 14:11:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 14:48:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 52496 <at> debbugs.gnu.org (full text, mbox):
On Dez 19 2021, Lars Ingebrigtsen wrote:
> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
>> On Dez 19 2021, Lars Ingebrigtsen wrote:
>>
>>> Right. I haven't real the shell documentation -- is "@" a valid heredoc
>>> ... separator?
>>
>> Any word is.
>
> But is @ word constituent?
A shell word can be almost anything.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 15:48:02 GMT)
Full text and
rfc822 format available.
Message #30 received at 52496 <at> debbugs.gnu.org (full text, mbox):
Andreas Schwab <schwab <at> linux-m68k.org> writes:
> On Dez 19 2021, Lars Ingebrigtsen wrote:
>
>> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>>
>>> On Dez 19 2021, Lars Ingebrigtsen wrote:
>>>
>>>> Right. I haven't real the shell documentation -- is "@" a valid heredoc
>>>> ... separator?
>>>
>>> Any word is.
>>
>> But is @ word constituent?
>
> A shell word can be almost anything.
Relevant part of (bash) Redirections:
> The format of here-documents is:
> [N]<<[-]WORD
> HERE-DOCUMENT
> DELIMITER
>
> No parameter and variable expansion, command substitution, arithmetic
> expansion, or filename expansion is performed on WORD. If any part of
> WORD is quoted, the DELIMITER is the result of quote removal on WORD,
And (bash) Definitions:
> 'word'
> A sequence of characters treated as a unit by the shell. Words may
> not include unquoted 'metacharacters'.
Preceded by:
> 'metacharacter'
> A character that, when unquoted, separates words. A metacharacter
> is a 'space', 'tab', 'newline', or one of the following characters:
> '|', '&', ';', '(', ')', '<', or '>'.
(AFAICT the same goes for POSIX sh[1])
So IIUC for here-documents anything is fair game except (1)
{single,double,back} quotes (2) metacharacters (3) backslashes and
comment openers (#); all of which can still be used if quoted or escaped
*on the opening line only*.
[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Sun, 19 Dec 2021 19:43:02 GMT)
Full text and
rfc822 format available.
Message #33 received at 52496 <at> debbugs.gnu.org (full text, mbox):
Yilkal Argaw <yilkalargawworkneh <at> gmail.com> writes:
> Yes it is the heredoc part. I have tried emacs 27, 28 and 29(i.e. the
> master) and it all behaves the same.
Right. So the question is whether we should just continue to add
characters to that regexp (safe solution) or whether to try to amend the
shell-script-mode concept of a "word", which I think is likely to break
stuff, but would be more correct... probably...
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Tue, 21 Dec 2021 04:10:02 GMT)
Full text and
rfc822 format available.
Message #36 received at 52496 <at> debbugs.gnu.org (full text, mbox):
Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
> So IIUC for here-documents anything is fair game except (1)
> {single,double,back} quotes (2) metacharacters (3) backslashes and
> comment openers (#); all of which can still be used if quoted or escaped
> *on the opening line only*.
Thanks.
As far as I can see, sh-mode doesn't really try too hard to be correct
here -- it accepts word constituents, but then adds back -/~._ which it
has defined as punctuation in `sh-mode-syntax-table'. So perhaps we
should just continue doing that and add @, too, even though that's not
very satisfactory.
So I've now done that in Emacs 29.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#52496
; Package
emacs
.
(Tue, 21 Dec 2021 04:22:02 GMT)
Full text and
rfc822 format available.
Message #39 received at 52496 <at> debbugs.gnu.org (full text, mbox):
Yes, I agree. I think this is enough for now until a refactor becomes
necessary.
On Mon, Dec 20, 2021 at 12:46 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>
> Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
>
> > So IIUC for here-documents anything is fair game except (1)
> > {single,double,back} quotes (2) metacharacters (3) backslashes and
> > comment openers (#); all of which can still be used if quoted or escaped
> > *on the opening line only*.
>
> Thanks.
>
> As far as I can see, sh-mode doesn't really try too hard to be correct
> here -- it accepts word constituents, but then adds back -/~._ which it
> has defined as punctuation in `sh-mode-syntax-table'. So perhaps we
> should just continue doing that and add @, too, even though that's not
> very satisfactory.
>
> So I've now done that in Emacs 29.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 29.1, send any further explanations to
52496 <at> debbugs.gnu.org and Yilkal Argaw <yilkalargawworkneh <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Tue, 21 Dec 2021 10:16:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 18 Jan 2022 12:24:11 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 245 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.