]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix an indentation bug:
authorAlan Mackenzie <acm@muc.de>
Mon, 21 Jun 2010 21:08:26 +0000 (21:08 +0000)
committerAlan Mackenzie <acm@muc.de>
Mon, 21 Jun 2010 21:08:26 +0000 (21:08 +0000)
progmodes/cc-mode.el (c-common-init): Initialise c-new-BEG/END.
(c-neutralize-syntax-in-and-mark-CPP): c-new-BEG/END: Take account
of existing values.

progmodes/cc-engine.el (c-clear-<-pair-props-if-match-after)
(c-clear->-pair-props-if-match-before): now return t when they've cleared
properties, nil otherwise.
(c-before-change-check-<>-operators): Set c-new-beg/end correctly by
taking account of the existing value.

progmodes/cc-defs.el (c-clear-char-property-with-value-function): Fix
this to clear the property rather than overwriting it with nil.

lisp/ChangeLog
lisp/progmodes/cc-defs.el
lisp/progmodes/cc-engine.el
lisp/progmodes/cc-mode.el

index a1776062cdabaa57e3834eb16bcb0a77cf458b39..134ae96895accdb4bcc3ea22e63bc6d293ac4631 100644 (file)
@@ -1,3 +1,21 @@
+2010-06-21  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+       Fix an indentation bug:
+
+       * progmodes/cc-mode.el (c-common-init): Initialise c-new-BEG/END.
+       (c-neutralize-syntax-in-and-mark-CPP): c-new-BEG/END: Take account
+       of existing values.
+
+       * progmodes/cc-engine.el (c-clear-<-pair-props-if-match-after)
+       (c-clear->-pair-props-if-match-before): now return t when they've
+       cleared properties, nil otherwise.
+       (c-before-change-check-<>-operators): Set c-new-beg/end correctly
+       by taking account of the existing value.
+
+       * progmodes/cc-defs.el
+       (c-clear-char-property-with-value-function): Fix this to clear the
+       property rather than overwriting it with nil.
+
 2010-06-20  Chong Yidong  <cyd@stupidchicken.com>
 
        * emacs-lisp/package.el (package-print-package): Add link to
index 7eb0016ff43046a058cbd198f715ff7b8e6f4b38..e5e108106f14bb66e07d7835b938cd1957a8b92f 100644 (file)
@@ -1082,7 +1082,7 @@ been put there by c-put-char-property.  POINT remains unchanged."
            (setq place (next-single-property-change place property nil to)))
          (< place to))
       (setq end-place (next-single-property-change place property nil to))
-      (put-text-property place end-place property nil)
+      (remove-text-properties place end-place (cons property nil))
       ;; Do we have to do anything with stickiness here?
       (setq place end-place))))
 
index 1ee3c295fe188835a420bc36abb51c3d96ac0fdd..9bbf82a044958866b4147405159f693dff89017b 100644 (file)
@@ -4985,7 +4985,8 @@ comment at the start of cc-engine.el for more info."
   ;; POS (default point) is at a < character.  If it is both marked
   ;; with open/close paren syntax-table property, and has a matching >
   ;; (also marked) which is after LIM, remove the property both from
-  ;; the current > and its partner.
+  ;; the current > and its partner.  Return t when this happens, nil
+  ;; when it doesn't.
   (save-excursion
     (if pos
        (goto-char pos)
@@ -4998,13 +4999,15 @@ comment at the start of cc-engine.el for more info."
                 (equal (c-get-char-property (1- (point)) 'syntax-table)
                        c->-as-paren-syntax)) ; should always be true.
        (c-unmark-<->-as-paren (1- (point)))
-       (c-unmark-<->-as-paren pos)))))
+       (c-unmark-<->-as-paren pos))
+      t)))
 
 (defun c-clear->-pair-props-if-match-before (lim &optional pos)
   ;; POS (default point) is at a > character.  If it is both marked
   ;; with open/close paren syntax-table property, and has a matching <
   ;; (also marked) which is before LIM, remove the property both from
-  ;; the current < and its partner.
+  ;; the current < and its partner.  Return t when this happens, nil
+  ;; when it doesn't.
   (save-excursion
     (if pos
        (goto-char pos)
@@ -5017,7 +5020,8 @@ comment at the start of cc-engine.el for more info."
                 (equal (c-get-char-property (point) 'syntax-table)
                        c-<-as-paren-syntax)) ; should always be true.
        (c-unmark-<->-as-paren (point))
-       (c-unmark-<->-as-paren pos)))))
+       (c-unmark-<->-as-paren pos))
+      t)))
 
 (defun c-before-change-check-<>-operators (beg end)
   ;; Unmark certain pairs of "< .... >" which are currently marked as
@@ -5040,25 +5044,39 @@ comment at the start of cc-engine.el for more info."
   ;; 2010-01-29.
   (save-excursion
     (let ((beg-lit-limits (progn (goto-char beg) (c-literal-limits)))
-         (end-lit-limits (progn (goto-char end) (c-literal-limits))))
+         (end-lit-limits (progn (goto-char end) (c-literal-limits)))
+         new-beg new-end need-new-beg need-new-end)
       ;; Locate the barrier before the changed region
       (goto-char  (if beg-lit-limits (car beg-lit-limits) beg))
       (c-syntactic-skip-backward "^;{}" (max (- beg 2048) (point-min)))
+      (setq new-beg (point))
 
       ;; Remove the syntax-table properties from each pertinent <...> pair.
       ;; Firsly, the ones with the < before beg and > after beg.
       (while (c-search-forward-char-property 'category 'c-<-as-paren-syntax beg)
-       (c-clear-<-pair-props-if-match-after beg (1- (point))))
+       (if (c-clear-<-pair-props-if-match-after beg (1- (point)))
+           (setq need-new-beg t)))
 
       ;; Locate the barrier after END.
       (goto-char (if end-lit-limits (cdr end-lit-limits) end))
       (c-syntactic-re-search-forward "[;{}]"
                                     (min (+ end 2048) (point-max)) 'end)
+      (setq new-end (point))
 
       ;; Remove syntax-table properties from the remaining pertinent <...>
       ;; pairs, those with a > after end and < before end.
       (while (c-search-backward-char-property 'category 'c->-as-paren-syntax end)
-       (c-clear->-pair-props-if-match-before end)))))
+       (if (c-clear->-pair-props-if-match-before end)
+           (setq need-new-end t)))
+
+      ;; Extend the fontification region, if needed.
+      (when need-new-beg
+       (goto-char new-beg)
+       (c-forward-syntactic-ws)
+       (and (< (point) c-new-BEG) (setq c-new-BEG (point))))
+
+      (when need-new-end
+       (and (> new-end c-new-END) (setq c-new-END new-end))))))
 
 
 
index ed17e6f34e6e78d8cdeca22c1d474bb5867370bc..9044b42a83892ea43e705bac7ec17da53cc5c779 100644 (file)
@@ -640,6 +640,8 @@ compatible with old code; callers should always specify it."
   ;; Starting a mode is a sort of "change".  So call the change functions...
   (save-restriction
     (widen)
+    (setq c-new-BEG (point-min))
+    (setq c-new-END (point-max))
     (save-excursion
       (if c-get-state-before-change-functions
          (mapc (lambda (fn)
@@ -886,17 +888,19 @@ Note that the style variables are always made local to the buffer."
     ;; inside a string, comment, or macro.
     (goto-char c-old-BOM)        ; already set to old start of macro or begg.
     (setq c-new-BEG
-         (if (setq limits (c-state-literal-at (point)))
-             (cdr limits)          ; go forward out of any string or comment.
-           (point)))
+         (min c-new-BEG
+              (if (setq limits (c-state-literal-at (point)))
+                  (cdr limits)     ; go forward out of any string or comment.
+                (point))))
 
     (goto-char endd)
     (if (setq limits (c-state-literal-at (point)))
        (goto-char (car limits)))  ; go backward out of any string or comment.
     (if (c-beginning-of-macro)
        (c-end-of-macro))
-    (setq c-new-END (max (+ (- c-old-EOM old-len) (- endd begg))
-                  (point)))
+    (setq c-new-END (max c-new-END
+                        (+ (- c-old-EOM old-len) (- endd begg))
+                        (point)))
 
     ;; Clear all old relevant properties.
     (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))