]> git.eshelyaron.com Git - emacs.git/commitdiff
perl-mode: / is a regexp match if there's nothing before it
authorMauro Aranda <maurooaranda@gmail.com>
Mon, 19 Sep 2022 18:36:53 +0000 (20:36 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 19 Sep 2022 18:36:53 +0000 (20:36 +0200)
* 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
test/lisp/progmodes/cperl-mode-tests.el

index 70cb46056836505a6241314a8743c42209dd11e1..bd8f4ecd1c0d3ac07b03760554f46bc591213a0c 100644 (file)
                                       (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.
index db3feec93ab7ed5d8216692f8631d674f330478e..66039d6fc7f531fd64374cdd3d247ed1e1b5b2da 100644 (file)
@@ -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