GNU bug report logs - #38658
perl-mode: EOF in same color as here doc text

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Wed, 18 Dec 2019 13:43:01 UTC

Severity: minor

Tags: confirmed

Merged with 17980

To reply to this bug, email your comments to 38658 AT debbugs.gnu.org.

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#38658; Package emacs. (Wed, 18 Dec 2019 13:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 18 Dec 2019 13:43:02 GMT) Full text and rfc822 format available.

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

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-gnu-emacs <at> gnu.org
Subject: perl-mode: EOF in same color as here doc text
Date: Wed, 18 Dec 2019 21:39:13 +0800
$ 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"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38658; Package emacs. (Thu, 06 Aug 2020 10:33:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 38658 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#38658: perl-mode: EOF in same color as here doc text
Date: Thu, 06 Aug 2020 12:31:55 +0200
積丹尼 Dan Jacobson <jidanni <at> 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




Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 06 Aug 2020 10:33:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38658; Package emacs. (Thu, 06 Aug 2020 14:40:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 38658 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#38658: perl-mode: EOF in same color as here doc text
Date: Thu, 06 Aug 2020 10:39:00 -0400
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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38658; Package emacs. (Fri, 07 Aug 2020 06:50:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 38658 <at> debbugs.gnu.org,
 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: Re: bug#38658: perl-mode: EOF in same color as here doc text
Date: Fri, 07 Aug 2020 08:49:32 +0200
Stefan Monnier <monnier <at> 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




Forcibly Merged 17980 38658. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 07 Aug 2020 10:13:02 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 310 days ago.

Previous Next


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