* bug#52496: syntax highlighting problem on emacs shell-script mode
@ 2021-12-15 0:35 Yilkal Argaw
2021-12-19 12:54 ` Lars Ingebrigtsen
0 siblings, 1 reply; 11+ messages in thread
From: Yilkal Argaw @ 2021-12-15 0:35 UTC (permalink / raw)
To: 52496
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-15 0:35 bug#52496: syntax highlighting problem on emacs shell-script mode Yilkal Argaw
@ 2021-12-19 12:54 ` Lars Ingebrigtsen
2021-12-19 13:30 ` Andreas Schwab
[not found] ` <CAJddU=rbKWaPHBmxAGz-bM4TsziYPOoC5tOJMKpybWOE-GJEPA@mail.gmail.com>
0 siblings, 2 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-19 12:54 UTC (permalink / raw)
To: Yilkal Argaw; +Cc: 52496
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Yilkal Argaw <yilkalargawworkneh@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?
[-- Attachment #2: Type: image/png, Size: 35653 bytes --]
[-- Attachment #3: Type: text/plain, Size: 182 bytes --]
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-19 12:54 ` Lars Ingebrigtsen
@ 2021-12-19 13:30 ` Andreas Schwab
2021-12-19 13:33 ` Lars Ingebrigtsen
[not found] ` <CAJddU=rbKWaPHBmxAGz-bM4TsziYPOoC5tOJMKpybWOE-GJEPA@mail.gmail.com>
1 sibling, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2021-12-19 13:30 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 52496, Yilkal Argaw
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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-19 13:30 ` Andreas Schwab
@ 2021-12-19 13:33 ` Lars Ingebrigtsen
2021-12-19 13:57 ` Andreas Schwab
0 siblings, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-19 13:33 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 52496, Yilkal Argaw
Andreas Schwab <schwab@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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-19 13:33 ` Lars Ingebrigtsen
@ 2021-12-19 13:57 ` Andreas Schwab
2021-12-19 14:10 ` Lars Ingebrigtsen
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2021-12-19 13:57 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 52496, Yilkal Argaw
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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-19 13:57 ` Andreas Schwab
@ 2021-12-19 14:10 ` Lars Ingebrigtsen
2021-12-19 14:47 ` Andreas Schwab
0 siblings, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-19 14:10 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 52496, Yilkal Argaw
Andreas Schwab <schwab@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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-19 14:10 ` Lars Ingebrigtsen
@ 2021-12-19 14:47 ` Andreas Schwab
2021-12-19 15:46 ` Kévin Le Gouguec
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2021-12-19 14:47 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 52496, Yilkal Argaw
On Dez 19 2021, Lars Ingebrigtsen wrote:
> Andreas Schwab <schwab@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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-19 14:47 ` Andreas Schwab
@ 2021-12-19 15:46 ` Kévin Le Gouguec
2021-12-20 9:46 ` Lars Ingebrigtsen
0 siblings, 1 reply; 11+ messages in thread
From: Kévin Le Gouguec @ 2021-12-19 15:46 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 52496, Lars Ingebrigtsen, Yilkal Argaw
Andreas Schwab <schwab@linux-m68k.org> writes:
> On Dez 19 2021, Lars Ingebrigtsen wrote:
>
>> Andreas Schwab <schwab@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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
[not found] ` <CAJddU=rbKWaPHBmxAGz-bM4TsziYPOoC5tOJMKpybWOE-GJEPA@mail.gmail.com>
@ 2021-12-19 19:42 ` Lars Ingebrigtsen
0 siblings, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-19 19:42 UTC (permalink / raw)
To: Yilkal Argaw; +Cc: 52496
Yilkal Argaw <yilkalargawworkneh@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...
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-19 15:46 ` Kévin Le Gouguec
@ 2021-12-20 9:46 ` Lars Ingebrigtsen
2021-12-21 4:20 ` Yilkal Argaw
0 siblings, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-20 9:46 UTC (permalink / raw)
To: Kévin Le Gouguec; +Cc: 52496, Andreas Schwab, Yilkal Argaw
Kévin Le Gouguec <kevin.legouguec@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
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#52496: syntax highlighting problem on emacs shell-script mode
2021-12-20 9:46 ` Lars Ingebrigtsen
@ 2021-12-21 4:20 ` Yilkal Argaw
0 siblings, 0 replies; 11+ messages in thread
From: Yilkal Argaw @ 2021-12-21 4:20 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 52496, Andreas Schwab, Kévin Le Gouguec
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@gnus.org> wrote:
>
> Kévin Le Gouguec <kevin.legouguec@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
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-12-21 4:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-15 0:35 bug#52496: syntax highlighting problem on emacs shell-script mode Yilkal Argaw
2021-12-19 12:54 ` Lars Ingebrigtsen
2021-12-19 13:30 ` Andreas Schwab
2021-12-19 13:33 ` Lars Ingebrigtsen
2021-12-19 13:57 ` Andreas Schwab
2021-12-19 14:10 ` Lars Ingebrigtsen
2021-12-19 14:47 ` Andreas Schwab
2021-12-19 15:46 ` Kévin Le Gouguec
2021-12-20 9:46 ` Lars Ingebrigtsen
2021-12-21 4:20 ` Yilkal Argaw
[not found] ` <CAJddU=rbKWaPHBmxAGz-bM4TsziYPOoC5tOJMKpybWOE-GJEPA@mail.gmail.com>
2021-12-19 19:42 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).