summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Aranda <maurooaranda@gmail.com>2022-09-19 20:36:53 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-09-19 20:36:53 +0200
commit0275b3a63168f66f3d1a5e8ac96200533519aa27 (patch)
tree37586b8a6b5b233c09ef50b63461ddf6ee1ebe89
parent60102016e416e5c19fa5945aeb80693dac7ff2e6 (diff)
downloademacs-0275b3a63168f66f3d1a5e8ac96200533519aa27.tar.gz
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.
-rw-r--r--lisp/progmodes/perl-mode.el1
-rw-r--r--test/lisp/progmodes/cperl-mode-tests.el12
2 files changed, 13 insertions, 0 deletions
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 70cb4605683..bd8f4ecd1c0 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 db3feec93ab..66039d6fc7f 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