Mercurial > emacs
changeset 109030:bfaf9e31b45e
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.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Mon, 21 Jun 2010 21:08:26 +0000 |
parents | 85a8c1358bb7 |
children | a52944b44517 f55bbc59cc75 |
files | lisp/ChangeLog lisp/progmodes/cc-defs.el lisp/progmodes/cc-engine.el lisp/progmodes/cc-mode.el |
diffstat | 4 files changed, 53 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Mon Jun 21 00:37:16 2010 -0700 +++ b/lisp/ChangeLog Mon Jun 21 21:08:26 2010 +0000 @@ -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
--- a/lisp/progmodes/cc-defs.el Mon Jun 21 00:37:16 2010 -0700 +++ b/lisp/progmodes/cc-defs.el Mon Jun 21 21:08:26 2010 +0000 @@ -1082,7 +1082,7 @@ (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))))
--- a/lisp/progmodes/cc-engine.el Mon Jun 21 00:37:16 2010 -0700 +++ b/lisp/progmodes/cc-engine.el Mon Jun 21 21:08:26 2010 +0000 @@ -4985,7 +4985,8 @@ ;; 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 @@ (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 @@ (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 @@ ;; 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))))))
--- a/lisp/progmodes/cc-mode.el Mon Jun 21 00:37:16 2010 -0700 +++ b/lisp/progmodes/cc-mode.el Mon Jun 21 21:08:26 2010 +0000 @@ -640,6 +640,8 @@ ;; 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 @@ ;; 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))