From: Mauro Aranda Date: Thu, 20 Oct 2022 10:34:38 +0000 (-0300) Subject: Improve HERE document detection in perl-mode X-Git-Tag: emacs-29.0.90~1616^2~527 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7ee5b0f85f32dd6fd874a12a033798ac56ecbacc;p=emacs.git 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. --- diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 7b7a2cdf019..c5d5d703fc9 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -215,11 +215,16 @@ (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 @@ "<<\\(~\\)?[ \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 <