diff options
author | Stefan Monnier <[email protected]> | 2008-06-03 07:18:54 +0000 |
---|---|---|
committer | Stefan Monnier <[email protected]> | 2008-06-03 07:18:54 +0000 |
commit | a9bc137f5ec9d474b035afdbd0de9b0a5fe73c5e (patch) | |
tree | 9a716369303cb823a5a785428fee3d351fbec2f1 /lisp | |
parent | acc12ef73e3f7605960b5ba190bf965d4e61eea2 (diff) |
(perl-font-lock-syntactic-keywords): Try to be
yet a bit more clever at distinguishing / from /.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/progmodes/perl-mode.el | 23 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index de57acf56b..a58fc46028 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-06-03 Stefan Monnier <[email protected]> + + * progmodes/perl-mode.el (perl-font-lock-syntactic-keywords): Try to be + yet a bit more clever at distinguishing / from /. + 2008-06-03 Kenichi Handa <[email protected]> * Makefile.in (ELCFILES): Add $(lisp)/language/hanja-util.elc. diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 22d9b488cc..c92ac4252d 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -252,7 +252,7 @@ The expansion is entirely correct because it uses the C preprocessor." ;; <file*glob> (defvar perl-font-lock-syntactic-keywords ;; TODO: here-documents ("<<\\(\\sw\\|['\"]\\)") - '(;; Turn POD into b-style comments + `(;; Turn POD into b-style comments ("^\\(=\\)\\sw" (1 "< b")) ("^=cut[ \t]*\\(\n\\)" (1 "> b")) ;; Catch ${ so that ${var} doesn't screw up indentation. @@ -267,12 +267,27 @@ The expansion is entirely correct because it uses the C preprocessor." ;; Be careful not to match "sub { (...) ... }". ("\\<sub\\(?:[[:space:]]+[^{}[:punct:][:space:]]+\\)?[[:space:]]*(\\([^)]+\\))" 1 '(1)) - ;; Regexp and funny quotes. - ("\\(?:[?:.,;=!~({[]\\|\\(^\\)\\)[ \t\n]*\\(/\\)" + ;; Regexp and funny quotes. Distinguishing a / that starts a regexp + ;; match from the division operator is ...interesting. + ;; Basically, / is a regexp match if it's preceded by an infix operator + ;; (or some similar separator), or by one of the special keywords + ;; corresponding to builtin functions that can take their first arg + ;; without parentheses. Of course, that presume we're looking at the + ;; *opening* slash. We can mis-match the closing ones, because they are + ;; treated separately later in + ;; perl-font-lock-special-syntactic-constructs. + (,(concat "\\(?:\\(?:\\(?:^\\|[^$@&%[:word:]]\\)" + (regexp-opt '("split" "if" "unless" "until" "while" "split" + "grep" "map" "not" "or" "and")) + "\\)\\|[?:.,;=!~({[]\\|\\(^\\)\\)[ \t\n]*\\(/\\)") (2 (if (and (match-end 1) (save-excursion (goto-char (match-end 1)) - (skip-chars-backward " \t\n") + ;; Not 100% correct since we haven't finished setting up + ;; the syntax-table before point, but better than nothing. + (forward-comment (- (point-max))) + (put-text-property (point) (match-end 2) + 'jit-lock-multiline t) (not (memq (char-before) '(?? ?: ?. ?, ?\; ?= ?! ?~ ?\( ?\[))))) nil ;; A division sign instead of a regexp-match. |