diff options
| author | Gerd Moellmann | 2000-07-24 11:12:40 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-07-24 11:12:40 +0000 |
| commit | c4052e8213c697fcaf3290d7322aa778e0d73913 (patch) | |
| tree | 3c960c0823c7b69ba78a895c6216cfa729331246 | |
| parent | b8ded7944c6e975c91001c2872364a87b68dc2db (diff) | |
| download | emacs-c4052e8213c697fcaf3290d7322aa778e0d73913.tar.gz emacs-c4052e8213c697fcaf3290d7322aa778e0d73913.zip | |
(c-lineup-multi-inher): Handle lines with
leading comma nicely. Extended to handle member initializers
too.
(c-gnu-impose-minimum): Don't impose minimum
indentation on cpp-macro lines.
| -rw-r--r-- | lisp/progmodes/cc-align.el | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el index 9244d6e4714..f63f4b59554 100644 --- a/lisp/progmodes/cc-align.el +++ b/lisp/progmodes/cc-align.el | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | ;;; cc-align.el --- custom indentation functions for CC Mode | 1 | ;;; cc-align.el --- custom indentation functions for CC Mode |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985,1987,1992-1999 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1985,1987,1992-2000 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Authors: 1998-1999 Barry A. Warsaw and Martin Stjernholm | 5 | ;; Authors: 2000- Martin Stjernholm |
| 6 | ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm | ||
| 6 | ;; 1992-1997 Barry A. Warsaw | 7 | ;; 1992-1997 Barry A. Warsaw |
| 7 | ;; 1987 Dave Detlefs and Stewart Clamen | 8 | ;; 1987 Dave Detlefs and Stewart Clamen |
| 8 | ;; 1985 Richard M. Stallman | 9 | ;; 1985 Richard M. Stallman |
| @@ -153,15 +154,41 @@ Works with: stream-op." | |||
| 153 | (- (current-column) langelem-col)))) | 154 | (- (current-column) langelem-col)))) |
| 154 | 155 | ||
| 155 | (defun c-lineup-multi-inher (langelem) | 156 | (defun c-lineup-multi-inher (langelem) |
| 156 | "Line up the classes in C++ multiple inheritance clauses under each other. | 157 | "Line up the classes in C++ multiple inheritance clauses and member |
| 158 | initializers under each other. E.g: | ||
| 157 | 159 | ||
| 158 | Works with: inher-cont." | 160 | class Foo: Foo::Foo (int a, int b): |
| 161 | public Cyphr, Cyphr (a), | ||
| 162 | public Bar <-> Bar (b) <- c-lineup-multi-inher | ||
| 163 | |||
| 164 | class Foo Foo::Foo (int a, int b) | ||
| 165 | : public Cyphr, : Cyphr (a), | ||
| 166 | public Bar <-> Bar (b) <- c-lineup-multi-inher | ||
| 167 | |||
| 168 | class Foo Foo::Foo (int a, int b) | ||
| 169 | : public Cyphr : Cyphr (a) | ||
| 170 | , public Bar <-> , Bar (b) <- c-lineup-multi-inher | ||
| 171 | |||
| 172 | Works with: inher-cont, member-init-cont." | ||
| 159 | (save-excursion | 173 | (save-excursion |
| 160 | (let ((eol (c-point 'eol)) | 174 | (let* ((eol (c-point 'eol)) |
| 161 | (here (point)) | 175 | (here (point)) |
| 162 | (langelem-col (c-langelem-col langelem))) | 176 | (char-after-ip (progn |
| 177 | (skip-chars-forward " \t") | ||
| 178 | (char-after))) | ||
| 179 | (langelem-col (c-langelem-col langelem))) | ||
| 180 | |||
| 181 | ;; This kludge is necessary to support both inher-cont and | ||
| 182 | ;; member-init-cont, since they have different anchor positions. | ||
| 183 | (c-backward-syntactic-ws) | ||
| 184 | (when (eq (char-before) ?:) | ||
| 185 | (backward-char) | ||
| 186 | (c-backward-syntactic-ws)) | ||
| 187 | |||
| 163 | (skip-chars-forward "^:" eol) | 188 | (skip-chars-forward "^:" eol) |
| 164 | (skip-chars-forward " \t:" eol) | 189 | (if (eq char-after-ip ?,) |
| 190 | (skip-chars-forward " \t" eol) | ||
| 191 | (skip-chars-forward " \t:" eol)) | ||
| 165 | (if (or (eolp) | 192 | (if (or (eolp) |
| 166 | (looking-at c-comment-start-regexp)) | 193 | (looking-at c-comment-start-regexp)) |
| 167 | (c-forward-syntactic-ws here)) | 194 | (c-forward-syntactic-ws here)) |
| @@ -624,8 +651,8 @@ indentation amount." | |||
| 624 | (while syntax | 651 | (while syntax |
| 625 | (setq langelem (car (car syntax)) | 652 | (setq langelem (car (car syntax)) |
| 626 | syntax (cdr syntax)) | 653 | syntax (cdr syntax)) |
| 627 | ;; don't adjust comment-only lines | 654 | ;; don't adjust macro or comment-only lines |
| 628 | (cond ((eq langelem 'comment-intro) | 655 | (cond ((memq langelem '(cpp-macro comment-intro)) |
| 629 | (setq syntax nil)) | 656 | (setq syntax nil)) |
| 630 | ((memq langelem non-top-levels) | 657 | ((memq langelem non-top-levels) |
| 631 | (save-excursion | 658 | (save-excursion |