emacs-diffs
[Top][All Lists]
Advanced

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

master 0275b3a631: perl-mode: / is a regexp match if there's nothing bef


From: Lars Ingebrigtsen
Subject: master 0275b3a631: perl-mode: / is a regexp match if there's nothing before it
Date: Mon, 19 Sep 2022 14:37:26 -0400 (EDT)

branch: master
commit 0275b3a63168f66f3d1a5e8ac96200533519aa27
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    perl-mode: / is a regexp match if there's nothing before it
    
    * lisp/progmodes/perl-mode.el (perl-syntax-propertize-function):
    A "/" that starts the first statement is a regexp match.  (Bug#997)
    * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-997): New
    test.
---
 lisp/progmodes/perl-mode.el             |  1 +
 test/lisp/progmodes/cperl-mode-tests.el | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 70cb460568..bd8f4ecd1c 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -280,6 +280,7 @@
                                       (backward-sexp 1)
                                       (member (buffer-substring (point) end)
                                               
perl--syntax-exp-intro-keywords)))
+                               (bobp)
                                (memq (char-before)
                                      '(?? ?: ?. ?, ?\; ?= ?! ?~ ?\( ?\[))))))
                nil ;; A division sign instead of a regexp-match.
diff --git a/test/lisp/progmodes/cperl-mode-tests.el 
b/test/lisp/progmodes/cperl-mode-tests.el
index db3feec93a..66039d6fc7 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -723,6 +723,18 @@ created by CPerl mode, so skip it for Perl mode."
 
 ;;; Tests for issues reported in the Bug Tracker
 
+(ert-deftest cperl-test-bug-997 ()
+  "Test that we distinguish a regexp match when there's nothing before it."
+  (let ((code "# some comment\n\n/fontify me/;\n"))
+    (with-temp-buffer
+      (funcall cperl-test-mode)
+      (insert code)
+      (font-lock-ensure)
+      (goto-char (point-min))
+      (search-forward "/f")
+      (should (equal (get-text-property (point) 'face)
+                     'font-lock-string-face)))))
+
 (defun cperl-test--run-bug-10483 ()
   "Runs a short program, intended to be under timer scrutiny.
 This function is intended to be used by an Emacs subprocess in



reply via email to

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