diff options
author | Alan Mackenzie <acm@muc.de> | 2019-04-26 01:15:00 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2019-04-26 01:15:00 +0000 |
commit | a0bb2588b8fc79ac8e040fd7a8d8d3d0e158ffa0 (patch) | |
tree | 955c186c6fa37605887f8f63e661e31785aefedb /lisp | |
parent | 80822917736edbab77969c4a18dfb8dd20fe3a88 (diff) | |
download | emacs-a0bb2588b8fc79ac8e040fd7a8d8d3d0e158ffa0.tar.gz |
Fix the formatting of '\' (including apostrophes) in CC Mode.
In particular, the second apostrophe must also get font-lock-warning-face.
* lisp/progmodes/cc-mode.el (c-parse-quotes-before-change)
(c-parse-quotes-after-change): Add cond arms to recognize and handle the
anomalous construct '\'. Correct the handling of c-new-BEG in
c-parse-quotes-before-change.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/progmodes/cc-mode.el | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 1a360048752..ea865e0b0fb 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -1529,9 +1529,12 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") (goto-char (match-end 0)) (if (> (match-end 0) c-new-BEG) (setq c-new-BEG (1- (match-beginning 0))))) + ((looking-at "\\\\'") + (setq c-new-BEG (min c-new-BEG (1- (point)))) + (goto-char (match-end 0))) ((save-excursion (not (search-forward "'" c-new-BEG t))) - (setq c-new-BEG (1- (point)))) + (setq c-new-BEG (min c-new-BEG (1- (point))))) (t nil))) (goto-char c-new-END) @@ -1555,6 +1558,9 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") (goto-char (match-end 0)) (if (> (match-end 0) c-new-END) (setq c-new-END (match-end 0)))) + ((looking-at "\\\\'") + (goto-char (match-end 0)) + (setq c-new-END (max c-new-END (point)))) ((equal (c-get-char-property (1- (point)) 'syntax-table) '(1)) (when (c-search-forward-char-property-with-value-on-char 'syntax-table '(1) ?\' (c-point 'eoll)) @@ -1624,6 +1630,12 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") "\\([^\\']\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][0-9a-fA-F]+\\|.\\)\ \\)'") ; balanced quoted expression. (goto-char (match-end 0))) + ((looking-at "\\\\'") ; Anomalous construct. + (c-invalidate-state-cache (1- (point))) + (c-truncate-semi-nonlit-pos-cache (1- (point))) + (c-put-char-properties-on-char (1- (point)) (+ (point) 2) + 'syntax-table '(1) ?') + (goto-char (match-end 0))) (t (c-invalidate-state-cache (1- (point))) (c-truncate-semi-nonlit-pos-cache (1- (point))) |