diff options
author | Alan Mackenzie <acm@muc.de> | 2022-11-24 10:51:03 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2022-11-24 10:51:03 +0000 |
commit | 3208a42c47c4f98cb03c4b15164ca83113244b40 (patch) | |
tree | 5d0e8391eed6a5885083c6f0e5dec6f664e41f0d /lisp/progmodes/cc-engine.el | |
parent | 005efce764c50f5fc68be84a7fb52565b9a2d2bc (diff) | |
download | emacs-3208a42c47c4f98cb03c4b15164ca83113244b40.tar.gz |
CC Mode: Make it scroll fast over buffers with only #define's
* lisp/progmodes/cc-engine.el (c-forward-over-token): New LIMIT parameter
* lisp/progmodes/cc-langs.el (c-anchored-hash-define-no-parens): Replace
ill-formed regular expression (which mixed \\sw and character alternative)
with simpler efficient regexp.
* lisp/progmodes/cc-mode.el (c-fl-decl-end): New forward limit LIM+ used in
c-forward-declarator and c-forward-over-token.
Diffstat (limited to 'lisp/progmodes/cc-engine.el')
-rw-r--r-- | lisp/progmodes/cc-engine.el | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 086166c822b..9e09e5150d9 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -4951,30 +4951,31 @@ comment at the start of cc-engine.el for more info." "\\w\\|\\s_\\|\\s\"\\|\\s|" "\\w\\|\\s_\\|\\s\"")) -(defun c-forward-over-token (&optional balanced) +(defun c-forward-over-token (&optional balanced limit) "Move forward over a token. Return t if we moved, nil otherwise (i.e. we were at EOB, or a non-token or BALANCED is non-nil and we can't move). If we are at syntactic whitespace, move over this in place of a token. If BALANCED is non-nil move over any balanced parens we are at, and never move -out of an enclosing paren." +out of an enclosing paren. LIMIT is the limit to where we might move to." (let ((jump-syntax (if balanced c-jump-syntax-balanced c-jump-syntax-unbalanced)) - (here (point))) + (here (point)) + (limit (or limit (point-max)))) (condition-case nil (cond ((/= (point) - (progn (c-forward-syntactic-ws) (point))) + (progn (c-forward-syntactic-ws limit) (point))) ;; If we're at whitespace, count this as the token. t) ((eobp) nil) ((looking-at jump-syntax) - (goto-char (scan-sexps (point) 1)) + (goto-char (min limit (scan-sexps (point) 1))) t) ((looking-at c-nonsymbol-token-regexp) - (goto-char (match-end 0)) + (goto-char (min (match-end 0) limit)) t) ((save-restriction (widen) |