diff options
| author | Alan Mackenzie | 2014-02-02 16:28:52 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2014-02-02 16:28:52 +0000 |
| commit | 99f7b0a6d66398d87368448346de104fe8b6531b (patch) | |
| tree | fafc989ad34d0495e648073bcab6a566ad30e2dc | |
| parent | f0a105764675324e5ea1f64f5592ab79a9da001f (diff) | |
| download | emacs-99f7b0a6d66398d87368448346de104fe8b6531b.tar.gz emacs-99f7b0a6d66398d87368448346de104fe8b6531b.zip | |
c-parse-state. Don't "append-lower-brace-pair" in certain
circumstances. Also fix an obscure bug where "\\s!" shouldn't be
recognised as a comment.
* progmodes/cc-engine.el (c-state-pp-to-literal): Check for "\\s!"
as well as normal comment starter.
(c-parse-state-get-strategy): Extra return possibility
'back-and-forward.
(c-remove-stale-state-cache): Extra element CONS-SEPARATED in
return value list to indicate replacement of a brace-pair cons
with its car.
(c-parse-state-1): With 'back-and-forward, only call
c-append-lower-brace-pair-to state-cache when cons-separated.
| -rw-r--r-- | lisp/ChangeLog | 16 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 39 |
2 files changed, 42 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 03d09cc8aaf..737f54d41e3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2014-02-02 Alan Mackenzie <bug-cc-mode@gnu.org> | ||
| 2 | |||
| 3 | c-parse-state. Don't "append-lower-brace-pair" in certain | ||
| 4 | circumstances. Also fix an obscure bug where "\\s!" shouldn't be | ||
| 5 | recognised as a comment. | ||
| 6 | |||
| 7 | * progmodes/cc-engine.el (c-state-pp-to-literal): Check for "\\s!" | ||
| 8 | as well as normal comment starter. | ||
| 9 | (c-parse-state-get-strategy): Extra return possibility | ||
| 10 | 'back-and-forward. | ||
| 11 | (c-remove-stale-state-cache): Extra element CONS-SEPARATED in | ||
| 12 | return value list to indicate replacement of a brace-pair cons | ||
| 13 | with its car. | ||
| 14 | (c-parse-state-1): With 'back-and-forward, only call | ||
| 15 | c-append-lower-brace-pair-to state-cache when cons-separated. | ||
| 16 | |||
| 1 | 2014-02-02 Jan Djärv <jan.h.d@swipnet.se> | 17 | 2014-02-02 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 18 | ||
| 3 | * term/ns-win.el (ns-suspend-error): New function. | 19 | * term/ns-win.el (ns-suspend-error): New function. |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 24ca6ca7ea4..f86e4b2c48a 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -2219,7 +2219,8 @@ comment at the start of cc-engine.el for more info." | |||
| 2219 | ((and (not not-in-delimiter) ; inside a comment starter | 2219 | ((and (not not-in-delimiter) ; inside a comment starter |
| 2220 | (not (bobp)) | 2220 | (not (bobp)) |
| 2221 | (progn (backward-char) | 2221 | (progn (backward-char) |
| 2222 | (looking-at c-comment-start-regexp))) | 2222 | (and (not (looking-at "\\s!")) |
| 2223 | (looking-at c-comment-start-regexp)))) | ||
| 2223 | (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++) | 2224 | (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++) |
| 2224 | co-st (point)) | 2225 | co-st (point)) |
| 2225 | (forward-comment 1) | 2226 | (forward-comment 1) |
| @@ -2552,8 +2553,11 @@ comment at the start of cc-engine.el for more info." | |||
| 2552 | ;; The return value is a list, one of the following: | 2553 | ;; The return value is a list, one of the following: |
| 2553 | ;; | 2554 | ;; |
| 2554 | ;; o - ('forward START-POINT) - scan forward from START-POINT, | 2555 | ;; o - ('forward START-POINT) - scan forward from START-POINT, |
| 2555 | ;; which is not less than the highest position in `c-state-cache' below here. | 2556 | ;; which is not less than the highest position in `c-state-cache' below HERE, |
| 2557 | ;; which is after GOOD-POS. | ||
| 2556 | ;; o - ('backward nil) - scan backwards (from HERE). | 2558 | ;; o - ('backward nil) - scan backwards (from HERE). |
| 2559 | ;; o - ('back-and-forward START-POINT) - like 'forward, but when HERE is earlier | ||
| 2560 | ;; than GOOD-POS. | ||
| 2557 | ;; o - ('IN-LIT nil) - point is inside the literal containing point-min. | 2561 | ;; o - ('IN-LIT nil) - point is inside the literal containing point-min. |
| 2558 | (let ((cache-pos (c-get-cache-scan-pos here)) ; highest position below HERE in cache (or 1) | 2562 | (let ((cache-pos (c-get-cache-scan-pos here)) ; highest position below HERE in cache (or 1) |
| 2559 | strategy ; 'forward, 'backward, or 'IN-LIT. | 2563 | strategy ; 'forward, 'backward, or 'IN-LIT. |
| @@ -2568,9 +2572,9 @@ comment at the start of cc-engine.el for more info." | |||
| 2568 | ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting. | 2572 | ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting. |
| 2569 | (setq strategy 'backward)) | 2573 | (setq strategy 'backward)) |
| 2570 | (t | 2574 | (t |
| 2571 | (setq strategy 'forward | 2575 | (setq strategy 'back-and-forward |
| 2572 | start-point cache-pos))) | 2576 | start-point cache-pos))) |
| 2573 | (list strategy (and (eq strategy 'forward) start-point)))) | 2577 | (list strategy start-point))) |
| 2574 | 2578 | ||
| 2575 | 2579 | ||
| 2576 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2580 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -2842,9 +2846,10 @@ comment at the start of cc-engine.el for more info." | |||
| 2842 | 2846 | ||
| 2843 | (defun c-remove-stale-state-cache (start-point here pps-point) | 2847 | (defun c-remove-stale-state-cache (start-point here pps-point) |
| 2844 | ;; Remove stale entries from the `c-cache-state', i.e. those which will | 2848 | ;; Remove stale entries from the `c-cache-state', i.e. those which will |
| 2845 | ;; not be in it when it is amended for position HERE. Additionally, the | 2849 | ;; not be in it when it is amended for position HERE. This may involve |
| 2846 | ;; "outermost" open-brace entry before HERE will be converted to a cons if | 2850 | ;; replacing a CONS element for a brace pair containing HERE with its car. |
| 2847 | ;; the matching close-brace is scanned. | 2851 | ;; Additionally, the "outermost" open-brace entry before HERE will be |
| 2852 | ;; converted to a cons if the matching close-brace is below HERE. | ||
| 2848 | ;; | 2853 | ;; |
| 2849 | ;; START-POINT is a "maximal" "safe position" - there must be no open | 2854 | ;; START-POINT is a "maximal" "safe position" - there must be no open |
| 2850 | ;; parens/braces/brackets between START-POINT and HERE. | 2855 | ;; parens/braces/brackets between START-POINT and HERE. |
| @@ -2855,7 +2860,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2855 | ;; adjust it to get outside a string/comment. (Sorry about this! The code | 2860 | ;; adjust it to get outside a string/comment. (Sorry about this! The code |
| 2856 | ;; needs to be FAST). | 2861 | ;; needs to be FAST). |
| 2857 | ;; | 2862 | ;; |
| 2858 | ;; Return a list (GOOD-POS SCAN-BACK-POS PPS-STATE), where | 2863 | ;; Return a list (GOOD-POS SCAN-BACK-POS CONS-SEPARATED PPS-STATE), where |
| 2859 | ;; o - GOOD-POS is a position where the new value `c-state-cache' is known | 2864 | ;; o - GOOD-POS is a position where the new value `c-state-cache' is known |
| 2860 | ;; to be good (we aim for this to be as high as possible); | 2865 | ;; to be good (we aim for this to be as high as possible); |
| 2861 | ;; o - SCAN-BACK-POS, if not nil, indicates there may be a brace pair | 2866 | ;; o - SCAN-BACK-POS, if not nil, indicates there may be a brace pair |
| @@ -2863,6 +2868,9 @@ comment at the start of cc-engine.el for more info." | |||
| 2863 | ;; position to scan backwards from. It is the position of the "{" of the | 2868 | ;; position to scan backwards from. It is the position of the "{" of the |
| 2864 | ;; last element to be removed from `c-state-cache', when that elt is a | 2869 | ;; last element to be removed from `c-state-cache', when that elt is a |
| 2865 | ;; cons, otherwise nil. | 2870 | ;; cons, otherwise nil. |
| 2871 | ;; o - CONS-SEPARATED is t when a cons element in `c-state-cache' has been | ||
| 2872 | ;; replaced by its car because HERE lies inside the brace pair represented | ||
| 2873 | ;; by the cons. | ||
| 2866 | ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT. | 2874 | ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT. |
| 2867 | (save-excursion | 2875 | (save-excursion |
| 2868 | (save-restriction | 2876 | (save-restriction |
| @@ -2890,6 +2898,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2890 | pos | 2898 | pos |
| 2891 | upper-lim ; ,beyond which `c-state-cache' entries are removed | 2899 | upper-lim ; ,beyond which `c-state-cache' entries are removed |
| 2892 | scan-back-pos | 2900 | scan-back-pos |
| 2901 | cons-separated | ||
| 2893 | pair-beg pps-point-state target-depth) | 2902 | pair-beg pps-point-state target-depth) |
| 2894 | 2903 | ||
| 2895 | ;; Remove entries beyond HERE. Also remove any entries inside | 2904 | ;; Remove entries beyond HERE. Also remove any entries inside |
| @@ -2911,7 +2920,8 @@ comment at the start of cc-engine.el for more info." | |||
| 2911 | (consp (car c-state-cache)) | 2920 | (consp (car c-state-cache)) |
| 2912 | (> (cdar c-state-cache) upper-lim)) | 2921 | (> (cdar c-state-cache) upper-lim)) |
| 2913 | (setcar c-state-cache (caar c-state-cache)) | 2922 | (setcar c-state-cache (caar c-state-cache)) |
| 2914 | (setq scan-back-pos (car c-state-cache))) | 2923 | (setq scan-back-pos (car c-state-cache) |
| 2924 | cons-separated t)) | ||
| 2915 | 2925 | ||
| 2916 | ;; The next loop jumps forward out of a nested level of parens each | 2926 | ;; The next loop jumps forward out of a nested level of parens each |
| 2917 | ;; time round; the corresponding elements in `c-state-cache' are | 2927 | ;; time round; the corresponding elements in `c-state-cache' are |
| @@ -2983,7 +2993,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2983 | (setq c-state-cache (cons (cons pair-beg pos) | 2993 | (setq c-state-cache (cons (cons pair-beg pos) |
| 2984 | c-state-cache))) | 2994 | c-state-cache))) |
| 2985 | 2995 | ||
| 2986 | (list pos scan-back-pos pps-state))))) | 2996 | (list pos scan-back-pos cons-separated pps-state))))) |
| 2987 | 2997 | ||
| 2988 | (defun c-remove-stale-state-cache-backwards (here) | 2998 | (defun c-remove-stale-state-cache-backwards (here) |
| 2989 | ;; Strip stale elements of `c-state-cache' by moving backwards through the | 2999 | ;; Strip stale elements of `c-state-cache' by moving backwards through the |
| @@ -3265,6 +3275,7 @@ comment at the start of cc-engine.el for more info." | |||
| 3265 | ; are no open parens/braces between it and HERE. | 3275 | ; are no open parens/braces between it and HERE. |
| 3266 | bopl-state | 3276 | bopl-state |
| 3267 | res | 3277 | res |
| 3278 | cons-separated | ||
| 3268 | scan-backward-pos scan-forward-p) ; used for 'backward. | 3279 | scan-backward-pos scan-forward-p) ; used for 'backward. |
| 3269 | ;; If POINT-MIN has changed, adjust the cache | 3280 | ;; If POINT-MIN has changed, adjust the cache |
| 3270 | (unless (= (point-min) c-state-point-min) | 3281 | (unless (= (point-min) c-state-point-min) |
| @@ -3277,13 +3288,15 @@ comment at the start of cc-engine.el for more info." | |||
| 3277 | 3288 | ||
| 3278 | ;; SCAN! | 3289 | ;; SCAN! |
| 3279 | (cond | 3290 | (cond |
| 3280 | ((eq strategy 'forward) | 3291 | ((memq strategy '(forward back-and-forward)) |
| 3281 | (setq res (c-remove-stale-state-cache start-point here here-bopl)) | 3292 | (setq res (c-remove-stale-state-cache start-point here here-bopl)) |
| 3282 | (setq cache-pos (car res) | 3293 | (setq cache-pos (car res) |
| 3283 | scan-backward-pos (cadr res) | 3294 | scan-backward-pos (cadr res) |
| 3284 | bopl-state (car (cddr res))) ; will be nil if (< here-bopl | 3295 | cons-separated (car (cddr res)) |
| 3296 | bopl-state (cadr (cddr res))) ; will be nil if (< here-bopl | ||
| 3285 | ; start-point) | 3297 | ; start-point) |
| 3286 | (if scan-backward-pos | 3298 | (if (and scan-backward-pos |
| 3299 | (or cons-separated (eq strategy 'forward))) ;scan-backward-pos | ||
| 3287 | (c-append-lower-brace-pair-to-state-cache scan-backward-pos here)) | 3300 | (c-append-lower-brace-pair-to-state-cache scan-backward-pos here)) |
| 3288 | (setq good-pos | 3301 | (setq good-pos |
| 3289 | (c-append-to-state-cache cache-pos here)) | 3302 | (c-append-to-state-cache cache-pos here)) |