diff options
author | Alan Mackenzie <acm@muc.de> | 2019-04-25 18:00:15 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2019-04-25 18:00:15 +0000 |
commit | 0c2d921a75375e5667224bfd92b28be3b77977b3 (patch) | |
tree | 6d897212bd8844da18d2b2937fb6cbc5d18550e9 /lisp/progmodes/cc-defs.el | |
parent | 6d8e0fc5aa7673540486af9ecbfc0a3e23c305cf (diff) | |
download | emacs-0c2d921a75375e5667224bfd92b28be3b77977b3.tar.gz emacs-0c2d921a75375e5667224bfd92b28be3b77977b3.tar.bz2 emacs-0c2d921a75375e5667224bfd92b28be3b77977b3.zip |
Restore fontification of delimiters of multiline CC Mode strings.
E.g., on typing the closing delimiter of a string continued onto a second
line, the opening delimiter retained its font-lock-warning-face.
* lisp/progmodes/cc-defs.el (c-c++-raw-string-opener-re)
(c-c++-raw-string-opener-1-re): New constants.
(c-sub-at-c++-raw-string-opener, c-at-c++-raw-string-opener): New macros.
* lisp/progmodes/cc-engine.el (c-raw-string-pos)
(c-depropertize-raw-strings-in-region, c-after-change-unmark-raw-strings):
Replace uses of open-coded raw string regexps by the new constants and macros
in cc-defs.el.
* lisp/progmodes/cc-fonts.el (c-font-lock-raw-strings): Ditto
* lisp/progmodes/cc-mode.el (c-before-change-check-unbalanced-strings): Set
c-new-BEG to the beginning of the string when we encounter its closing ".
When not in a raw string, but in a string, clear syntax-table properties from
its delimiters and set c-new-BEG/END to its limits.
(c-after-change-mark-abnormal-strings): When applying syntax-table properties
to string delimiters, also set c-new-BEG/END to ensure subsequent
fontification.
Diffstat (limited to 'lisp/progmodes/cc-defs.el')
-rw-r--r-- | lisp/progmodes/cc-defs.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 87ddf3ac1e2..cd4ed6b352e 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -503,6 +503,31 @@ to it is returned. This function does not modify the point or the mark." ;; Emacs <22 + XEmacs '(default-value 'sentence-end))) +(defconst c-c++-raw-string-opener-re "R\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(") +;; Matches a C++ raw string opener. Submatch 1 is its identifier. + +(defconst c-c++-raw-string-opener-1-re "\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(") +;; Matches a C++ raw string opener starting after the initial R. + +(defmacro c-sub-at-c++-raw-string-opener () + `(save-excursion + (and + (if (eq (char-after) ?R) + (progn (forward-char) t) + (eq (char-before) ?R)) + (looking-at c-c++-raw-string-opener-1-re)))) + +(defmacro c-at-c++-raw-string-opener (&optional pos) + ;; Return non-nil if POS (default point) is either at the start of a C++ raw + ;; string opener, or after the introductory R of one. The match data is + ;; overwritten. On success the opener's identifier will be (match-string + ;; 1). Text properties on any characters are ignored. + (if pos + `(save-excursion + (goto-char ,pos) + (c-sub-at-c++-raw-string-opener)) + `(c-sub-at-c++-raw-string-opener))) + ;; The following is essentially `save-buffer-state' from lazy-lock.el. ;; It ought to be a standard macro. (defmacro c-save-buffer-state (varlist &rest body) |