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

Full log


View this message in rfc822 format

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: 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




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

Previous Next


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