From bbcbb2acdc44dbd219bd989469c1d41ddfe024df Mon Sep 17 00:00:00 2001 From: Mauro Aranda Date: Tue, 18 Oct 2022 19:49:09 -0300 Subject: [PATCH] Improve HERE document detection in perl-mode * lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): Detect indented HERE documents when using a bare identifier. (perl--syntax-exp-intro-keywords): Recognize HERE documents that come after die, warn and eval. (perl--syntax-exp-intro-regexp): Identify HERE documents when printing to a filehandle with printf? and when they appear after a fat comma. * test/lisp/progmodes/cperl-mode-resources/here-docs.pl: Add more tests. --- lisp/progmodes/perl-mode.el | 9 ++- .../cperl-mode-resources/here-docs.pl | 66 +++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 7b7a2cdf01..c5d5d703fc 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -215,11 +215,16 @@ perl-quote-like-pairs (eval-and-compile (defconst perl--syntax-exp-intro-keywords '("split" "if" "unless" "until" "while" "print" "printf" - "grep" "map" "not" "or" "and" "for" "foreach" "return")) + "grep" "map" "not" "or" "and" "for" "foreach" "return" "die" + "warn" "eval")) (defconst perl--syntax-exp-intro-regexp (concat "\\(?:\\(?:^\\|[^$@&%[:word:]]\\)" (regexp-opt perl--syntax-exp-intro-keywords) + ;; A HERE document as an argument to printf? + ;; when printing to a filehandle. + "\\|printf?[ \t]*$?[_[:alpha:]][_[:alnum:]]*" + "\\|=>" "\\|[?:.,;|&*=!~({[]" "\\|[^-+][-+]" ;Bug#42168: `+' is intro but `++' isn't! "\\|\\(^\\)\\)[ \t\n]*"))) @@ -335,7 +340,7 @@ perl-syntax-propertize-function "<<\\(~\\)?[ \t]*\\('[^'\n]*'\\|\"[^\"\n]*\"\\|\\\\[[:alpha:]][[:alnum:]]*\\)" ;; The < <<~HERE +look-here +HERE + ); + +$noindent = "New statement in this line"; + +=head2 Test case 10 + +A HERE document as an argument to die. + +=cut + +1 or die <