From 0275b3a63168f66f3d1a5e8ac96200533519aa27 Mon Sep 17 00:00:00 2001 From: Mauro Aranda Date: Mon, 19 Sep 2022 20:36:53 +0200 Subject: [PATCH] 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 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 -- 2.39.2