cperl-mode.el: Optionally treat trailing text as comment
* lisp/progmodes/cperl-mode.el (cperl-fontify-trailer): New customization variable. With a value of 'comment, cperl-mode treats trailing text after after __END__ and __DATA__ as comment, like perl-mode does (Bug#66161). (cperl-find-pods-heres): Treat trailing text after __END__ and __DATA__ according to the customization variable `cperl-fontify-trailer'. * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-66161): New test, verifying the changed behavior if the custom variable is set to 'comment. * test/lisp/progmodes/cperl-mode-resources/cperl-bug-66161.pl: New resource file, source code from the corresponding bug report.
This commit is contained in:
parent
baf778c7ca
commit
3a1fc81628
3 changed files with 42 additions and 2 deletions
|
@ -550,6 +550,18 @@ This way enabling/disabling of menu items is more correct."
|
|||
:version "29.1")
|
||||
;;;###autoload(put 'cperl-file-style 'safe-local-variable 'stringp)
|
||||
|
||||
(defcustom cperl-fontify-trailer
|
||||
'perl-code
|
||||
"How to fontify text after an \"__END__\" or \"__DATA__\" token.
|
||||
If \"perl-code\", treat as Perl code for fontification, and
|
||||
examine for imenu entries. Use this setting if you have trailing
|
||||
POD documentation, or for modules which use AutoLoad or
|
||||
AutoSplit. If \"comment\", treat as comment, and do not look for
|
||||
imenu entries."
|
||||
:type '(choice (const perl-code)
|
||||
(const comment))
|
||||
:group 'cperl-faces)
|
||||
|
||||
(defcustom cperl-ps-print-face-properties
|
||||
'((font-lock-keyword-face nil nil bold shadow)
|
||||
(font-lock-variable-name-face nil nil bold)
|
||||
|
@ -4913,8 +4925,9 @@ recursive calls in starting lines of here-documents."
|
|||
;; 1+6+2+1+1+6+1+1=19 extra () before this:
|
||||
;; "__\\(END\\|DATA\\)__"
|
||||
((match-beginning 20) ; __END__, __DATA__
|
||||
(setq bb (match-end 0))
|
||||
;; (put-text-property b (1+ bb) 'syntax-type 'pod) ; Cheat
|
||||
(if (eq cperl-fontify-trailer 'perl-code)
|
||||
(setq bb (match-end 0))
|
||||
(setq bb (point-max)))
|
||||
(cperl-commentify b bb nil)
|
||||
(setq end t))
|
||||
;; "\\\\\\(['`\"($]\\)"
|
||||
|
|
13
test/lisp/progmodes/cperl-mode-resources/cperl-bug-66161.pl
Normal file
13
test/lisp/progmodes/cperl-mode-resources/cperl-bug-66161.pl
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
print("Hello World\n");
|
||||
|
||||
__END__
|
||||
|
||||
TODO:
|
||||
What's happening?
|
||||
|
||||
It's all messed up.
|
|
@ -1403,6 +1403,20 @@ beginning with `cperl-test-unicode`."
|
|||
(cdr (assoc (match-string-no-properties 1)
|
||||
faces)))))))))
|
||||
|
||||
(ert-deftest cperl-test-bug-66161 ()
|
||||
"Verify that text after \"__END__\" is fontified as comment.
|
||||
For `cperl-mode', this needs the custom variable
|
||||
`cperl-fontify-trailer' to be set to `comment'. Per default,
|
||||
cperl-mode fontifies text after the delimiter as Perl code."
|
||||
(with-temp-buffer
|
||||
(insert-file-contents (ert-resource-file "cperl-bug-66161.pl"))
|
||||
(setq cperl-fontify-trailer 'comment)
|
||||
(funcall cperl-test-mode)
|
||||
(font-lock-ensure)
|
||||
(search-forward "TODO") ; leaves point before the colon
|
||||
(should (equal (get-text-property (point) 'face)
|
||||
font-lock-comment-face))))
|
||||
|
||||
(ert-deftest test-indentation ()
|
||||
(ert-test-erts-file (ert-resource-file "cperl-indents.erts")))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue