diff options
author | Alan Mackenzie <acm@muc.de> | 2021-11-13 11:58:26 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2021-11-13 11:58:26 +0000 |
commit | 60a85834202dc4e117d3e5086ab210bcd293d659 (patch) | |
tree | 5f729eb936bde89dc2f07cb7673e516f6a90c085 /lisp/progmodes/cc-fonts.el | |
parent | f32280bfa6342090abaa9f015d4cd70fb81bbfef (diff) | |
download | emacs-60a85834202dc4e117d3e5086ab210bcd293d659.tar.gz emacs-60a85834202dc4e117d3e5086ab210bcd293d659.tar.bz2 emacs-60a85834202dc4e117d3e5086ab210bcd293d659.zip |
C++ Mode: Fix incoorect background fontification of <
Where c-record-found-types gets "bound" to itself, we postpone the calling of
c-fontify-new-type on possible new found types until these are confirmed by
the return from the function tentatively finding these types, for exmaple
c-forward-<>-arglist. We check this "binding" by testing the value of
c-record-found-types.
Correct the background fontification algorithm.
* lisp/progmodes/cc-engine.el (c-record-found-types): Move the definition to
earlier in the file.
(c-add-type-1): Check additionally c-record-found-types is nil before calling
c-fontify-new-found-type.
(c-forward-<>-arglist, c-forward-type): On return from a function which
collects found types in c-record-found-types, call c-fontify-new-found-types
for each such type.
* lisp/progmodes/c-fonts.el (c-force-redisplay): Actually fontify the new
found type.
(c-fontify-new-found-type): Test for font-lock-mode being enabled. Remove the
spurious condition on the `fontified' text property being nil before causing
c-force-redisplay to get called.
Diffstat (limited to 'lisp/progmodes/cc-fonts.el')
-rw-r--r-- | lisp/progmodes/cc-fonts.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 9355409b2af..967464ac14d 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -101,6 +101,7 @@ (cc-bytecomp-defun c-font-lock-objc-method) (cc-bytecomp-defun c-font-lock-invalid-string) (cc-bytecomp-defun c-before-context-fl-expand-region) +(cc-bytecomp-defun c-font-lock-fontify-region) ;; Note that font-lock in XEmacs doesn't expand face names as @@ -2428,6 +2429,7 @@ higher." (defun c-force-redisplay (start end) ;; Force redisplay immediately. This assumes `font-lock-support-mode' is ;; 'jit-lock-mode. Set the variable `c-re-redisplay-timer' to nil. + (save-excursion (c-font-lock-fontify-region start end)) (jit-lock-force-redisplay (copy-marker start) (copy-marker end)) (setq c-re-redisplay-timer nil)) @@ -2436,7 +2438,8 @@ higher." ;; buffer. If TYPE is currently displayed in a window, cause redisplay to ;; happen "instantaneously". These actions are done only when jit-lock-mode ;; is active. - (when (and (boundp 'font-lock-support-mode) + (when (and font-lock-mode + (boundp 'font-lock-support-mode) (eq font-lock-support-mode 'jit-lock-mode)) (c-save-buffer-state ((window-boundaries @@ -2455,7 +2458,6 @@ higher." (dolist (win-boundary window-boundaries) (when (and (< (match-beginning 0) (cdr win-boundary)) (> (match-end 0) (car win-boundary)) - (c-get-char-property (match-beginning 0) 'fontified) (not c-re-redisplay-timer)) (setq c-re-redisplay-timer (run-with-timer 0 nil #'c-force-redisplay |