all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#45255: cperl-mode doesn't recognise the double diamond operator
@ 2020-12-15 14:20 E. Choroba
  2020-12-15 17:55 ` bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc Harald Jörg
  0 siblings, 1 reply; 3+ messages in thread
From: E. Choroba @ 2020-12-15 14:20 UTC (permalink / raw)
  To: 45255

Perl 5.22 added the new form of the diamond operator <<>> (which uses the
three argument version of open under the hood).

Unfortunately, cperl-mode doesn't recognise it and treats it as a HERE-doc
start:

while (<<>>) {
This is displayed in the font-lock-string-face.
The here document ends with an empty line.
Pressing Tab doesn't indent the code.

Ch.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc
  2020-12-15 14:20 bug#45255: cperl-mode doesn't recognise the double diamond operator E. Choroba
@ 2020-12-15 17:55 ` Harald Jörg
  2020-12-16 15:39   ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: Harald Jörg @ 2020-12-15 17:55 UTC (permalink / raw)
  To: 45255

[-- Attachment #1: Type: text/plain, Size: 135 bytes --]

The patch includes "<<>>" in the list of checks for stuff which does not
start a here-doc after "<<", and adds a test.
-- 
Cheers,
haj

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Don't treat <<>> as here-doc --]
[-- Type: text/x-diff, Size: 2174 bytes --]

From 80c7ba0cb9ffc71b5d3ebd389f668d1c8fd86462 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20J=C3=B6rg?= <haj@posteo.de>
Date: Tue, 15 Dec 2020 18:53:03 +0100
Subject: [PATCH] ; 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 ae839a6622..a9edb42b15 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -3694,13 +3694,14 @@ cperl-find-pods-heres
 	       ;;    ;; "\\([^= \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 896160bb88..cb2d067a61 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -312,4 +312,12 @@ cperl-test-bug-42168
   (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
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc
  2020-12-15 17:55 ` bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc Harald Jörg
@ 2020-12-16 15:39   ` Stefan Kangas
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Kangas @ 2020-12-16 15:39 UTC (permalink / raw)
  To: Harald Jörg; +Cc: 45255

tags 45255 fixed
close 45255 28.1
thanks

Harald Jörg <haj@posteo.de> writes:

> The patch includes "<<>>" in the list of checks for stuff which does not
> start a here-doc after "<<", and adds a test.

LGTM, so I pushed it to master as commit 32d85e3079.  Thanks!





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-16 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-15 14:20 bug#45255: cperl-mode doesn't recognise the double diamond operator E. Choroba
2020-12-15 17:55 ` bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc Harald Jörg
2020-12-16 15:39   ` Stefan Kangas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.