aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2020-06-29 19:10:09 +0000
committerAlan Mackenzie2020-06-29 19:10:09 +0000
commit519e64f98140b984e10a9567017c7e5c4a81ff89 (patch)
treef4576a3033ba65d5fa42fc4c8fad2e9d2f844512
parentd0872638b4f6330bdece465d6cbf5c1d85306c35 (diff)
downloademacs-519e64f98140b984e10a9567017c7e5c4a81ff89.tar.gz
emacs-519e64f98140b984e10a9567017c7e5c4a81ff89.zip
CC Mode: optimize for repeated simple operations.
Do this by recognising that unterminated strings in a buffer are typically going to be few and close together. Also optimize code for C++ attributes. * lisp/progmodes/cc-defs.el (c-previous-single-property-change): New macro. (c-put-syn-tab, c-clear-syn-tab): Turned from macros into functions, and moved to cc-mode.el. (c-clear-syn-tab-properties): Amended to use c-min/max-syn-tab-mkr. (c-with-extended-string-fences): Removed. * lisp/progmodes/cc-engine-el (c-enclosing-c++-attribute): Rewritten for speed. (c-slow-enclosing-c++-attribute): Removed. (c-semi-pp-to-literal): Remove a superfluous call to c-with-extended-string-fences. * lisp/progmodes/cc-mode.el (c-min-syn-tab-mkr, c-max-syn-tab-mkr): two new marker variables which bound the region occupied by positions with c-fl-syn-tab text properties. (c-basic-common-init): Initialize these two variables. (c-fl-syn-tab-region): Removed. (c-put-syn-tab, c-clear-syn-tab): Functions moved from cc-defs.el. (c-clear-string-fences): Amended to use the new scheme. (c-restore-string-fences): Now takes no arguments; amended to use the new scheme. (c-font-lock-fontify-region): Amended to use the new scheme.
-rw-r--r--lisp/progmodes/cc-defs.el61
-rw-r--r--lisp/progmodes/cc-engine.el67
-rw-r--r--lisp/progmodes/cc-mode.el224
3 files changed, 183 insertions, 169 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 2624d9db58d..9a3d7adf61d 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -445,6 +445,15 @@ to it is returned. This function does not modify the point or the mark."
445 ;; Emacs and earlier XEmacs 445 ;; Emacs and earlier XEmacs
446 `(next-single-property-change ,position ,prop ,object ,limit))) 446 `(next-single-property-change ,position ,prop ,object ,limit)))
447 447
448(defmacro c-previous-single-property-change (position prop &optional object limit)
449 ;; See the doc string for either of the defuns expanded to.
450 (if (and c-use-extents
451 (fboundp 'previous-single-char-property-change))
452 ;; XEmacs >= 2005-01-25
453 `(previous-single-char-property-change ,position ,prop ,object ,limit)
454 ;; Emacs and earlier XEmacs
455 `(previous-single-property-change ,position ,prop ,object ,limit)))
456
448(defmacro c-region-is-active-p () 457(defmacro c-region-is-active-p ()
449 ;; Return t when the region is active. The determination of region 458 ;; Return t when the region is active. The determination of region
450 ;; activeness is different in both Emacs and XEmacs. 459 ;; activeness is different in both Emacs and XEmacs.
@@ -1047,15 +1056,6 @@ MODE is either a mode symbol or a list of mode symbols."
1047;; properties set on a single character and that never spread to any 1056;; properties set on a single character and that never spread to any
1048;; other characters. 1057;; other characters.
1049 1058
1050(defmacro c-put-syn-tab (pos value)
1051 ;; Set both the syntax-table and the c-fl-syn-tab text properties at POS to
1052 ;; VALUE (which should not be nil).
1053 `(let ((-pos- ,pos)
1054 (-value- ,value))
1055 (c-put-char-property -pos- 'syntax-table -value-)
1056 (c-put-char-property -pos- 'c-fl-syn-tab -value-)
1057 (c-truncate-lit-pos-cache -pos-)))
1058
1059(eval-and-compile 1059(eval-and-compile
1060 ;; Constant used at compile time to decide whether or not to use 1060 ;; Constant used at compile time to decide whether or not to use
1061 ;; XEmacs extents. Check all the extent functions we'll use since 1061 ;; XEmacs extents. Check all the extent functions we'll use since
@@ -1183,13 +1183,6 @@ MODE is either a mode symbol or a list of mode symbols."
1183 ;; Emacs < 21. 1183 ;; Emacs < 21.
1184 `(c-clear-char-property-fun ,pos ',property)))) 1184 `(c-clear-char-property-fun ,pos ',property))))
1185 1185
1186(defmacro c-clear-syn-tab (pos)
1187 ;; Remove both the 'syntax-table and `c-fl-syn-tab properties at POS.
1188 `(let ((-pos- ,pos))
1189 (c-clear-char-property -pos- 'syntax-table)
1190 (c-clear-char-property -pos- 'c-fl-syn-tab)
1191 (c-truncate-lit-pos-cache -pos-)))
1192
1193(defmacro c-min-property-position (from to property) 1186(defmacro c-min-property-position (from to property)
1194 ;; Return the first position in the range [FROM to) where the text property 1187 ;; Return the first position in the range [FROM to) where the text property
1195 ;; PROPERTY is set, or `most-positive-fixnum' if there is no such position. 1188 ;; PROPERTY is set, or `most-positive-fixnum' if there is no such position.
@@ -1235,8 +1228,18 @@ MODE is either a mode symbol or a list of mode symbols."
1235 ;; Remove all occurrences of the `syntax-table' and `c-fl-syn-tab' text 1228 ;; Remove all occurrences of the `syntax-table' and `c-fl-syn-tab' text
1236 ;; properties between FROM and TO. 1229 ;; properties between FROM and TO.
1237 `(let ((-from- ,from) (-to- ,to)) 1230 `(let ((-from- ,from) (-to- ,to))
1238 (c-clear-char-properties -from- -to- 'syntax-table) 1231 (when (and
1239 (c-clear-char-properties -from- -to- 'c-fl-syn-tab))) 1232 c-min-syn-tab-mkr c-max-syn-tab-mkr
1233 (< -from- c-max-syn-tab-mkr)
1234 (> -to- c-min-syn-tab-mkr))
1235 (let ((pos -from-))
1236 (while (and
1237 (< pos -to-)
1238 (setq pos (c-min-property-position pos -to- 'c-fl-syn-tab))
1239 (< pos -to-))
1240 (c-clear-syn-tab pos)
1241 (setq pos (1+ pos)))))
1242 (c-clear-char-properties -from- -to- 'syntax-table)))
1240 1243
1241(defmacro c-search-forward-char-property (property value &optional limit) 1244(defmacro c-search-forward-char-property (property value &optional limit)
1242 "Search forward for a text-property PROPERTY having value VALUE. 1245 "Search forward for a text-property PROPERTY having value VALUE.
@@ -1456,28 +1459,6 @@ with value CHAR in the region [FROM to)."
1456 (c-put-char-property (point) ,property ,value) 1459 (c-put-char-property (point) ,property ,value)
1457 (forward-char))))) 1460 (forward-char)))))
1458 1461
1459(defmacro c-with-extended-string-fences (beg end &rest body)
1460 ;; If needed, extend the region with "mirrored" c-fl-syn-tab properties to
1461 ;; contain the region (BEG END), then evaluate BODY. If this mirrored
1462 ;; region was initially empty, restore it afterwards.
1463 `(let ((-beg- ,beg)
1464 (-end- ,end)
1465 )
1466 (cond
1467 ((null c-fl-syn-tab-region)
1468 (unwind-protect
1469 (progn
1470 (c-restore-string-fences -beg- -end-)
1471 ,@body)
1472 (c-clear-string-fences)))
1473 ((and (>= -beg- (car c-fl-syn-tab-region))
1474 (<= -end- (cdr c-fl-syn-tab-region)))
1475 ,@body)
1476 (t ; Crudely extend the mirrored region.
1477 (setq -beg- (min -beg- (car c-fl-syn-tab-region))
1478 -end- (max -end- (cdr c-fl-syn-tab-region)))
1479 (c-restore-string-fences -beg- -end-)
1480 ,@body))))
1481 1462
1482;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text. 1463;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text.
1483;; For our purposes, these are characterized by being possible to 1464;; For our purposes, these are characterized by being possible to
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 888184d2b46..1977eadb5c6 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -163,7 +163,9 @@
163(defvar c-doc-line-join-re) 163(defvar c-doc-line-join-re)
164(defvar c-doc-bright-comment-start-re) 164(defvar c-doc-bright-comment-start-re)
165(defvar c-doc-line-join-end-ch) 165(defvar c-doc-line-join-end-ch)
166(defvar c-fl-syn-tab-region) 166(cc-bytecomp-defvar c-min-syn-tab-mkr)
167(cc-bytecomp-defvar c-max-syn-tab-mkr)
168(cc-bytecomp-defun c-clear-syn-tab)
167(cc-bytecomp-defun c-clear-string-fences) 169(cc-bytecomp-defun c-clear-string-fences)
168(cc-bytecomp-defun c-restore-string-fences) 170(cc-bytecomp-defun c-restore-string-fences)
169 171
@@ -1910,52 +1912,29 @@ comment at the start of cc-engine.el for more info."
1910(defun c-enclosing-c++-attribute () 1912(defun c-enclosing-c++-attribute ()
1911 ;; If we're in C++ Mode, and point is within a correctly balanced [[ ... ]] 1913 ;; If we're in C++ Mode, and point is within a correctly balanced [[ ... ]]
1912 ;; attribute structure, return a cons of its starting and ending positions. 1914 ;; attribute structure, return a cons of its starting and ending positions.
1913 ;; Otherwise, return nil. We use the c-{in,is}-sws-face text properties for 1915 ;; Otherwise, return nil.
1914 ;; this determination, this macro being intended only for use in the *-sws-*
1915 ;; functions and macros. The match data are NOT preserved over this macro.
1916 (let (attr-end pos-is-sws)
1917 (and
1918 (c-major-mode-is 'c++-mode)
1919 (> (point) (point-min))
1920 (setq pos-is-sws
1921 (if (get-text-property (1- (point)) 'c-is-sws)
1922 (1- (point))
1923 (1- (previous-single-property-change
1924 (point) 'c-is-sws nil (point-min)))))
1925 (save-excursion
1926 (goto-char pos-is-sws)
1927 (setq attr-end (c-looking-at-c++-attribute)))
1928 (> attr-end (point))
1929 (cons pos-is-sws attr-end))))
1930
1931(defun c-slow-enclosing-c++-attribute ()
1932 ;; Like `c-enclosing-c++-attribute', but does not depend on the c-i[ns]-sws
1933 ;; properties being set.
1934 (and 1916 (and
1935 (c-major-mode-is 'c++-mode) 1917 (c-major-mode-is 'c++-mode)
1936 (save-excursion 1918 (save-excursion
1937 (let ((paren-state (c-parse-state)) 1919 (let ((lim (max (- (point) 200) (point-min)))
1938 cand) 1920 cand)
1939 (while 1921 (while
1940 (progn 1922 (and
1941 (setq cand 1923 (progn
1942 (catch 'found-cand 1924 (skip-chars-backward "^[;{}" lim)
1943 (while (cdr paren-state) 1925 (eq (char-before) ?\[))
1944 (when (and (numberp (car paren-state)) 1926 (not (eq (char-before (1- (point))) ?\[))
1945 (numberp (cadr paren-state)) 1927 (> (point) lim))
1946 (eq (car paren-state) 1928 (backward-char))
1947 (1+ (cadr paren-state))) 1929 (and (eq (char-before) ?\[)
1948 (eq (char-after (car paren-state)) ?\[) 1930 (eq (char-before (1- (point))) ?\[)
1949 (eq (char-after (cadr paren-state)) ?\[)) 1931 (progn (backward-char 2) t)
1950 (throw 'found-cand (cadr paren-state))) 1932 (setq cand (point))
1951 (setq paren-state (cdr paren-state))))) 1933 (c-go-list-forward nil (min (+ (point) 200) (point-max)))
1952 (and cand 1934 (eq (char-before) ?\])
1953 (not 1935 (eq (char-before (1- (point))) ?\])
1954 (and (c-go-list-forward cand) 1936 (not (c-literal-limits))
1955 (eq (char-before) ?\]) 1937 (cons cand (point)))))))
1956 (eq (char-before (1- (point))) ?\])))))
1957 (setq paren-state (cdr paren-state)))
1958 (and cand (cons cand (point)))))))
1959 1938
1960(defun c-invalidate-sws-region-before (beg end) 1939(defun c-invalidate-sws-region-before (beg end)
1961 ;; Called from c-before-change. BEG and END are the bounds of the change 1940 ;; Called from c-before-change. BEG and END are the bounds of the change
@@ -3003,9 +2982,7 @@ comment at the start of cc-engine.el for more info."
3003 c-block-comment-awkward-chars))) 2982 c-block-comment-awkward-chars)))
3004 (and (nth 4 s) (nth 7 s) ; Line comment 2983 (and (nth 4 s) (nth 7 s) ; Line comment
3005 (not (memq (char-before here) '(?\\ ?\n))))))) 2984 (not (memq (char-before here) '(?\\ ?\n)))))))
3006 (c-with-extended-string-fences 2985 (setq s (parse-partial-sexp pos here nil nil s)))
3007 pos here
3008 (setq s (parse-partial-sexp pos here nil nil s))))
3009 (when (not (eq near-pos here)) 2986 (when (not (eq near-pos here))
3010 (c-semi-put-near-cache-entry here s)) 2987 (c-semi-put-near-cache-entry here s))
3011 (cond 2988 (cond
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 4869f5c596d..bd0efc681eb 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -558,6 +558,18 @@ preferably use the `c-mode-menu' language constant directly."
558;; and `after-change-functions'. Note that this variable is not set when 558;; and `after-change-functions'. Note that this variable is not set when
559;; `c-before-change' is invoked by a change to text properties. 559;; `c-before-change' is invoked by a change to text properties.
560 560
561(defvar c-min-syn-tab-mkr nil)
562;; The minimum buffer position where there's a `c-fl-syn-tab' text property,
563;; or nil if there aren't any. This is a marker, or nil if there's currently
564;; no such text property.
565(make-variable-buffer-local 'c-min-syn-tab-mkr)
566
567(defvar c-max-syn-tab-mkr nil)
568;; The maximum buffer position plus 1 where there's a `c-fl-syn-tab' text
569;; property, or nil if there aren't any. This is a marker, or nil if there's
570;; currently no such text property.
571(make-variable-buffer-local 'c-max-syn-tab-mkr)
572
561(defun c-basic-common-init (mode default-style) 573(defun c-basic-common-init (mode default-style)
562 "Do the necessary initialization for the syntax handling routines 574 "Do the necessary initialization for the syntax handling routines
563and the line breaking/filling code. Intended to be used by other 575and the line breaking/filling code. Intended to be used by other
@@ -631,6 +643,10 @@ that requires a literal mode spec at compile time."
631 ;; Initialize the "brace stack" cache. 643 ;; Initialize the "brace stack" cache.
632 (c-init-bs-cache) 644 (c-init-bs-cache)
633 645
646 ;; Keep track of where `c-fl-syn-tab' text properties are set.
647 (setq c-min-syn-tab-mkr nil)
648 (setq c-max-syn-tab-mkr nil)
649
634 (when (or c-recognize-<>-arglists 650 (when (or c-recognize-<>-arglists
635 (c-major-mode-is 'awk-mode) 651 (c-major-mode-is 'awk-mode)
636 (c-major-mode-is '(java-mode c-mode c++-mode objc-mode pike-mode))) 652 (c-major-mode-is '(java-mode c-mode c++-mode objc-mode pike-mode)))
@@ -1232,52 +1248,94 @@ Note that the style variables are always made local to the buffer."
1232 (c-put-char-property (1- (point)) 'syntax-table '(15))) 1248 (c-put-char-property (1- (point)) 'syntax-table '(15)))
1233 (t nil))))) 1249 (t nil)))))
1234 1250
1235(defvar c-fl-syn-tab-region nil) 1251(defun c-put-syn-tab (pos value)
1236 ;; Non-nil when a `c-restore-string-fences' is "in force". It's value is a 1252 ;; Set both the syntax-table and the c-fl-syn-tab text properties at POS to
1237 ;; cons of the BEG and END of the region currently "mirroring" the 1253 ;; VALUE (which should not be nil).
1238 ;; c-fl-syn-tab properties as syntax-table properties. 1254 ;; `(let ((-pos- ,pos)
1255 ;; (-value- ,value))
1256 (c-put-char-property pos 'syntax-table value)
1257 (c-put-char-property pos 'c-fl-syn-tab value)
1258 (cond
1259 ((null c-min-syn-tab-mkr)
1260 (setq c-min-syn-tab-mkr (copy-marker pos t)))
1261 ((< pos c-min-syn-tab-mkr)
1262 (move-marker c-min-syn-tab-mkr pos)))
1263 (cond
1264 ((null c-max-syn-tab-mkr)
1265 (setq c-max-syn-tab-mkr (copy-marker (1+ pos) nil)))
1266 ((>= pos c-max-syn-tab-mkr)
1267 (move-marker c-max-syn-tab-mkr (1+ pos))))
1268 (c-truncate-lit-pos-cache pos))
1269
1270(defun c-clear-syn-tab (pos)
1271 ;; Remove both the 'syntax-table and `c-fl-syn-tab properties at POS.
1272 (c-clear-char-property pos 'syntax-table)
1273 (c-clear-char-property pos 'c-fl-syn-tab)
1274 (when c-min-syn-tab-mkr
1275 (if (and (eq pos (marker-position c-min-syn-tab-mkr))
1276 (eq (1+ pos) (marker-position c-max-syn-tab-mkr)))
1277 (progn
1278 (move-marker c-min-syn-tab-mkr nil)
1279 (move-marker c-max-syn-tab-mkr nil)
1280 (setq c-min-syn-tab-mkr nil c-max-syn-tab-mkr nil))
1281 (when (eq pos (marker-position c-min-syn-tab-mkr))
1282 (move-marker c-min-syn-tab-mkr
1283 (if (c-get-char-property (1+ pos) 'c-fl-syn-tab)
1284 (1+ pos)
1285 (c-next-single-property-change
1286 (1+ pos) 'c-fl-syn-tab nil c-max-syn-tab-mkr))))
1287 (when (eq (1+ pos) (marker-position c-max-syn-tab-mkr))
1288 (move-marker c-max-syn-tab-mkr
1289 (if (c-get-char-property (1- pos) 'c-fl-syn-tab)
1290 pos
1291 (c-previous-single-property-change
1292 pos 'c-fl-syn-tab nil (1+ c-min-syn-tab-mkr)))))))
1293 (c-truncate-lit-pos-cache pos))
1239 1294
1240(defun c-clear-string-fences () 1295(defun c-clear-string-fences ()
1241 ;; Clear syntax-table text properties in the region defined by 1296 ;; Clear syntax-table text properties which are "mirrored" by c-fl-syn-tab
1242 ;; `c-cl-syn-tab-region' which are "mirrored" by c-fl-syn-tab text 1297 ;; text properties. However, any such " character which ends up not being
1243 ;; properties. However, any such " character which ends up not being
1244 ;; balanced by another " is left with a '(1) syntax-table property. 1298 ;; balanced by another " is left with a '(1) syntax-table property.
1245 (when c-fl-syn-tab-region 1299 (when
1246 (let ((beg (car c-fl-syn-tab-region)) 1300 (and c-min-syn-tab-mkr c-max-syn-tab-mkr)
1247 (end (cdr c-fl-syn-tab-region)) 1301 (let (s pos)
1248 s pos) 1302 (setq pos c-min-syn-tab-mkr)
1249 (setq pos beg)
1250 (while 1303 (while
1251 (and 1304 (and
1252 (< pos end) 1305 (< pos c-max-syn-tab-mkr)
1253 (setq pos 1306 (setq pos (c-min-property-position pos
1254 (c-min-property-position pos end 'c-fl-syn-tab)) 1307 c-max-syn-tab-mkr
1255 (< pos end)) 1308 'c-fl-syn-tab))
1309 (< pos c-max-syn-tab-mkr))
1256 (c-clear-char-property pos 'syntax-table) 1310 (c-clear-char-property pos 'syntax-table)
1257 (setq pos (1+ pos))) 1311 (setq pos (1+ pos)))
1258 ;; Check we haven't left any unbalanced "s. 1312 ;; Check we haven't left any unbalanced "s.
1259 (save-excursion 1313 (save-excursion
1260 (setq pos beg) 1314 (setq pos c-min-syn-tab-mkr)
1261 ;; Is there already an unbalanced " before BEG? 1315 ;; Is there already an unbalanced " before BEG?
1262 (setq pos (c-min-property-position pos end 'c-fl-syn-tab)) 1316 (setq pos (c-min-property-position pos c-max-syn-tab-mkr
1263 (when (< pos end) (goto-char pos)) 1317 'c-fl-syn-tab))
1318 (when (< pos c-max-syn-tab-mkr)
1319 (goto-char pos))
1264 (when (and (save-match-data 1320 (when (and (save-match-data
1265 (c-search-backward-char-property-with-value-on-char 1321 (c-search-backward-char-property-with-value-on-char
1266 'c-fl-syn-tab '(15) ?\" 1322 'c-fl-syn-tab '(15) ?\"
1267 (max (- (point) 500) (point-min)))) 1323 (max (- (point) 500) (point-min))))
1268 (not (equal (c-get-char-property (point) 'syntax-table) '(1)))) 1324 (not (equal (c-get-char-property (point) 'syntax-table) '(1))))
1269 (setq pos (1+ pos))) 1325 (setq pos (1+ pos)))
1270 (while (< pos end) 1326 (while (< pos c-max-syn-tab-mkr)
1271 (setq pos 1327 (setq pos
1272 (c-min-property-position pos end 'c-fl-syn-tab)) 1328 (c-min-property-position pos c-max-syn-tab-mkr 'c-fl-syn-tab))
1273 (when (< pos end) 1329 (when (< pos c-max-syn-tab-mkr)
1274 (if (memq (char-after pos) c-string-delims) 1330 (if (memq (char-after pos) c-string-delims)
1275 (progn 1331 (progn
1276 ;; Step over the ". 1332 ;; Step over the ".
1277 (setq s (parse-partial-sexp pos end nil nil nil 1333 (setq s (parse-partial-sexp pos c-max-syn-tab-mkr
1334 nil nil nil
1278 'syntax-table)) 1335 'syntax-table))
1279 ;; Seek a (bogus) matching ". 1336 ;; Seek a (bogus) matching ".
1280 (setq s (parse-partial-sexp (point) end nil nil s 1337 (setq s (parse-partial-sexp (point) c-max-syn-tab-mkr
1338 nil nil s
1281 'syntax-table)) 1339 'syntax-table))
1282 ;; When a bogus matching " is found, do nothing. 1340 ;; When a bogus matching " is found, do nothing.
1283 ;; Otherwise mark the " with 'syntax-table '(1). 1341 ;; Otherwise mark the " with 'syntax-table '(1).
@@ -1287,23 +1345,22 @@ Note that the style variables are always made local to the buffer."
1287 (c-get-char-property (1- (point)) 'c-fl-syn-tab)) 1345 (c-get-char-property (1- (point)) 'c-fl-syn-tab))
1288 (c-put-char-property pos 'syntax-table '(1))) 1346 (c-put-char-property pos 'syntax-table '(1)))
1289 (setq pos (point))) 1347 (setq pos (point)))
1290 (setq pos (1+ pos)))))) 1348 (setq pos (1+ pos)))))))))
1291 (setq c-fl-syn-tab-region nil)))) 1349
1292 1350(defun c-restore-string-fences ()
1293(defun c-restore-string-fences (beg end) 1351 ;; Restore any syntax-table text properties which are "mirrored" by
1294 ;; Restore any syntax-table text properties in the region (BEG END) which 1352 ;; c-fl-syn-tab text properties.
1295 ;; are "mirrored" by c-fl-syn-tab text properties. 1353 (when (and c-min-syn-tab-mkr c-max-syn-tab-mkr)
1296 (let ((pos beg)) 1354 (let ((pos c-min-syn-tab-mkr))
1297 (while 1355 (while
1298 (and 1356 (and
1299 (< pos end) 1357 (< pos c-max-syn-tab-mkr)
1300 (setq pos 1358 (setq pos
1301 (c-min-property-position pos end 'c-fl-syn-tab)) 1359 (c-min-property-position pos c-max-syn-tab-mkr 'c-fl-syn-tab))
1302 (< pos end)) 1360 (< pos c-max-syn-tab-mkr))
1303 (c-put-char-property pos 'syntax-table 1361 (c-put-char-property pos 'syntax-table
1304 (c-get-char-property pos 'c-fl-syn-tab)) 1362 (c-get-char-property pos 'c-fl-syn-tab))
1305 (setq pos (1+ pos))) 1363 (setq pos (1+ pos))))))
1306 (setq c-fl-syn-tab-region (cons beg end))))
1307 1364
1308(defvar c-bc-changed-stringiness nil) 1365(defvar c-bc-changed-stringiness nil)
1309;; Non-nil when, in a before-change function, the deletion of a range of text 1366;; Non-nil when, in a before-change function, the deletion of a range of text
@@ -1913,7 +1970,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
1913 (widen) 1970 (widen)
1914 (unwind-protect 1971 (unwind-protect
1915 (progn 1972 (progn
1916 (c-restore-string-fences (point-min) (point-max)) 1973 (c-restore-string-fences)
1917 (save-excursion 1974 (save-excursion
1918 ;; Are we inserting/deleting stuff in the middle of an 1975 ;; Are we inserting/deleting stuff in the middle of an
1919 ;; identifier? 1976 ;; identifier?
@@ -2043,7 +2100,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
2043 (widen) 2100 (widen)
2044 (unwind-protect 2101 (unwind-protect
2045 (progn 2102 (progn
2046 (c-restore-string-fences (point-min) (point-max)) 2103 (c-restore-string-fences)
2047 (when (> end (point-max)) 2104 (when (> end (point-max))
2048 ;; Some emacsen might return positions past the end. This 2105 ;; Some emacsen might return positions past the end. This
2049 ;; has been observed in Emacs 20.7 when rereading a buffer 2106 ;; has been observed in Emacs 20.7 when rereading a buffer
@@ -2208,7 +2265,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
2208 enclosing-attribute pos1) 2265 enclosing-attribute pos1)
2209 (unless lit-start 2266 (unless lit-start
2210 (c-backward-syntactic-ws) 2267 (c-backward-syntactic-ws)
2211 (when (setq enclosing-attribute (c-slow-enclosing-c++-attribute)) 2268 (when (setq enclosing-attribute (c-enclosing-c++-attribute))
2212 (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode. 2269 (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode.
2213 (when (setq pos1 (c-on-identifier)) 2270 (when (setq pos1 (c-on-identifier))
2214 (goto-char pos1) 2271 (goto-char pos1)
@@ -2303,46 +2360,45 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
2303 (t beg))) 2360 (t beg)))
2304 (c-save-buffer-state nil 2361 (c-save-buffer-state nil
2305 ;; Temporarily reapply the string fence syntax-table properties. 2362 ;; Temporarily reapply the string fence syntax-table properties.
2306 (c-with-extended-string-fences 2363 (unwind-protect
2307 string-fence-beg (if c-in-after-change-fontification 2364 (progn
2308 (max end c-new-END) 2365 (c-restore-string-fences)
2309 end) 2366 (if (and c-in-after-change-fontification
2310 2367 (< beg c-new-END) (> end c-new-BEG))
2311 (if (and c-in-after-change-fontification 2368 ;; Region and the latest after-change fontification region overlap.
2312 (< beg c-new-END) (> end c-new-BEG)) 2369 ;; Determine the upper and lower bounds of our adjusted region
2313 ;; Region and the latest after-change fontification region overlap. 2370 ;; separately.
2314 ;; Determine the upper and lower bounds of our adjusted region 2371 (progn
2315 ;; separately. 2372 (if (<= beg c-new-BEG)
2316 (progn 2373 (setq c-in-after-change-fontification nil))
2317 (if (<= beg c-new-BEG) 2374 (setq new-beg
2318 (setq c-in-after-change-fontification nil)) 2375 (if (and (>= beg (c-point 'bol c-new-BEG))
2319 (setq new-beg 2376 (<= beg c-new-BEG))
2320 (if (and (>= beg (c-point 'bol c-new-BEG)) 2377 ;; Either jit-lock has accepted `c-new-BEG', or has
2321 (<= beg c-new-BEG)) 2378 ;; (probably) extended the change region spuriously
2322 ;; Either jit-lock has accepted `c-new-BEG', or has 2379 ;; to BOL, which position likely has a
2323 ;; (probably) extended the change region spuriously 2380 ;; syntactically different position. To ensure
2324 ;; to BOL, which position likely has a 2381 ;; correct fontification, we start at `c-new-BEG',
2325 ;; syntactically different position. To ensure 2382 ;; assuming any characters to the left of
2326 ;; correct fontification, we start at `c-new-BEG', 2383 ;; `c-new-BEG' on the line do not require
2327 ;; assuming any characters to the left of 2384 ;; fontification.
2328 ;; `c-new-BEG' on the line do not require 2385 c-new-BEG
2329 ;; fontification. 2386 (setq new-region (c-before-context-fl-expand-region beg end)
2330 c-new-BEG 2387 new-end (cdr new-region))
2331 (setq new-region (c-before-context-fl-expand-region beg end) 2388 (car new-region)))
2332 new-end (cdr new-region)) 2389 (setq new-end
2333 (car new-region))) 2390 (if (and (>= end (c-point 'bol c-new-END))
2334 (setq new-end 2391 (<= end c-new-END))
2335 (if (and (>= end (c-point 'bol c-new-END)) 2392 c-new-END
2336 (<= end c-new-END)) 2393 (or new-end
2337 c-new-END 2394 (cdr (c-before-context-fl-expand-region beg end))))))
2338 (or new-end 2395 ;; Context (etc.) fontification.
2339 (cdr (c-before-context-fl-expand-region beg end)))))) 2396 (setq new-region (c-before-context-fl-expand-region beg end)
2340 ;; Context (etc.) fontification. 2397 new-beg (car new-region) new-end (cdr new-region)))
2341 (setq new-region (c-before-context-fl-expand-region beg end) 2398 ;; Finally invoke font lock's functionality.
2342 new-beg (car new-region) new-end (cdr new-region))) 2399 (funcall (default-value 'font-lock-fontify-region-function)
2343 ;; Finally invoke font lock's functionality. 2400 new-beg new-end verbose))
2344 (funcall (default-value 'font-lock-fontify-region-function) 2401 (c-clear-string-fences)))))))
2345 new-beg new-end verbose)))))))
2346 2402
2347(defun c-after-font-lock-init () 2403(defun c-after-font-lock-init ()
2348 ;; Put on `font-lock-mode-hook'. This function ensures our after-change 2404 ;; Put on `font-lock-mode-hook'. This function ensures our after-change