Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #11545

Re: Indentation styles for namespaces?

From Miles Bader <miles@gnu.org>
Newsgroups comp.lang.c++
Subject Re: Indentation styles for namespaces?
Date 2011-11-17 08:15 +0900
Message-ID <87aa7vmzfq.fsf@catnip.gol.com> (permalink)
References <slrnjc0dmk.1bk.grahn+nntp@frailea.sa.invalid> <4ec0dbf9$0$7610$9b4e6d93@newsspool1.arcor-online.net>

Show all headers | View raw


Marcel Müller <news.5.maazl@spamgourmet.com> writes:
>> I can certainly understand that some feel the indent is a waste of
>> horizontal space, but it's really the way I (and my editor, Emacs)
>> prefer it.
>
> Who cares, what /your/ editor prefers?

You can tell Emacs not to indent namespaces by putting:

  (add-to-list 'c++-mode-hook (lambda () (c-set-offset 'innamespace 0)))

in your ~/.emacs file.

More clever would be to add a hook that looks at the "namespace" line,
and bases its decision to indent or not on some sort of context, e.g.,
if there's a comment saying "// noindent", it wouldn't indent (or the
opposite if not indenting is more common).  [Basically you write a
lisp function, and use it's name in place of the "0" above; see the
info node "(ccmode) c-offsets-alist" for details.]

As such conventions often vary among _projects_, an altnerative would
be to place an appropriate ".dir-locals.el" file in the root of source
trees; see the info node "(emacs) Directory Variables" for details.

-Miles

-- 
Any man who is a triangle, has thee right, when in Cartesian Space,
to have angles, which when summed, come to know more, nor no less,
than nine score degrees, should he so wish.  [TEMPLE OV THEE LEMUR]

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Indentation styles for namespaces? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-13 21:29 +0000
  Re: Indentation styles for namespaces? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2011-11-14 00:39 +0100
    Re: Indentation styles for namespaces? drew@furrfu.invalid (Drew Lawson) - 2011-11-18 18:09 +0000
  Re: Indentation styles for namespaces? Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-11-14 10:14 +0100
    Re: Indentation styles for namespaces? Miles Bader <miles@gnu.org> - 2011-11-17 08:15 +0900

csiph-web