comparison lisp/progmodes/cc-align.el @ 30407:b88ff2eabd4e

(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.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 24 Jul 2000 11:12:40 +0000
parents 03befb219d03
children c7610b751e49
comparison
equal deleted inserted replaced
30406:4fe5cb975331 30407:b88ff2eabd4e
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
9 ;; Maintainer: bug-cc-mode@gnu.org 10 ;; Maintainer: bug-cc-mode@gnu.org
10 ;; Created: 22-Apr-1997 (split from cc-mode.el) 11 ;; Created: 22-Apr-1997 (split from cc-mode.el)
151 (re-search-forward "<<\\|>>" (c-point 'eol) 'move) 152 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
152 (goto-char (match-beginning 0)) 153 (goto-char (match-beginning 0))
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
157 158 initializers under each other. E.g:
158 Works with: inher-cont." 159
159 (save-excursion 160 class Foo: Foo::Foo (int a, int b):
160 (let ((eol (c-point 'eol)) 161 public Cyphr, Cyphr (a),
161 (here (point)) 162 public Bar <-> Bar (b) <- c-lineup-multi-inher
162 (langelem-col (c-langelem-col langelem))) 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."
173 (save-excursion
174 (let* ((eol (c-point 'eol))
175 (here (point))
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))
168 (- (current-column) langelem-col) 195 (- (current-column) langelem-col)
169 ))) 196 )))
622 (syntax c-syntactic-context) 649 (syntax c-syntactic-context)
623 langelem) 650 langelem)
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
632 (setq syntax nil) 659 (setq syntax nil)
633 (back-to-indentation) 660 (back-to-indentation)