Mercurial > emacs
changeset 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 | 4fe5cb975331 |
children | e3e2c9051c5f |
files | lisp/progmodes/cc-align.el |
diffstat | 1 files changed, 37 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/cc-align.el Mon Jul 24 11:12:07 2000 +0000 +++ b/lisp/progmodes/cc-align.el Mon Jul 24 11:12:40 2000 +0000 @@ -1,8 +1,9 @@ ;;; cc-align.el --- custom indentation functions for CC Mode -;; Copyright (C) 1985,1987,1992-1999 Free Software Foundation, Inc. +;; Copyright (C) 1985,1987,1992-2000 Free Software Foundation, Inc. -;; Authors: 1998-1999 Barry A. Warsaw and Martin Stjernholm +;; Authors: 2000- Martin Stjernholm +;; 1998-1999 Barry A. Warsaw and Martin Stjernholm ;; 1992-1997 Barry A. Warsaw ;; 1987 Dave Detlefs and Stewart Clamen ;; 1985 Richard M. Stallman @@ -153,15 +154,41 @@ (- (current-column) langelem-col)))) (defun c-lineup-multi-inher (langelem) - "Line up the classes in C++ multiple inheritance clauses under each other. + "Line up the classes in C++ multiple inheritance clauses and member +initializers under each other. E.g: + +class Foo: Foo::Foo (int a, int b): + public Cyphr, Cyphr (a), + public Bar <-> Bar (b) <- c-lineup-multi-inher -Works with: inher-cont." +class Foo Foo::Foo (int a, int b) + : public Cyphr, : Cyphr (a), + public Bar <-> Bar (b) <- c-lineup-multi-inher + +class Foo Foo::Foo (int a, int b) + : public Cyphr : Cyphr (a) + , public Bar <-> , Bar (b) <- c-lineup-multi-inher + +Works with: inher-cont, member-init-cont." (save-excursion - (let ((eol (c-point 'eol)) - (here (point)) - (langelem-col (c-langelem-col langelem))) + (let* ((eol (c-point 'eol)) + (here (point)) + (char-after-ip (progn + (skip-chars-forward " \t") + (char-after))) + (langelem-col (c-langelem-col langelem))) + + ;; This kludge is necessary to support both inher-cont and + ;; member-init-cont, since they have different anchor positions. + (c-backward-syntactic-ws) + (when (eq (char-before) ?:) + (backward-char) + (c-backward-syntactic-ws)) + (skip-chars-forward "^:" eol) - (skip-chars-forward " \t:" eol) + (if (eq char-after-ip ?,) + (skip-chars-forward " \t" eol) + (skip-chars-forward " \t:" eol)) (if (or (eolp) (looking-at c-comment-start-regexp)) (c-forward-syntactic-ws here)) @@ -624,8 +651,8 @@ (while syntax (setq langelem (car (car syntax)) syntax (cdr syntax)) - ;; don't adjust comment-only lines - (cond ((eq langelem 'comment-intro) + ;; don't adjust macro or comment-only lines + (cond ((memq langelem '(cpp-macro comment-intro)) (setq syntax nil)) ((memq langelem non-top-levels) (save-excursion