summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-mode.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2010-04-12 18:58:52 +0000
committerAlan Mackenzie <acm@muc.de>2010-04-12 18:58:52 +0000
commite42a330165c80c3024d730c6075ed59a94b4db46 (patch)
tree2b8c97544cbca85de3dc529ea00b61e39878d758 /lisp/progmodes/cc-mode.el
parent7af4bf3aea19289d47e46d9007e786ac1956bcb7 (diff)
downloademacs-e42a330165c80c3024d730c6075ed59a94b4db46.tar.gz
Reverse 2009-12-03T16:02:10Z!acm@muc.de "Enhance `c-parse-state' to run efficiently in
\"brace desserts\".".
Diffstat (limited to 'lisp/progmodes/cc-mode.el')
-rw-r--r--lisp/progmodes/cc-mode.el54
1 files changed, 19 insertions, 35 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 91fc29cdfa8..2bfa2b7df9b 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -410,7 +410,7 @@ preferably use the `c-mode-menu' language constant directly."
;; temporary changes in some font lock support modes, causing extra
;; unnecessary work and font lock glitches due to interactions between
;; various text properties.
-;;
+;;
;; (2007-02-12): The macro `combine-after-change-calls' ISN'T used any
;; more.
@@ -451,18 +451,18 @@ preferably use the `c-mode-menu' language constant directly."
end (point))))))))
;; c-maybe-stale-found-type records a place near the region being
-;; changed where an element of `found-types' might become stale. It
+;; changed where an element of `found-types' might become stale. It
;; is set in c-before-change and is either nil, or has the form:
;;
;; (c-decl-id-start "foo" 97 107 " (* ooka) " "o"), where
-;;
+;;
;; o - `c-decl-id-start' is the c-type text property value at buffer
;; pos 96.
-;;
+;;
;; o - 97 107 is the region potentially containing the stale type -
;; this is delimited by a non-nil c-type text property at 96 and
;; either another one or a ";", "{", or "}" at 107.
-;;
+;;
;; o - " (* ooka) " is the (before change) buffer portion containing
;; the suspect type (here "ooka").
;;
@@ -517,9 +517,6 @@ that requires a literal mode spec at compile time."
(make-local-variable 'fill-paragraph-function)
(setq fill-paragraph-function 'c-fill-paragraph)
- ;; Initialise the cache of brace pairs, and opening braces/brackets/parens.
- (c-state-cache-init)
-
(when (or c-recognize-<>-arglists
(c-major-mode-is 'awk-mode)
(c-major-mode-is '(c-mode c++-mode objc-mode)))
@@ -846,7 +843,7 @@ Note that the style variables are always made local to the buffer."
t)
(t nil)))))))
-(defun c-neutralize-syntax-in-and-mark-CPP (begg endd old-len)
+(defun c-extend-and-neutralize-syntax-in-CPP (begg endd old-len)
;; (i) Extend the font lock region to cover all changed preprocessor
;; regions; it does this by setting the variables `c-new-BEG' and
;; `c-new-END' to the new boundaries.
@@ -855,15 +852,10 @@ Note that the style variables are always made local to the buffer."
;; extended changed region. "Restore" lines which were CPP lines before the
;; change and are no longer so; these can be located from the Buffer local
;; variables `c-old-BOM' and `c-old-EOM'.
- ;;
- ;; (iii) Mark every CPP construct by placing a `category' property value
- ;; `c-cpp-delimiter' at its start and end. The marked characters are the
- ;; opening # and usually the terminating EOL, but sometimes the character
- ;; before a comment/string delimiter.
- ;;
+ ;;
;; That is, set syntax-table properties on characters that would otherwise
;; interact syntactically with those outside the CPP line(s).
- ;;
+ ;;
;; This function is called from an after-change function, BEGG ENDD and
;; OLD-LEN being the standard parameters. It prepares the buffer for font
;; locking, hence must get called before `font-lock-after-change-function'.
@@ -874,34 +866,32 @@ Note that the style variables are always made local to the buffer."
;; This function is the C/C++/ObjC value of `c-before-font-lock-function'.
;;
;; Note: SPEED _MATTERS_ IN THIS FUNCTION!!!
- ;;
+ ;;
;; This function might make hidden buffer changes.
- (c-save-buffer-state (limits)
+ (c-save-buffer-state (limits mbeg+1)
;; First determine the region, (c-new-BEG c-new-END), which will get font
;; locked. It might need "neutralizing". This region may not start
;; inside a string, comment, or macro.
(goto-char c-old-BOM) ; already set to old start of macro or begg.
(setq c-new-BEG
- (if (setq limits (c-state-literal-at (point)))
+ (if (setq limits (c-literal-limits))
(cdr limits) ; go forward out of any string or comment.
(point)))
(goto-char endd)
- (if (setq limits (c-state-literal-at (point)))
+ (if (setq limits (c-literal-limits))
(goto-char (car limits))) ; go backward out of any string or comment.
(if (c-beginning-of-macro)
(c-end-of-macro))
(setq c-new-END (max (+ (- c-old-EOM old-len) (- endd begg))
(point)))
- ;; Clear all old relevant properties.
+ ;; Clear any existing punctuation properties.
(c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
- (c-clear-char-property-with-value c-new-BEG c-new-END 'category 'c-cpp-delimiter)
- ;; FIXME!!! What about the "<" and ">" category properties? 2009-11-16
;; Add needed properties to each CPP construct in the region.
(goto-char c-new-BEG)
- (let ((pps-position c-new-BEG) pps-state mbeg)
+ (let ((pps-position c-new-BEG) pps-state)
(while (and (< (point) c-new-END)
(search-forward-regexp c-anchored-cpp-prefix c-new-END t))
;; If we've found a "#" inside a string/comment, ignore it.
@@ -910,16 +900,10 @@ Note that the style variables are always made local to the buffer."
pps-position (point))
(unless (or (nth 3 pps-state) ; in a string?
(nth 4 pps-state)) ; in a comment?
- (goto-char (match-beginning 0))
- (setq mbeg (point))
- (if (> (c-syntactic-end-of-macro) mbeg)
- (progn
- (c-neutralize-CPP-line mbeg (point))
- (c-set-cpp-delimiters mbeg (point))
- ;(setq pps-position (point))
- )
- (forward-line)) ; no infinite loop with, e.g., "#//"
- )))))
+ (setq mbeg+1 (point))
+ (c-end-of-macro) ; Do we need to go forward 1 char here? No!
+ (c-neutralize-CPP-line mbeg+1 (point))
+ (setq pps-position (point))))))) ; no need to update pps-state.
(defun c-before-change (beg end)
;; Function to be put on `before-change-function'. Primarily, this calls
@@ -927,7 +911,7 @@ Note that the style variables are always made local to the buffer."
;; otherwise used only to remove stale entries from the `c-found-types'
;; cache, and to record entries which a `c-after-change' function might
;; confirm as stale.
- ;;
+ ;;
;; Note that this function must be FAST rather than accurate. Note
;; also that it only has any effect when font locking is enabled.
;; We exploit this by checking for font-lock-*-face instead of doing