emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 32d85e3: CPerl-mode: don't treat <<>> as starting a here-doc


From: Stefan Kangas
Subject: master 32d85e3: CPerl-mode: don't treat <<>> as starting a here-doc
Date: Wed, 16 Dec 2020 10:39:46 -0500 (EST)

branch: master
commit 32d85e3079a8cdfb0f083b766f2fafd361ee6e00
Author: Harald Jörg <haj@posteo.de>
Commit: Stefan Kangas <stefan@marxist.se>

    CPerl-mode: don't treat <<>> as starting a here-doc
    
    * lisp/progmodes/cperl-mode.el (cperl-find-pods-heres): Detect
    the "<<>>" operator (Bug#42455).
    
    * test/lisp/progmodes/cperl-mode-tests.el
    (cperl-test-bug-45255): Verify that <<>> does not start a
    HERE-doc.
---
 lisp/progmodes/cperl-mode.el            | 3 ++-
 test/lisp/progmodes/cperl-mode-tests.el | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 5cf40fe..15987a3 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -3694,13 +3694,14 @@ the sections using `cperl-pod-head-face', 
`cperl-pod-face',
               ;;    ;; "\\([^= \t0-9$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)" ; 6 + 1
               ;;    "\\(\\)"           ; To preserve count of pars :-( 6 + 1
               ;;  "\\)"
-              ((match-beginning 3)     ; 2 + 1
+              ((match-beginning 3)     ; 2 + 1: found "<<", detect its type
                (setq b (point)
                      tb (match-beginning 0)
                      c (and            ; not HERE-DOC
                         (match-beginning 6)
                         (save-match-data
                           (or (looking-at "[ \t]*(") ; << function_call()
+                              (looking-at ">>")      ; <<>> operator
                               (save-excursion ; 1 << func_name, or $foo << 10
                                 (condition-case nil
                                     (progn
diff --git a/test/lisp/progmodes/cperl-mode-tests.el 
b/test/lisp/progmodes/cperl-mode-tests.el
index 896160bb..cb2d067 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -312,4 +312,12 @@ have a face property."
   (let ((code "{ $a- / $b } # /"))
     (should (equal (nth 8 (cperl-test-ppss code "/")) 7))))
 
+(ert-deftest cperl-test-bug-45255 ()
+  "Verify that \"<<>>\" is recognized as not starting a HERE-doc."
+  (let ((code (concat "while (<<>>) {\n"
+                      "   ...;\n"
+                      "}\n")))
+    ;; The yadda-yadda operator should not be in a string.
+    (should (equal (nth 8 (cperl-test-ppss code "\\.")) nil))))
+
 ;;; cperl-mode-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]