[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7a7847d: * lisp/progmodes/perl-mode.el (perl--syntax-exp-intro-re
From: |
Stefan Monnier |
Subject: |
master 7a7847d: * lisp/progmodes/perl-mode.el (perl--syntax-exp-intro-regexp): Bug#42168 |
Date: |
Fri, 14 Aug 2020 10:58:12 -0400 (EDT) |
branch: master
commit 7a7847d7ad558afb8452ff346a0356c5fc837f6e
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* lisp/progmodes/perl-mode.el (perl--syntax-exp-intro-regexp): Bug#42168
* test/lisp/progmodes/cperl-mode-tests.el: Adjust for `perl-mode`.
(cperl-test-ppss): Rename from `cperl-test-face` and change return value.
(cperl-mode-test-bug-42168): Test the `syntax-ppss` state rather than
the font-lock faces, so it works for both `perl-mode` and `cperl-mode`.
---
lisp/progmodes/perl-mode.el | 4 +++-
test/lisp/progmodes/cperl-mode-tests.el | 25 +++++++++++++------------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index ff0b6a3..127b24c 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -214,7 +214,9 @@
(defconst perl--syntax-exp-intro-regexp
(concat "\\(?:\\(?:^\\|[^$@&%[:word:]]\\)"
(regexp-opt perl--syntax-exp-intro-keywords)
- "\\|[-?:.,;|&+*=!~({[]\\|\\(^\\)\\)[ \t\n]*")))
+ "\\|[?:.,;|&*=!~({[]"
+ "\\|[^-+][-+]" ;Bug#42168: `+' is intro but `++' isn't!
+ "\\|\\(^\\)\\)[ \t\n]*")))
(defun perl-syntax-propertize-function (start end)
(let ((case-fold-search nil))
diff --git a/test/lisp/progmodes/cperl-mode-tests.el
b/test/lisp/progmodes/cperl-mode-tests.el
index f39f1ba..be8b42d 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -16,16 +16,17 @@
;;; Code:
-(defun cperl-test-face (text regexp)
- "Returns the face of the first character matched by REGEXP in TEXT."
+(defvar cperl-test-mode #'cperl-mode)
+
+(defun cperl-test-ppss (text regexp)
+ "Return the `syntax-ppss' of the first character matched by REGEXP in TEXT."
(interactive)
(with-temp-buffer
- (insert text)
- (cperl-mode)
- (font-lock-ensure (point-min) (point-max))
- (goto-char (point-min))
- (re-search-forward regexp)
- (get-text-property (match-beginning 0) 'face)))
+ (insert text)
+ (funcall cperl-test-mode)
+ (goto-char (point-min))
+ (re-search-forward regexp)
+ (syntax-ppss)))
(ert-deftest cperl-mode-test-bug-42168 ()
"Verify that '/' is a division after ++ or --, not a regexp.
@@ -37,14 +38,14 @@ have a face property."
;; The next two Perl expressions have divisions. Perl "punctuation"
;; operators don't get a face.
(let ((code "{ $a++ / $b }"))
- (should (equal (cperl-test-face code "/" ) nil)))
+ (should (equal (nth 8 (cperl-test-ppss code "/")) nil)))
(let ((code "{ $a-- / $b }"))
- (should (equal (cperl-test-face code "/" ) nil)))
+ (should (equal (nth 8 (cperl-test-ppss code "/")) nil)))
;; The next two Perl expressions have regular expressions. The
;; delimiter of a RE is fontified with font-lock-constant-face.
(let ((code "{ $a+ / $b } # /"))
- (should (equal (cperl-test-face code "/" ) font-lock-constant-face)))
+ (should (equal (nth 8 (cperl-test-ppss code "/")) 7)))
(let ((code "{ $a- / $b } # /"))
- (should (equal (cperl-test-face code "/" ) font-lock-constant-face))))
+ (should (equal (nth 8 (cperl-test-ppss code "/")) 7))))
;;; cperl-mode-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 7a7847d: * lisp/progmodes/perl-mode.el (perl--syntax-exp-intro-regexp): Bug#42168,
Stefan Monnier <=