aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2016-06-23 16:12:45 +0000
committerAlan Mackenzie2016-06-23 16:12:45 +0000
commit7a20ebe5ca884954e34c5129f70c211fef266369 (patch)
treee045011fd9b5f8272b4cfff7960a91e42b2b1596
parent11a17619737b16d10bfad03b52097943eebc517f (diff)
downloademacs-7a20ebe5ca884954e34c5129f70c211fef266369.tar.gz
emacs-7a20ebe5ca884954e34c5129f70c211fef266369.zip
Make typing into incomplete C++ raw strings work, and make it work fast enough
* lisp/progmodes/cc-engine.el (c-beginning-of-macro, c-state-pp-to-literal): Put `save-match-data' around calls to `looking-at' to enable the use of the match data in higher level functions. * lisp/progmodes/cc-fonts.el (c-font-lock-declarations) (c-font-lock-cut-off-declarators): Use `limit' rather than `(point-max)' as a limit to speed up handling of C++ raw strings.
-rw-r--r--lisp/progmodes/cc-engine.el55
-rw-r--r--lisp/progmodes/cc-fonts.el4
2 files changed, 30 insertions, 29 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 595d57756eb..5fa04034585 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -305,7 +305,7 @@ comment at the start of cc-engine.el for more info."
305 (forward-line -1)) 305 (forward-line -1))
306 (back-to-indentation) 306 (back-to-indentation)
307 (if (and (<= (point) here) 307 (if (and (<= (point) here)
308 (looking-at c-opt-cpp-start) 308 (save-match-data (looking-at c-opt-cpp-start))
309 (c-macro-is-genuine-p)) 309 (c-macro-is-genuine-p))
310 (progn 310 (progn
311 (setq c-macro-cache (cons (point) nil) 311 (setq c-macro-cache (cons (point) nil)
@@ -2304,32 +2304,33 @@ comment at the start of cc-engine.el for more info."
2304 ;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of 2304 ;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of
2305 ;; STATE are valid. 2305 ;; STATE are valid.
2306 (save-excursion 2306 (save-excursion
2307 (let ((s (parse-partial-sexp from to)) 2307 (save-match-data
2308 ty co-st) 2308 (let ((s (parse-partial-sexp from to))
2309 (cond 2309 ty co-st)
2310 ((or (nth 3 s) (nth 4 s)) ; in a string or comment 2310 (cond
2311 (setq ty (cond 2311 ((or (nth 3 s) (nth 4 s)) ; in a string or comment
2312 ((nth 3 s) 'string) 2312 (setq ty (cond
2313 ((nth 7 s) 'c++) 2313 ((nth 3 s) 'string)
2314 (t 'c))) 2314 ((nth 7 s) 'c++)
2315 (parse-partial-sexp (point) (point-max) 2315 (t 'c)))
2316 nil ; TARGETDEPTH 2316 (parse-partial-sexp (point) (point-max)
2317 nil ; STOPBEFORE 2317 nil ; TARGETDEPTH
2318 s ; OLDSTATE 2318 nil ; STOPBEFORE
2319 'syntax-table) ; stop at end of literal 2319 s ; OLDSTATE
2320 `(,s ,ty (,(nth 8 s) . ,(point)))) 2320 'syntax-table) ; stop at end of literal
2321 2321 `(,s ,ty (,(nth 8 s) . ,(point))))
2322 ((and (not not-in-delimiter) ; inside a comment starter 2322
2323 (not (bobp)) 2323 ((and (not not-in-delimiter) ; inside a comment starter
2324 (progn (backward-char) 2324 (not (bobp))
2325 (and (not (looking-at "\\s!")) 2325 (progn (backward-char)
2326 (looking-at c-comment-start-regexp)))) 2326 (and (not (looking-at "\\s!"))
2327 (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++) 2327 (looking-at c-comment-start-regexp))))
2328 co-st (point)) 2328 (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)
2329 (forward-comment 1) 2329 co-st (point))
2330 `(,s ,ty (,co-st . ,(point)))) 2330 (forward-comment 1)
2331 2331 `(,s ,ty (,co-st . ,(point))))
2332 (t `(,s)))))) 2332
2333 (t `(,s)))))))
2333 2334
2334(defun c-state-safe-place (here) 2335(defun c-state-safe-place (here)
2335 ;; Return a buffer position before HERE which is "safe", i.e. outside any 2336 ;; Return a buffer position before HERE which is "safe", i.e. outside any
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 65ec5c3f044..3a8c9ec0ec4 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1396,7 +1396,7 @@ casts and declarations are fontified. Used on level 2 and higher."
1396 'c-decl-id-start))))) 1396 'c-decl-id-start)))))
1397 1397
1398 (c-font-lock-declarators 1398 (c-font-lock-declarators
1399 (point-max) decl-list (cadr decl-or-cast))) 1399 (min limit (point-max)) decl-list (cadr decl-or-cast)))
1400 1400
1401 ;; A declaration has been successfully identified, so do all the 1401 ;; A declaration has been successfully identified, so do all the
1402 ;; fontification of types and refs that've been recorded. 1402 ;; fontification of types and refs that've been recorded.
@@ -1542,7 +1542,7 @@ casts and declarations are fontified. Used on level 2 and higher."
1542 (c-forward-syntactic-ws)) 1542 (c-forward-syntactic-ws))
1543 ;; At a real declaration? 1543 ;; At a real declaration?
1544 (if (memq (c-forward-type t) '(t known found decltype)) 1544 (if (memq (c-forward-type t) '(t known found decltype))
1545 (c-font-lock-declarators (point-max) t is-typedef))) 1545 (c-font-lock-declarators limit t is-typedef)))
1546 nil))))) 1546 nil)))))
1547 1547
1548(defun c-font-lock-enclosing-decls (limit) 1548(defun c-font-lock-enclosing-decls (limit)