commit/cc-mode: 2 new changesets

[email protected]
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
2 new commits in cc-mode:

https://bitbucket.org/xemacs/cc-mode/commits/837026913414/
Changeset:   837026913414
User:        acm
Date:        2014-02-02 17:07:54
Summary:     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.

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.
Affected #:  1 file

diff -r c4ec2b121c78037c898bded82474eff79e1df0fb -r 8370269134143161981cb1bc137e228ffd968cb1 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -2221,7 +2221,8 @@
        ((and (not not-in-delimiter)	; inside a comment starter
 	     (not (bobp))
 	     (progn (backward-char)
-		    (looking-at c-comment-start-regexp)))
+		    (and (not (looking-at "\\s!"))
+			 (looking-at c-comment-start-regexp))))
 	(setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)
 	      co-st (point))
 	(forward-comment 1)
@@ -2554,8 +2555,11 @@
   ;; The return value is a list, one of the following:
   ;;
   ;; o - ('forward START-POINT) - scan forward from START-POINT,
-  ;;	 which is not less than the highest position in `c-state-cache' below here.
+  ;;	 which is not less than the highest position in `c-state-cache' below HERE,
+  ;;     which is after GOOD-POS.
   ;; o - ('backward nil) - scan backwards (from HERE).
+  ;; o - ('back-and-forward START-POINT) - like 'forward, but when HERE is earlier
+  ;;     than GOOD-POS.
   ;; o - ('IN-LIT nil) - point is inside the literal containing point-min.
   (let ((cache-pos (c-get-cache-scan-pos here))	; highest position below HERE in cache (or 1)
 	strategy	    ; 'forward, 'backward, or 'IN-LIT.
@@ -2570,9 +2574,9 @@
      ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting.
       (setq strategy 'backward))
      (t
-      (setq strategy 'forward
+      (setq strategy 'back-and-forward
 	    start-point cache-pos)))
-    (list strategy (and (eq strategy 'forward) start-point))))
+    (list strategy start-point)))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2844,9 +2848,10 @@
 
 (defun c-remove-stale-state-cache (start-point here pps-point)
   ;; Remove stale entries from the `c-cache-state', i.e. those which will
-  ;; not be in it when it is amended for position HERE.  Additionally, the
-  ;; "outermost" open-brace entry before HERE will be converted to a cons if
-  ;; the matching close-brace is scanned.
+  ;; not be in it when it is amended for position HERE.  This may involve
+  ;; replacing a CONS element for a brace pair containing HERE with its car.
+  ;; Additionally, the "outermost" open-brace entry before HERE will be
+  ;; converted to a cons if the matching close-brace is below HERE.
   ;;
   ;; START-POINT is a "maximal" "safe position" - there must be no open
   ;; parens/braces/brackets between START-POINT and HERE.
@@ -2857,7 +2862,7 @@
   ;; adjust it to get outside a string/comment.	 (Sorry about this!  The code
   ;; needs to be FAST).
   ;;
-  ;; Return a list (GOOD-POS SCAN-BACK-POS PPS-STATE), where
+  ;; Return a list (GOOD-POS SCAN-BACK-POS CONS-SEPARATED PPS-STATE), where
   ;; o - GOOD-POS is a position where the new value `c-state-cache' is known
   ;;   to be good (we aim for this to be as high as possible);
   ;; o - SCAN-BACK-POS, if not nil, indicates there may be a brace pair
@@ -2865,6 +2870,9 @@
   ;;   position to scan backwards from.  It is the position of the "{" of the
   ;;   last element to be removed from `c-state-cache', when that elt is a
   ;;   cons, otherwise nil.
+  ;; o - CONS-SEPARATED is t when a cons element in `c-state-cache' has been
+  ;;   replaced by its car because HERE lies inside the brace pair represented
+  ;;   by the cons.
   ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT.
   (save-excursion
     (save-restriction
@@ -2892,6 +2900,7 @@
 	     pos
 	     upper-lim	   ; ,beyond which `c-state-cache' entries are removed
 	     scan-back-pos
+	     cons-separated
 	     pair-beg pps-point-state target-depth)
 
 	;; Remove entries beyond HERE.  Also remove any entries inside
@@ -2913,7 +2922,8 @@
 		   (consp (car c-state-cache))
 		   (> (cdar c-state-cache) upper-lim))
 	  (setcar c-state-cache (caar c-state-cache))
-	  (setq scan-back-pos (car c-state-cache)))
+	  (setq scan-back-pos (car c-state-cache)
+		cons-separated t))
 
 	;; The next loop jumps forward out of a nested level of parens each
 	;; time round; the corresponding elements in `c-state-cache' are
@@ -2986,7 +2996,7 @@
 	  (setq c-state-cache (cons (cons pair-beg pos)
 				    c-state-cache)))
 
-	(list pos scan-back-pos pps-state)))))
+	(list pos scan-back-pos cons-separated pps-state)))))
 
 (defun c-remove-stale-state-cache-backwards (here)
   ;; Strip stale elements of `c-state-cache' by moving backwards through the
@@ -3271,6 +3281,7 @@
 		     ; are no open parens/braces between it and HERE.
 	 bopl-state
 	 res
+	 cons-separated
 	 scan-backward-pos scan-forward-p) ; used for 'backward.
     ;; If POINT-MIN has changed, adjust the cache
     (unless (= (point-min) c-state-point-min)
@@ -3283,13 +3294,15 @@
 
     ;; SCAN!
     (cond
-     ((eq strategy 'forward)
+     ((memq strategy '(forward back-and-forward))
       (setq res (c-remove-stale-state-cache start-point here here-bopl))
       (setq cache-pos (car res)
 	    scan-backward-pos (cadr res)
-	    bopl-state (car (cddr res))) ; will be nil if (< here-bopl
+	    cons-separated (car (cddr res)) 
+	    bopl-state (cadr (cddr res))) ; will be nil if (< here-bopl
 					; start-point)
-      (if scan-backward-pos
+      (if (and scan-backward-pos
+	       (or cons-separated (eq strategy 'forward))) ;scan-backward-pos
 	  (c-append-lower-brace-pair-to-state-cache scan-backward-pos here))
       (setq good-pos
 	    (c-append-to-state-cache cache-pos here))


https://bitbucket.org/xemacs/cc-mode/commits/ab3c6b891272/
Changeset:   ab3c6b891272
User:        acm
Date:        2014-02-09 13:18:32
Summary:     Fix c-invalidate-state-cache on narrowed buffers.
cc-defs.el (c-with-all-but-one-cpps-commented-out): Widen when setting
and clearing the CPP delimiter properties.
Affected #:  1 file

diff -r 8370269134143161981cb1bc137e228ffd968cb1 -r ab3c6b89127224a9d35c9e54cef3adb99e6a375f cc-defs.el
--- a/cc-defs.el
+++ b/cc-defs.el
@@ -1342,10 +1342,14 @@
   ;; suppressed.
   `(unwind-protect
        (c-save-buffer-state ()
-	 (c-clear-cpp-delimiters ,beg ,end)
+	 (save-restriction
+	   (widen)
+	   (c-clear-cpp-delimiters ,beg ,end))
 	 ,`(c-with-cpps-commented-out ,@forms))
      (c-save-buffer-state ()
-       (c-set-cpp-delimiters ,beg ,end))))
+       (save-restriction
+	 (widen)
+	 (c-set-cpp-delimiters ,beg ,end)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; The following macros are to be used only in `c-parse-state' and its

Repository URL: https://bitbucket.org/xemacs/cc-mode/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.