unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38658: perl-mode: EOF in same color as here doc text
@ 2019-12-18 13:39 積丹尼 Dan Jacobson
  2020-08-06 10:31 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-12-18 13:39 UTC (permalink / raw)
  To: 38658

$ nl e.pl
     1  print <<EOF;
     2  bla
     3  EOF
$ emacs e.pl

Why is line 1 in color A, and lines 2 and 3 in color B?
How about instead lines 1 and 3 in color A, and line 2 in color B?
emacs-version "26.3"





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#38658: perl-mode: EOF in same color as here doc text
  2019-12-18 13:39 bug#38658: perl-mode: EOF in same color as here doc text 積丹尼 Dan Jacobson
@ 2020-08-06 10:31 ` Lars Ingebrigtsen
  2020-08-06 14:39   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-06 10:31 UTC (permalink / raw)
  To: 積丹尼 Dan Jacobson; +Cc: 38658, Stefan Monnier

積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:

> $ nl e.pl
>      1  print <<EOF;
>      2  bla
>      3  EOF
> $ emacs e.pl
>
> Why is line 1 in color A, and lines 2 and 3 in color B?
> How about instead lines 1 and 3 in color A, and line 2 in color B?

This is apparently due to the following code:

(defun perl-syntax-propertize-special-constructs (limit)
[...]
      ;; A Here document.
      (let ((names (cdr (get-text-property (nth 8 state) 'syntax-table))))
        (when (cdr names)
          (setq names (reverse names))
          ;; Multiple heredocs on a single line, we have to search from the
          ;; beginning, since we don't know which names might be
          ;; before point.
          (goto-char (nth 8 state)))
        (while (and names
                    (re-search-forward
                     (pcase-let ((`(,name . ,indented) (pop names)))
                       (concat "^" (if indented "[ \t]*")
                               (regexp-quote name) "\n"))
                     limit 'move))
          (unless names
            (put-text-property (1- (point)) (point) 'syntax-table
                               (string-to-syntax "> c"))))))

We apparently want to put that syntax on at the end of the heredoc, but
stop fontifying at the start of the final EOF.  I poked around a bit in
the code to see whether I could make it do that, and...  I can't.

So I'm Cc-ing Stefan, who wrote this.  :-)

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#38658: perl-mode: EOF in same color as here doc text
  2020-08-06 10:31 ` Lars Ingebrigtsen
@ 2020-08-06 14:39   ` Stefan Monnier
  2020-08-07  6:49     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2020-08-06 14:39 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38658, 積丹尼 Dan Jacobson

First, I'll note that all the rest of font-lock highlights the comment
and string delimiters the same as the comment and string contents,
except for the `font-lock-comment-delimiter-face`, so you might like to
check how `font-lock-comment-delimiter-face` is done.

> We apparently want to put that syntax on at the end of the heredoc, but
> stop fontifying at the start of the final EOF.

Rather than "not fontify" the delimiter, I think it'll be much easier to
add extra fontification to it.


        Stefan






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#38658: perl-mode: EOF in same color as here doc text
  2020-08-06 14:39   ` Stefan Monnier
@ 2020-08-07  6:49     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-07  6:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 38658, 積丹尼 Dan Jacobson

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> First, I'll note that all the rest of font-lock highlights the comment
> and string delimiters the same as the comment and string contents,
> except for the `font-lock-comment-delimiter-face`, so you might like to
> check how `font-lock-comment-delimiter-face` is done.

Hm, right...

I just noticed that heredocs in .sh files are fontified identically to
in Perl-mode, by the way.

>> We apparently want to put that syntax on at the end of the heredoc, but
>> stop fontifying at the start of the final EOF.
>
> Rather than "not fontify" the delimiter, I think it'll be much easier to
> add extra fontification to it.

Right.

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-07  6:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 13:39 bug#38658: perl-mode: EOF in same color as here doc text 積丹尼 Dan Jacobson
2020-08-06 10:31 ` Lars Ingebrigtsen
2020-08-06 14:39   ` Stefan Monnier
2020-08-07  6:49     ` 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).