aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2020-02-23 19:43:56 +0000
committerAlan Mackenzie2020-02-23 19:43:56 +0000
commit3bce7ec3826003fda1971224a20d7fe2cba8bf65 (patch)
tree21660c0f1d3db4f98ec9208bff691a09429f87a8
parentba7004b2a74c69450114c12ef4521768fc165e8e (diff)
downloademacs-3bce7ec3826003fda1971224a20d7fe2cba8bf65.tar.gz
emacs-3bce7ec3826003fda1971224a20d7fe2cba8bf65.zip
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.
-rw-r--r--lisp/progmodes/cc-mode.el47
1 files changed, 30 insertions, 17 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 7496684d939..9f95a9ce48b 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1865,18 +1865,25 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
1865 ;; it/them from the cache. Don't worry about being inside a string 1865 ;; it/them from the cache. Don't worry about being inside a string
1866 ;; or a comment - "wrongly" removing a symbol from `c-found-types' 1866 ;; or a comment - "wrongly" removing a symbol from `c-found-types'
1867 ;; isn't critical. 1867 ;; isn't critical.
1868 (unless (or (c-called-from-text-property-change-p) 1868 (unless (c-called-from-text-property-change-p)
1869 c-just-done-before-change) ; guard against a spurious second
1870 ; invocation of before-change-functions.
1871 (setq c-just-done-before-change t)
1872 ;; (c-new-BEG c-new-END) will be the region to fontify.
1873 (setq c-new-BEG beg c-new-END end)
1874 (setq c-maybe-stale-found-type nil)
1875 ;; A workaround for syntax-ppss's failure to notice syntax-table text
1876 ;; property changes.
1877 (when (fboundp 'syntax-ppss)
1878 (setq c-syntax-table-hwm most-positive-fixnum))
1879 (save-restriction 1869 (save-restriction
1870 (widen)
1871 (if c-just-done-before-change
1872 ;; We have two consecutive calls to `before-change-functions' without
1873 ;; an intervening `after-change-functions'. An example of this is bug
1874 ;; #38691. To protect CC Mode, assume that the entire buffer has
1875 ;; changed.
1876 (setq beg (point-min)
1877 end (point-max)
1878 c-just-done-before-change 'whole-buffer)
1879 (setq c-just-done-before-change t))
1880 ;; (c-new-BEG c-new-END) will be the region to fontify.
1881 (setq c-new-BEG beg c-new-END end)
1882 (setq c-maybe-stale-found-type nil)
1883 ;; A workaround for syntax-ppss's failure to notice syntax-table text
1884 ;; property changes.
1885 (when (fboundp 'syntax-ppss)
1886 (setq c-syntax-table-hwm most-positive-fixnum))
1880 (save-match-data 1887 (save-match-data
1881 (widen) 1888 (widen)
1882 (unwind-protect 1889 (unwind-protect
@@ -1982,14 +1989,20 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
1982 ;; without an intervening call to `before-change-functions' when reverting 1989 ;; without an intervening call to `before-change-functions' when reverting
1983 ;; the buffer (see bug #24094). Whatever the cause, assume that the entire 1990 ;; the buffer (see bug #24094). Whatever the cause, assume that the entire
1984 ;; buffer has changed. 1991 ;; buffer has changed.
1985 (when (and (not c-just-done-before-change) 1992
1986 (not (c-called-from-text-property-change-p))) 1993 ;; Note: c-just-done-before-change is nil, t, or 'whole-buffer.
1994 (unless (c-called-from-text-property-change-p)
1987 (save-restriction 1995 (save-restriction
1988 (widen) 1996 (widen)
1989 (c-before-change (point-min) (point-max)) 1997 (unless c-just-done-before-change
1990 (setq beg (point-min) 1998 (c-before-change (point-min) (point-max)))
1991 end (point-max) 1999 (unless (eq c-just-done-before-change t)
1992 old-len (- end beg)))) 2000 (setq beg (point-min)
2001 end (point-max)
2002 old-len (- end beg)
2003 c-new-BEG (point-min)
2004 c-new-END (point-max)))
2005 (setq c-just-done-before-change nil)))
1993 2006
1994 ;; (c-new-BEG c-new-END) will be the region to fontify. It may become 2007 ;; (c-new-BEG c-new-END) will be the region to fontify. It may become
1995 ;; larger than (beg end). 2008 ;; larger than (beg end).