Function: c-lineup-multi-inher

c-lineup-multi-inher is a byte-compiled function defined in cc-align.el.gz.

Signature

(c-lineup-multi-inher LANGELEM)

Documentation

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

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.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-align.el.gz
(defun c-lineup-multi-inher (langelem)
  "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

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
    (back-to-indentation)
    (let* ((eol (c-point 'eol))
	   (here (point))
	   (char-after-ip (char-after)))
      (if (c-langelem-pos langelem)
	  (goto-char (c-langelem-pos 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))

      (c-syntactic-re-search-forward ":" eol 'move)
      (if (looking-at c-syntactic-eol)
	  (c-forward-syntactic-ws here)
	(if (eq char-after-ip ?,)
	    (backward-char)
	  (skip-chars-forward " \t" eol)))
      (if (< (point) here)
	  (vector (current-column)))
      )))