Commit 468517c8 authored by Alan Mackenzie's avatar Alan Mackenzie

CC Mode: Add a workaround for syntax-ppss ignoring syntax-table prop changes

* lisp/progmodes/cc-engine.el (c-truncate-lit-pos-cache): Maintain the new
variable c-syntax-table-hwm after buffer changes.

* lisp/progmodes/cc-mode.el (c-syntax-table-hwm): New variable.
(c-before-change): Set c-syntax-table-hwm to "infinity".
(c-after-change): Call syntax-ppss-flush-cache, just before a font locking is
due to take place.
parent 2d71e684
Pipeline #2012 failed with stage
in 3 seconds
......@@ -155,6 +155,7 @@
(defvar c-doc-line-join-re)
(defvar c-doc-bright-comment-start-re)
(defvar c-doc-line-join-end-ch)
(defvar c-syntax-table-hwm)
;; Make declarations for all the `c-lang-defvar' variables in cc-langs.
......@@ -3003,7 +3004,13 @@ comment at the start of cc-engine.el for more info."
;; higher than that position.
(setq c-lit-pos-cache-limit (min c-lit-pos-cache-limit pos)
c-semi-near-cache-limit (min c-semi-near-cache-limit pos)
c-full-near-cache-limit (min c-full-near-cache-limit pos)))
c-full-near-cache-limit (min c-full-near-cache-limit pos))
(when (fboundp 'syntax-ppss)
;; Also keep track of where we need to truncate `syntax-ppss''s cache to.
;; Actually we shouldn't have to touch this thing (which we do not use),
;; but its design forces us to. Hopefully this will be fixed in a future
;; version of Emacs.
(setq c-syntax-table-hwm (min c-syntax-table-hwm pos))))
;; A system for finding noteworthy parens before the point.
......
......@@ -888,6 +888,12 @@ Note that the style variables are always made local to the buffer."
;;; Change hooks, linking with Font Lock and electric-indent-mode.
(defvar c-syntax-table-hwm most-positive-fixnum)
;; A workaround for `syntax-ppss''s failure to take account of changes in
;; syntax-table text properties. This variable gets set to the lowest
;; position where the syntax-table text property is changed, and that value
;; gets supplied to `syntax-ppss-flush-cache' just before a font locking is
;; due to take place.
(defun c-called-from-text-property-change-p ()
;; Is the primitive which invoked `before-change-functions' or
......@@ -1672,6 +1678,10 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
;; (c-new-BEG c-new-END) will be the region to fontify.
(setq c-new-BEG beg c-new-END end)
(setq c-maybe-stale-found-type nil)
;; A workaround for syntax-ppss's failure to notice syntax-table text
;; property changes.
(when (fboundp 'syntax-ppss)
(setq c-syntax-table-hwm most-positive-fixnum))
(save-restriction
(save-match-data
(widen)
......@@ -1823,7 +1833,11 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
(save-excursion
(mapc (lambda (fn)
(funcall fn beg end old-len))
c-before-font-lock-functions)))))))
c-before-font-lock-functions))))))
;; A workaround for syntax-ppss's failure to notice syntax-table text
;; property changes.
(when (fboundp 'syntax-ppss)
(syntax-ppss-flush-cache c-syntax-table-hwm)))
(defun c-doc-fl-decl-start (pos)
;; If the line containing POS is in a doc comment continued line (as defined
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment