diff options
author | Alan Mackenzie <acm@muc.de> | 2016-07-12 13:16:02 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2016-07-12 13:16:02 +0000 |
commit | a1db933c5b68165879ada5ddf3c2585d1e7e893d (patch) | |
tree | 09821d2158098da3b98100feaea445ed95a2fbfd /lisp/progmodes/cc-fonts.el | |
parent | 2f67f8a145af8f185f644b1d094a03895a124ef1 (diff) | |
download | emacs-a1db933c5b68165879ada5ddf3c2585d1e7e893d.tar.gz emacs-a1db933c5b68165879ada5ddf3c2585d1e7e893d.tar.bz2 emacs-a1db933c5b68165879ada5ddf3c2585d1e7e893d.zip |
Amend CC Mode to handle big C++ raw strings correctly.
Problems were caused by such a string spanning jit-lock chunks, and by a flaw
in the +-500 bytes boundaries imposed for macros.
* lisp/progmodes/cc-mode.el (c-extend-region-for-CPP): Check the +-500 byte
macro boundaries here.
(c-extend-font-lock-region-for-macros): Remove the check on the +-500 byte
lower boundary. Fix the check on the upper boundary.
* lisp/progmodes/cc-fonts.el (c-font-lock-raw-strings): Handle the starting
point already being within a raw string.
* lisp/progmodes/cc-engine.el (c-raw-string-pos)
(c-depropertize-raw-strings-in-region, c-after-change-re-mark-raw-strings):
Modify regexp element "\\{,16\\}" to "\\{0,16\\}" for greater compatibility
with other Emacsen.
Diffstat (limited to 'lisp/progmodes/cc-fonts.el')
-rw-r--r-- | lisp/progmodes/cc-fonts.el | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index dfc2c061217..b45686c81b0 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -1542,33 +1542,45 @@ casts and declarations are fontified. Used on level 2 and higher." ;; font-lock-keyword-face. It always returns NIL to inhibit this and ;; prevent a repeat invocation. See elisp/lispref page "Search-based ;; Fontification". - (while (search-forward-regexp - "R\\(\"\\)\\([^ ()\\\n\r\t]\\{,16\\}\\)(" limit t) - (when - (or (and (eobp) - (eq (c-get-char-property (1- (point)) 'face) - 'font-lock-warning-face)) - (eq (c-get-char-property (point) 'face) 'font-lock-string-face) - (and (equal (c-get-char-property (match-end 2) 'syntax-table) '(1)) - (equal (c-get-char-property (match-beginning 1) 'syntax-table) - '(1)))) - (let ((paren-prop (c-get-char-property (1- (point)) 'syntax-table))) - (if paren-prop - (progn - (c-put-font-lock-face (match-beginning 0) (match-end 0) - 'font-lock-warning-face) - (when - (and - (equal paren-prop '(15)) - (not (c-search-forward-char-property 'syntax-table '(15) limit))) - (goto-char limit))) - (c-put-font-lock-face (match-beginning 1) (match-end 2) 'default) - (when (search-forward-regexp - (concat ")\\(" (regexp-quote (match-string-no-properties 2)) - "\\)\"") - limit t) - (c-put-font-lock-face (match-beginning 1) (point) - 'default)))))) + (let* ((state (c-state-semi-pp-to-literal (point))) + (string-start (and (eq (cadr state) 'string) + (car (cddr state)))) + (raw-id (and string-start + (save-excursion + (goto-char string-start) + (and (eq (char-before) ?R) + (looking-at "\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(") + (match-string-no-properties 1)))))) + (while (< (point) limit) + (if raw-id + (progn + (if (search-forward-regexp (concat ")\\(" (regexp-quote raw-id) "\\)\"") + limit 'limit) + (c-put-font-lock-face (match-beginning 1) (point) 'default)) + (setq raw-id nil)) + + (when (search-forward-regexp + "R\\(\"\\)\\([^ ()\\\n\r\t]\\{0,16\\}\\)(" limit 'limit) + (when + (or (and (eobp) + (eq (c-get-char-property (1- (point)) 'face) + 'font-lock-warning-face)) + (eq (c-get-char-property (point) 'face) 'font-lock-string-face) + (and (equal (c-get-char-property (match-end 2) 'syntax-table) '(1)) + (equal (c-get-char-property (match-beginning 1) 'syntax-table) + '(1)))) + (let ((paren-prop (c-get-char-property (1- (point)) 'syntax-table))) + (if paren-prop + (progn + (c-put-font-lock-face (match-beginning 0) (match-end 0) + 'font-lock-warning-face) + (when + (and + (equal paren-prop '(15)) + (not (c-search-forward-char-property 'syntax-table '(15) limit))) + (goto-char limit))) + (c-put-font-lock-face (match-beginning 1) (match-end 2) 'default) + (setq raw-id (match-string-no-properties 2))))))))) nil) (c-lang-defconst c-simple-decl-matchers |