* How to use Generic String Delimiter ("|")
@ 2021-11-07 19:51 Reza Nikoopour
2021-11-07 20:57 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Reza Nikoopour @ 2021-11-07 19:51 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 629 bytes --]
Hello All,
I'm trying to highlight a multiline construct. It uses the here doc syntax
<<SYMBOL
whatever
text
SYMBOL
Do I need two delimiters as follows:
<<SYMBOL(1)
whatever
text(2)
SYMBOL
Or do I use one delimiter that spans the entire string body?
<<SYMBOL(delimiter start)
whatever
text(delimiter end)
SYMBOL
In my experiments using the single delimiter I've failed at getting the
highlighting to work properly so I think I'm going down the wrong path.
I'm trying to avoid how sh-mode and the current implementation
of terraform-mode highlight the entirety of the closing SYMBOL.
[image: image.png]
Cheers,
Reza
[-- Attachment #1.2: Type: text/html, Size: 1235 bytes --]
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 26180 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to use Generic String Delimiter ("|")
2021-11-07 19:51 How to use Generic String Delimiter ("|") Reza Nikoopour
@ 2021-11-07 20:57 ` Stefan Monnier
2021-11-08 2:42 ` Reza Nikoopour
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2021-11-07 20:57 UTC (permalink / raw)
To: Reza Nikoopour; +Cc: emacs-devel
> Hello All,
>
> I'm trying to highlight a multiline construct. It uses the here doc syntax
>
> <<SYMBOL
> whatever
> text
> SYMBOL
>
>
> Do I need two delimiters as follows:
>
>
> <<SYMBOL(1)
> whatever
> text(2)
> SYMBOL
Yes
> Or do I use one delimiter that spans the entire string body?
>
> <<SYMBOL(delimiter start)
> whatever
> text(delimiter end)
> SYMBOL
A string delimiter only occupies a single character. When you apply
a text property to a range of text, it applies that property to every
char in the text. So with your "delimiter that spans the entire string
body", Emacs interprets it as N consecutive string delimiters.
So depending on whether N is odd or even the rest of the text will be
highlighted with `font-lock-string-face` ;-)
> I'm trying to avoid how sh-mode and the current implementation
> of terraform-mode highlight the entirety of the closing SYMBOL.
> [image: image.png]
I recommend you consider the highlighting itself separately from the
placement of the string delimiters (the placement of the delimiters does
impact the default highlighting, obviously, but you can override that in
the `font-lock-keywords` rules).
The placement of the delimiters should be chosen based on the needs of
things like navigation (e.g. `C-M-f`) and indentation, or maybe to take
care of corner cases like empty here docs:
<<SYMBOL
SYMBOL
-- Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-08 2:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-07 19:51 How to use Generic String Delimiter ("|") Reza Nikoopour
2021-11-07 20:57 ` Stefan Monnier
2021-11-08 2:42 ` Reza Nikoopour
2021-11-08 2:54 ` Reza Nikoopour
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.