CC Mode: Protect against consecutive calls to before-change-functions ...
without an intervening call to after-change-functions. This would have been a workaround to bug #38691 had the causes of that bug not been removed. * lisp/progmodes/cc-mode.el (c-just-done-before-change): Add an extra value to this variable, 'whole-buffer, this being set by c-before-change as a signal to c-after-change that although c-before-change has run, it has assumed the entire buffer as the change region. (c-before-change, c-after-change): Adapt to the new meaning of the above.
This commit is contained in:
parent
ba7004b2a7
commit
3bce7ec382
1 changed files with 30 additions and 17 deletions
|
@ -1865,10 +1865,18 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
|
|||
;; it/them from the cache. Don't worry about being inside a string
|
||||
;; or a comment - "wrongly" removing a symbol from `c-found-types'
|
||||
;; isn't critical.
|
||||
(unless (or (c-called-from-text-property-change-p)
|
||||
c-just-done-before-change) ; guard against a spurious second
|
||||
; invocation of before-change-functions.
|
||||
(setq c-just-done-before-change t)
|
||||
(unless (c-called-from-text-property-change-p)
|
||||
(save-restriction
|
||||
(widen)
|
||||
(if c-just-done-before-change
|
||||
;; We have two consecutive calls to `before-change-functions' without
|
||||
;; an intervening `after-change-functions'. An example of this is bug
|
||||
;; #38691. To protect CC Mode, assume that the entire buffer has
|
||||
;; changed.
|
||||
(setq beg (point-min)
|
||||
end (point-max)
|
||||
c-just-done-before-change 'whole-buffer)
|
||||
(setq c-just-done-before-change t))
|
||||
;; (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)
|
||||
|
@ -1876,7 +1884,6 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
|
|||
;; property changes.
|
||||
(when (fboundp 'syntax-ppss)
|
||||
(setq c-syntax-table-hwm most-positive-fixnum))
|
||||
(save-restriction
|
||||
(save-match-data
|
||||
(widen)
|
||||
(unwind-protect
|
||||
|
@ -1982,14 +1989,20 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
|
|||
;; without an intervening call to `before-change-functions' when reverting
|
||||
;; the buffer (see bug #24094). Whatever the cause, assume that the entire
|
||||
;; buffer has changed.
|
||||
(when (and (not c-just-done-before-change)
|
||||
(not (c-called-from-text-property-change-p)))
|
||||
|
||||
;; Note: c-just-done-before-change is nil, t, or 'whole-buffer.
|
||||
(unless (c-called-from-text-property-change-p)
|
||||
(save-restriction
|
||||
(widen)
|
||||
(c-before-change (point-min) (point-max))
|
||||
(unless c-just-done-before-change
|
||||
(c-before-change (point-min) (point-max)))
|
||||
(unless (eq c-just-done-before-change t)
|
||||
(setq beg (point-min)
|
||||
end (point-max)
|
||||
old-len (- end beg))))
|
||||
old-len (- end beg)
|
||||
c-new-BEG (point-min)
|
||||
c-new-END (point-max)))
|
||||
(setq c-just-done-before-change nil)))
|
||||
|
||||
;; (c-new-BEG c-new-END) will be the region to fontify. It may become
|
||||
;; larger than (beg end).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue