These cache variables are c-lit-pos-cache-limit,
c-semi-near-cache-limit, c-full-near-cache-limit, and
c-state-cache-invalid-pos.
* lisp/progmodes/cc-awk.el
(c-awk-set-string-regexp-syntax-table-properties): Invalidate
the caches after changing the 'syntax-table property.
* lisp/progmodes/cc-defs.el (c-put-string-fence-trim-caches):
New macro.
(c-unmark-<-or->-as-paren): New name for c-unmark-<->-as-paren.
(Also renamed throughout CC Mode)
* lisp/progmodes/cc-engine.el (c-propertize-ml-string-opener):
Add missing cache invalidation.
* lisp/progmodes/cc-mode.el (c-neutralize-CPP-line): Remove
syntax-table properties from < and > as needed.
(c-put-syn-tab): Add missing cache invalidation.
(cherry picked from commit
0334b0743f83a3e69d1d3a426efbba1d2a5f2cc6)
(if (eq (char-after beg) ?_) (setq beg (1+ beg)))
;; First put the properties on the delimiters.
- (cond ((eq end (point-max)) ; string/regexp terminated by EOB
- (c-put-string-fence beg))
+ (cond ((eq end (point-max)) ; string/regexp terminated by EOB
+ (c-put-string-fence-trim-caches beg))
((/= (char-after beg) (char-after end)) ; missing end delimiter
- (c-put-string-fence beg)
+ (c-put-string-fence-trim-caches beg)
(c-put-string-fence end))
((eq (char-after beg) ?/) ; Properly bracketed regexp
- (c-put-char-property beg 'syntax-table '(7)) ; (7) = "string"
- (c-put-syntax-table-trim-caches end '(7)))
- (t)) ; Properly bracketed string: Nothing to do.
+ (c-put-syntax-table-trim-caches beg '(7)) ; (7) = "string"
+ (c-put-char-property end 'syntax-table '(7)))
+ (t)) ; Properly bracketed string: Nothing to do.
;; Now change the properties of any escaped "s in the string to punctuation.
(save-excursion
(goto-char (1+ beg))
(c-clear-char-property -pos- 'c-is-sws)
(c-clear-char-property -pos- 'c-in-sws)))
+(defmacro c-put-string-fence-trim-caches (pos)
+ ;; Put the string-fence syntax-table text property at POS, and invalidate
+ ;; the four caches from position POS.
+ (declare (debug t))
+ `(let ((-pos- ,pos))
+ (c-put-string-fence -pos-)
+ (c-truncate-lit-pos/state-cache -pos-)))
+
(eval-and-compile
;; Constant to decide at compilation time whether to use category
;; properties. Currently (2010-03) they're available only on GNU
`(c-put-char-property ,pos 'category 'c->-as-paren-syntax)
`(c-put-char-property ,pos 'syntax-table c->-as-paren-syntax)))
-(defmacro c-unmark-<->-as-paren (pos)
- ;; Unmark the "<" or "<" character at POS as an sexp list opener using the
+(defmacro c-unmark-<-or->-as-paren (pos)
+ ;; Unmark the "<" or ">" character at POS as an sexp list opener using the
;; `syntax-table' property either directly or indirectly through a
;; `category' text property.
;;
(c-go-list-forward))
(when (equal (c-get-char-property (1- (point)) 'syntax-table)
c->-as-paren-syntax) ; should always be true.
- (c-unmark-<->-as-paren (1- (point)))
+ (c-unmark-<-or->-as-paren (1- (point)))
(c-truncate-lit-pos/state-cache (1- (point))))
- (c-unmark-<->-as-paren pos)
+ (c-unmark-<-or->-as-paren pos)
(c-truncate-lit-pos/state-cache pos))))
(defun c-clear->-pair-props (&optional pos)
(c-go-up-list-backward))
(when (equal (c-get-char-property (point) 'syntax-table)
c-<-as-paren-syntax) ; should always be true.
- (c-unmark-<->-as-paren (point))
+ (c-unmark-<-or->-as-paren (point))
(c-truncate-lit-pos/state-cache (point)))
- (c-unmark-<->-as-paren pos)
+ (c-unmark-<-or->-as-paren pos)
(c-truncate-lit-pos/state-cache pos))))
(defun c-clear-<>-pair-props (&optional pos)
(when (and (>= (point) lim)
(equal (c-get-char-property (1- (point)) 'syntax-table)
c->-as-paren-syntax)) ; should always be true.
- (c-unmark-<->-as-paren (1- (point)))
- (c-unmark-<->-as-paren pos)
+ (c-unmark-<-or->-as-paren (1- (point)))
+ (c-unmark-<-or->-as-paren pos)
(c-truncate-lit-pos/state-cache pos)
- (point)))))
+ (point)))))
(defun c-clear->-pair-props-if-match-before (lim &optional pos)
;; POS (default point) is at a > character. If it is both marked
(when (and (<= (point) lim)
(equal (c-get-char-property (point) 'syntax-table)
c-<-as-paren-syntax)) ; should always be true.
- (c-unmark-<->-as-paren (point))
+ (c-unmark-<-or->-as-paren (point))
(c-truncate-lit-pos/state-cache (point))
- (c-unmark-<->-as-paren pos)
+ (c-unmark-<-or->-as-paren pos)
(point)))))
;; Set by c-common-init in cc-mode.el.
(goto-char (cadr end-delim))
t)
(c-put-syntax-table-trim-caches (cddr delim) '(1))
- (c-put-string-fence (1- (cadr delim)))
+ (c-put-string-fence-trim-caches (1- (cadr delim)))
(when bound
;; In a CPP construct, we try to apply a generic-string
;; `syntax-table' text property to the last possible character in
"\\(\\\\\n\\)*\\=")) ; 11
(cadr delim) t))
(if (match-beginning 10)
- (progn
- (c-put-string-fence (match-beginning 10))
- (c-truncate-lit-pos/state-cache (match-beginning 10)))
+ (c-put-string-fence-trim-caches (match-beginning 10))
(c-put-syntax-table-trim-caches (match-beginning 5) '(1))
(c-put-string-fence (1+ (match-beginning 5)))))
(goto-char bound))
(and (c-go-list-backward)
(eq (char-after) ?<)
(c-truncate-lit-pos/state-cache (point))
- (c-unmark-<->-as-paren (point)))))
+ (c-unmark-<-or->-as-paren (point)))))
(c-mark-<-as-paren start)
(c-mark->-as-paren (1- (point)))
(c-truncate-lit-pos/state-cache start))
(progn
(setq s (parse-partial-sexp beg end -1))
(cond
- ((< (nth 0 s) 0) ; found an unmated ),},]
- (c-put-syntax-table-trim-caches (1- (point)) '(1))
+ ((< (nth 0 s) 0) ; found an unmated ),},],>
+ (if (eq (char-before) ?>)
+ (c-clear->-pair-props (1- (point)))
+ (c-put-syntax-table-trim-caches (1- (point)) '(1)))
t)
;; Unbalanced strings are now handled by
;; `c-before-change-check-unbalanced-strings', etc.
;; ((nth 3 s) ; In a string
;; (c-put-char-property (nth 8 s) 'syntax-table '(1))
;; t)
- ((> (nth 0 s) 0) ; In a (,{,[
- (c-put-syntax-table-trim-caches (nth 1 s) '(1))
+ ((> (nth 0 s) 0) ; In a (,{,[,<
+ (if (eq (char-after (nth 1 s)) ?<)
+ (c-clear-<-pair-props (nth 1 s))
+ (c-put-syntax-table-trim-caches (nth 1 s) '(1)))
t)
(t nil)))))))
;; `(let ((-pos- ,pos)
;; (-value- ,value))
(if (equal value '(15))
- (c-put-string-fence pos)
+ (c-put-string-fence-trim-caches pos)
(c-put-syntax-table-trim-caches pos value))
(c-put-char-property pos 'c-fl-syn-tab value)
(cond
(looking-at "\\s(")
(looking-at "\\(<\\)[^>\n\r]*\\(>\\)?")
(not (cdr (c-semi-pp-to-literal hash-pos))))
- (c-unmark-<->-as-paren (match-beginning 1))
+ (c-unmark-<-or->-as-paren (match-beginning 1))
(when (< hash-pos c-new-BEG)
(setq c-new-BEG hash-pos))
(when (match-beginning 2)
- (c-unmark-<->-as-paren (match-beginning 2))
+ (c-unmark-<-or->-as-paren (match-beginning 2))
(when (> (match-end 2) c-new-END)
(setq c-new-END (match-end 2))))))))