diff options
| author | Alan Mackenzie | 2008-10-07 13:14:17 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2008-10-07 13:14:17 +0000 |
| commit | 24f15006fe95c9ed0f14c6b03c1523ec904cb60b (patch) | |
| tree | 73cda4cb9dea7b50f71aefc779622503b9a5b632 | |
| parent | c074408120c453400b2ab1f085da9911f86f8996 (diff) | |
| download | emacs-24f15006fe95c9ed0f14c6b03c1523ec904cb60b.tar.gz emacs-24f15006fe95c9ed0f14c6b03c1523ec904cb60b.zip | |
(c-indent-region): Fix so that indenting a macro followed by blank lines
doesn't backslash the following non-blank line into the macro.
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 391e8b2cb56..86715acea14 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -3096,46 +3096,41 @@ non-nil." | |||
| 3096 | (c-parsing-error nil) | 3096 | (c-parsing-error nil) |
| 3097 | ;; shut up any echo msgs on indiv lines | 3097 | ;; shut up any echo msgs on indiv lines |
| 3098 | (c-echo-syntactic-information-p nil) | 3098 | (c-echo-syntactic-information-p nil) |
| 3099 | (in-macro (and c-auto-align-backslashes | 3099 | (macro-start |
| 3100 | (c-save-buffer-state () | 3100 | (and (c-save-buffer-state () |
| 3101 | (save-excursion (c-beginning-of-macro))) | 3101 | (save-excursion (c-beginning-of-macro))) |
| 3102 | start)) | 3102 | start)) |
| 3103 | (c-fix-backslashes nil) | 3103 | (c-fix-backslashes nil) |
| 3104 | syntax) | 3104 | syntax) |
| 3105 | (unwind-protect | 3105 | (unwind-protect |
| 3106 | (progn | 3106 | (progn |
| 3107 | (c-progress-init start end 'c-indent-region) | 3107 | (c-progress-init start end 'c-indent-region) |
| 3108 | (while (and (bolp) | 3108 | |
| 3109 | (while (and (bolp) ;; One line each time round the loop. | ||
| 3109 | (not (eobp)) | 3110 | (not (eobp)) |
| 3110 | (< (point) endmark)) | 3111 | (< (point) endmark)) |
| 3111 | ;; update progress | 3112 | ;; update progress |
| 3112 | (c-progress-update) | 3113 | (c-progress-update) |
| 3113 | ;; skip empty lines | 3114 | ;; skip empty lines |
| 3114 | (skip-chars-forward " \t\n") | 3115 | (unless (or (looking-at "\\s *$") |
| 3115 | (beginning-of-line) | 3116 | (and macro-start (looking-at "\\s *\\\\$"))) |
| 3116 | ;; Get syntax and indent. | 3117 | ;; Get syntax and indent. |
| 3117 | (c-save-buffer-state nil | 3118 | (c-save-buffer-state nil |
| 3118 | (setq syntax (c-guess-basic-syntax))) | 3119 | (setq syntax (c-guess-basic-syntax))) |
| 3119 | (if (and c-auto-align-backslashes | 3120 | (c-indent-line syntax t t)) |
| 3120 | (assq 'cpp-macro syntax)) | 3121 | |
| 3121 | ;; Record macro start. | 3122 | (if (assq 'cpp-macro syntax) ; New macro? |
| 3122 | (setq in-macro (point))) | 3123 | (setq macro-start (point)) |
| 3123 | (if in-macro | 3124 | (when (and macro-start ; End of old macro? |
| 3124 | (if (looking-at "\\s *\\\\$") | 3125 | c-auto-align-backslashes |
| 3125 | (forward-line) | 3126 | (not (eq (char-before (c-point 'eol)) ?\\))) |
| 3126 | (c-indent-line syntax t t) | 3127 | ;; Fixup macro backslashes. |
| 3127 | (if (progn (end-of-line) | 3128 | (c-backslash-region macro-start (c-point 'bonl) nil) |
| 3128 | (not (eq (char-before) ?\\))) | 3129 | (setq macro-start nil))) |
| 3129 | (progn | 3130 | (forward-line)) |
| 3130 | ;; Fixup macro backslashes. | 3131 | |
| 3131 | (forward-line) | 3132 | (if (and macro-start c-auto-align-backslashes) |
| 3132 | (c-backslash-region in-macro (point) nil) | 3133 | (c-backslash-region macro-start (c-point 'bopl) nil t))) |
| 3133 | (setq in-macro nil)) | ||
| 3134 | (forward-line))) | ||
| 3135 | (c-indent-line syntax t t) | ||
| 3136 | (forward-line))) | ||
| 3137 | (if in-macro | ||
| 3138 | (c-backslash-region in-macro (c-point 'bopl) nil t))) | ||
| 3139 | (set-marker endmark nil) | 3134 | (set-marker endmark nil) |
| 3140 | (c-progress-fini 'c-indent-region)) | 3135 | (c-progress-fini 'c-indent-region)) |
| 3141 | (c-echo-parsing-error quiet)) | 3136 | (c-echo-parsing-error quiet)) |