diff options
| author | Alan Mackenzie | 2010-06-21 21:08:26 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2010-06-21 21:08:26 +0000 |
| commit | 43a91810d3264702000f57b820d8d4255cf212d9 (patch) | |
| tree | dd992a65e4922036167b10aae00b0107b797cbfe | |
| parent | b75ddb76f12d10476ae55e77ede7a89696e57255 (diff) | |
| download | emacs-43a91810d3264702000f57b820d8d4255cf212d9.tar.gz emacs-43a91810d3264702000f57b820d8d4255cf212d9.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 18 | ||||
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 32 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 14 |
4 files changed, 53 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a1776062cda..134ae96895a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,21 @@ | |||
| 1 | 2010-06-21 Alan Mackenzie <bug-cc-mode@gnu.org> | ||
| 2 | |||
| 3 | Fix an indentation bug: | ||
| 4 | |||
| 5 | * progmodes/cc-mode.el (c-common-init): Initialise c-new-BEG/END. | ||
| 6 | (c-neutralize-syntax-in-and-mark-CPP): c-new-BEG/END: Take account | ||
| 7 | of existing values. | ||
| 8 | |||
| 9 | * progmodes/cc-engine.el (c-clear-<-pair-props-if-match-after) | ||
| 10 | (c-clear->-pair-props-if-match-before): now return t when they've | ||
| 11 | cleared properties, nil otherwise. | ||
| 12 | (c-before-change-check-<>-operators): Set c-new-beg/end correctly | ||
| 13 | by taking account of the existing value. | ||
| 14 | |||
| 15 | * progmodes/cc-defs.el | ||
| 16 | (c-clear-char-property-with-value-function): Fix this to clear the | ||
| 17 | property rather than overwriting it with nil. | ||
| 18 | |||
| 1 | 2010-06-20 Chong Yidong <cyd@stupidchicken.com> | 19 | 2010-06-20 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 20 | ||
| 3 | * emacs-lisp/package.el (package-print-package): Add link to | 21 | * emacs-lisp/package.el (package-print-package): Add link to |
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 7eb0016ff43..e5e108106f1 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -1082,7 +1082,7 @@ been put there by c-put-char-property. POINT remains unchanged." | |||
| 1082 | (setq place (next-single-property-change place property nil to))) | 1082 | (setq place (next-single-property-change place property nil to))) |
| 1083 | (< place to)) | 1083 | (< place to)) |
| 1084 | (setq end-place (next-single-property-change place property nil to)) | 1084 | (setq end-place (next-single-property-change place property nil to)) |
| 1085 | (put-text-property place end-place property nil) | 1085 | (remove-text-properties place end-place (cons property nil)) |
| 1086 | ;; Do we have to do anything with stickiness here? | 1086 | ;; Do we have to do anything with stickiness here? |
| 1087 | (setq place end-place)))) | 1087 | (setq place end-place)))) |
| 1088 | 1088 | ||
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 1ee3c295fe1..9bbf82a0449 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -4985,7 +4985,8 @@ comment at the start of cc-engine.el for more info." | |||
| 4985 | ;; POS (default point) is at a < character. If it is both marked | 4985 | ;; POS (default point) is at a < character. If it is both marked |
| 4986 | ;; with open/close paren syntax-table property, and has a matching > | 4986 | ;; with open/close paren syntax-table property, and has a matching > |
| 4987 | ;; (also marked) which is after LIM, remove the property both from | 4987 | ;; (also marked) which is after LIM, remove the property both from |
| 4988 | ;; the current > and its partner. | 4988 | ;; the current > and its partner. Return t when this happens, nil |
| 4989 | ;; when it doesn't. | ||
| 4989 | (save-excursion | 4990 | (save-excursion |
| 4990 | (if pos | 4991 | (if pos |
| 4991 | (goto-char pos) | 4992 | (goto-char pos) |
| @@ -4998,13 +4999,15 @@ comment at the start of cc-engine.el for more info." | |||
| 4998 | (equal (c-get-char-property (1- (point)) 'syntax-table) | 4999 | (equal (c-get-char-property (1- (point)) 'syntax-table) |
| 4999 | c->-as-paren-syntax)) ; should always be true. | 5000 | c->-as-paren-syntax)) ; should always be true. |
| 5000 | (c-unmark-<->-as-paren (1- (point))) | 5001 | (c-unmark-<->-as-paren (1- (point))) |
| 5001 | (c-unmark-<->-as-paren pos))))) | 5002 | (c-unmark-<->-as-paren pos)) |
| 5003 | t))) | ||
| 5002 | 5004 | ||
| 5003 | (defun c-clear->-pair-props-if-match-before (lim &optional pos) | 5005 | (defun c-clear->-pair-props-if-match-before (lim &optional pos) |
| 5004 | ;; POS (default point) is at a > character. If it is both marked | 5006 | ;; POS (default point) is at a > character. If it is both marked |
| 5005 | ;; with open/close paren syntax-table property, and has a matching < | 5007 | ;; with open/close paren syntax-table property, and has a matching < |
| 5006 | ;; (also marked) which is before LIM, remove the property both from | 5008 | ;; (also marked) which is before LIM, remove the property both from |
| 5007 | ;; the current < and its partner. | 5009 | ;; the current < and its partner. Return t when this happens, nil |
| 5010 | ;; when it doesn't. | ||
| 5008 | (save-excursion | 5011 | (save-excursion |
| 5009 | (if pos | 5012 | (if pos |
| 5010 | (goto-char pos) | 5013 | (goto-char pos) |
| @@ -5017,7 +5020,8 @@ comment at the start of cc-engine.el for more info." | |||
| 5017 | (equal (c-get-char-property (point) 'syntax-table) | 5020 | (equal (c-get-char-property (point) 'syntax-table) |
| 5018 | c-<-as-paren-syntax)) ; should always be true. | 5021 | c-<-as-paren-syntax)) ; should always be true. |
| 5019 | (c-unmark-<->-as-paren (point)) | 5022 | (c-unmark-<->-as-paren (point)) |
| 5020 | (c-unmark-<->-as-paren pos))))) | 5023 | (c-unmark-<->-as-paren pos)) |
| 5024 | t))) | ||
| 5021 | 5025 | ||
| 5022 | (defun c-before-change-check-<>-operators (beg end) | 5026 | (defun c-before-change-check-<>-operators (beg end) |
| 5023 | ;; Unmark certain pairs of "< .... >" which are currently marked as | 5027 | ;; Unmark certain pairs of "< .... >" which are currently marked as |
| @@ -5040,25 +5044,39 @@ comment at the start of cc-engine.el for more info." | |||
| 5040 | ;; 2010-01-29. | 5044 | ;; 2010-01-29. |
| 5041 | (save-excursion | 5045 | (save-excursion |
| 5042 | (let ((beg-lit-limits (progn (goto-char beg) (c-literal-limits))) | 5046 | (let ((beg-lit-limits (progn (goto-char beg) (c-literal-limits))) |
| 5043 | (end-lit-limits (progn (goto-char end) (c-literal-limits)))) | 5047 | (end-lit-limits (progn (goto-char end) (c-literal-limits))) |
| 5048 | new-beg new-end need-new-beg need-new-end) | ||
| 5044 | ;; Locate the barrier before the changed region | 5049 | ;; Locate the barrier before the changed region |
| 5045 | (goto-char (if beg-lit-limits (car beg-lit-limits) beg)) | 5050 | (goto-char (if beg-lit-limits (car beg-lit-limits) beg)) |
| 5046 | (c-syntactic-skip-backward "^;{}" (max (- beg 2048) (point-min))) | 5051 | (c-syntactic-skip-backward "^;{}" (max (- beg 2048) (point-min))) |
| 5052 | (setq new-beg (point)) | ||
| 5047 | 5053 | ||
| 5048 | ;; Remove the syntax-table properties from each pertinent <...> pair. | 5054 | ;; Remove the syntax-table properties from each pertinent <...> pair. |
| 5049 | ;; Firsly, the ones with the < before beg and > after beg. | 5055 | ;; Firsly, the ones with the < before beg and > after beg. |
| 5050 | (while (c-search-forward-char-property 'category 'c-<-as-paren-syntax beg) | 5056 | (while (c-search-forward-char-property 'category 'c-<-as-paren-syntax beg) |
| 5051 | (c-clear-<-pair-props-if-match-after beg (1- (point)))) | 5057 | (if (c-clear-<-pair-props-if-match-after beg (1- (point))) |
| 5058 | (setq need-new-beg t))) | ||
| 5052 | 5059 | ||
| 5053 | ;; Locate the barrier after END. | 5060 | ;; Locate the barrier after END. |
| 5054 | (goto-char (if end-lit-limits (cdr end-lit-limits) end)) | 5061 | (goto-char (if end-lit-limits (cdr end-lit-limits) end)) |
| 5055 | (c-syntactic-re-search-forward "[;{}]" | 5062 | (c-syntactic-re-search-forward "[;{}]" |
| 5056 | (min (+ end 2048) (point-max)) 'end) | 5063 | (min (+ end 2048) (point-max)) 'end) |
| 5064 | (setq new-end (point)) | ||
| 5057 | 5065 | ||
| 5058 | ;; Remove syntax-table properties from the remaining pertinent <...> | 5066 | ;; Remove syntax-table properties from the remaining pertinent <...> |
| 5059 | ;; pairs, those with a > after end and < before end. | 5067 | ;; pairs, those with a > after end and < before end. |
| 5060 | (while (c-search-backward-char-property 'category 'c->-as-paren-syntax end) | 5068 | (while (c-search-backward-char-property 'category 'c->-as-paren-syntax end) |
| 5061 | (c-clear->-pair-props-if-match-before end))))) | 5069 | (if (c-clear->-pair-props-if-match-before end) |
| 5070 | (setq need-new-end t))) | ||
| 5071 | |||
| 5072 | ;; Extend the fontification region, if needed. | ||
| 5073 | (when need-new-beg | ||
| 5074 | (goto-char new-beg) | ||
| 5075 | (c-forward-syntactic-ws) | ||
| 5076 | (and (< (point) c-new-BEG) (setq c-new-BEG (point)))) | ||
| 5077 | |||
| 5078 | (when need-new-end | ||
| 5079 | (and (> new-end c-new-END) (setq c-new-END new-end)))))) | ||
| 5062 | 5080 | ||
| 5063 | 5081 | ||
| 5064 | 5082 | ||
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index ed17e6f34e6..9044b42a838 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -640,6 +640,8 @@ compatible with old code; callers should always specify it." | |||
| 640 | ;; Starting a mode is a sort of "change". So call the change functions... | 640 | ;; Starting a mode is a sort of "change". So call the change functions... |
| 641 | (save-restriction | 641 | (save-restriction |
| 642 | (widen) | 642 | (widen) |
| 643 | (setq c-new-BEG (point-min)) | ||
| 644 | (setq c-new-END (point-max)) | ||
| 643 | (save-excursion | 645 | (save-excursion |
| 644 | (if c-get-state-before-change-functions | 646 | (if c-get-state-before-change-functions |
| 645 | (mapc (lambda (fn) | 647 | (mapc (lambda (fn) |
| @@ -886,17 +888,19 @@ Note that the style variables are always made local to the buffer." | |||
| 886 | ;; inside a string, comment, or macro. | 888 | ;; inside a string, comment, or macro. |
| 887 | (goto-char c-old-BOM) ; already set to old start of macro or begg. | 889 | (goto-char c-old-BOM) ; already set to old start of macro or begg. |
| 888 | (setq c-new-BEG | 890 | (setq c-new-BEG |
| 889 | (if (setq limits (c-state-literal-at (point))) | 891 | (min c-new-BEG |
| 890 | (cdr limits) ; go forward out of any string or comment. | 892 | (if (setq limits (c-state-literal-at (point))) |
| 891 | (point))) | 893 | (cdr limits) ; go forward out of any string or comment. |
| 894 | (point)))) | ||
| 892 | 895 | ||
| 893 | (goto-char endd) | 896 | (goto-char endd) |
| 894 | (if (setq limits (c-state-literal-at (point))) | 897 | (if (setq limits (c-state-literal-at (point))) |
| 895 | (goto-char (car limits))) ; go backward out of any string or comment. | 898 | (goto-char (car limits))) ; go backward out of any string or comment. |
| 896 | (if (c-beginning-of-macro) | 899 | (if (c-beginning-of-macro) |
| 897 | (c-end-of-macro)) | 900 | (c-end-of-macro)) |
| 898 | (setq c-new-END (max (+ (- c-old-EOM old-len) (- endd begg)) | 901 | (setq c-new-END (max c-new-END |
| 899 | (point))) | 902 | (+ (- c-old-EOM old-len) (- endd begg)) |
| 903 | (point))) | ||
| 900 | 904 | ||
| 901 | ;; Clear all old relevant properties. | 905 | ;; Clear all old relevant properties. |
| 902 | (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1)) | 906 | (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1)) |