aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorAlan Mackenzie2017-01-14 12:38:43 +0000
committerAlan Mackenzie2017-01-14 12:38:43 +0000
commita23974d6e62f660259409baadd848cf6f834d88b (patch)
tree2533ec7750591adfb4495f32aa77c5ea3e12f26f /lisp
parent877c525f4b98bc785f1bb0b50d70f72d09c80eb2 (diff)
downloademacs-a23974d6e62f660259409baadd848cf6f834d88b.tar.gz
emacs-a23974d6e62f660259409baadd848cf6f834d88b.zip
Correct c-parse-state-get-strategy for moving HERE backward into a macro.
* list/progmodes/c-engine.el (c-parse-state-get-strategy): When HERE is below its previous value, we chose strategy 'forward, and the new HERE is in a (different) macro, ensure the returned START-POINT is not above the start of the macro.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/cc-engine.el26
1 files changed, 20 insertions, 6 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 3077e0085d3..e84c4cebf69 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2931,11 +2931,23 @@ comment at the start of cc-engine.el for more info."
2931 ;; o - ('BOD START-POINT) - scan forwards from START-POINT, which is at the 2931 ;; o - ('BOD START-POINT) - scan forwards from START-POINT, which is at the
2932 ;; top level. 2932 ;; top level.
2933 ;; o - ('IN-LIT nil) - point is inside the literal containing point-min. 2933 ;; o - ('IN-LIT nil) - point is inside the literal containing point-min.
2934 (let ((cache-pos (c-get-cache-scan-pos here)) ; highest position below HERE in cache (or 1) 2934 (let* ((in-macro-start ; start of macro containing HERE or nil.
2935 BOD-pos ; position of 2nd BOD before HERE. 2935 (save-excursion
2936 strategy ; 'forward, 'backward, 'BOD, or 'IN-LIT. 2936 (goto-char here)
2937 start-point 2937 (and (c-beginning-of-macro)
2938 how-far) ; putative scanning distance. 2938 (point))))
2939 (changed-macro-start
2940 (and in-macro-start
2941 (not (and c-state-old-cpp-beg
2942 (= in-macro-start c-state-old-cpp-beg)))
2943 in-macro-start))
2944 (cache-pos (c-get-cache-scan-pos (if changed-macro-start
2945 (min changed-macro-start here)
2946 here))) ; highest suitable position in cache (or 1)
2947 BOD-pos ; position of 2nd BOD before HERE.
2948 strategy ; 'forward, 'backward, 'BOD, or 'IN-LIT.
2949 start-point
2950 how-far) ; putative scanning distance.
2939 (setq good-pos (or good-pos (c-state-get-min-scan-pos))) 2951 (setq good-pos (or good-pos (c-state-get-min-scan-pos)))
2940 (cond 2952 (cond
2941 ((< here (c-state-get-min-scan-pos)) 2953 ((< here (c-state-get-min-scan-pos))
@@ -2945,7 +2957,9 @@ comment at the start of cc-engine.el for more info."
2945 how-far 0)) 2957 how-far 0))
2946 ((<= good-pos here) 2958 ((<= good-pos here)
2947 (setq strategy 'forward 2959 (setq strategy 'forward
2948 start-point (max good-pos cache-pos) 2960 start-point (if changed-macro-start
2961 cache-pos
2962 (max good-pos cache-pos))
2949 how-far (- here start-point))) 2963 how-far (- here start-point)))
2950 ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting. 2964 ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting.
2951 (setq strategy 'backward 2965 (setq strategy 'backward