[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

indentation/alingment (was Re: dpkg-scanlibs)



On Mon, 26 Feb 2001, Jason Gunthorpe wrote:

> 
> On Mon, 26 Feb 2001, Joey Hess wrote:
> 
> > Er, sure you can. The bit of whitespace before "char" can be a tab, all
> > whitespace following it on successive lines should be spaces (or as a
> > general rule: indent with tabs, align with spaces). I've reformatted your
> > example above just like that, I think you'll find that the list lines up no
> > matter what your tab stop is.
> 
> Yes, if you can pull off such a delicate dance of tabstoppery. If most
> editors had a visual tab it might even be quite easy..
> 
> But that anyone but the most dedicated tab stop user would do that, I
> think is a little extreme..

Not if the indentation is done by the editor itself. Seems that the
standard cc-mode in emacs could not differentiate between alignment and
indentation, so I wrote a little patch for cc-engine.el. If tab-width is
set to c-basic-indent and indent-tabs-mode is on, this will give you tabs
for indentation and spaces for alignment.


==== cut here ====
2367a2368,2370
> ;; This will go into cc-vars.el
> (defcustom align-with-spaces t "Use spaces for alignment (not indentation)")
> 
2375a2379
>        (align 0)
2383a2388,2402
>       (if (and align-with-spaces
>              (string-match "-cont" (symbol-name (caar c-syntactic-context))))
>         (if syntax
>             (error "Cannot use arg syntax if align-with-spaces is on")
>           (save-excursion
>             (setq align indent)
>             (while (and
>                     (string-match "-cont"
>                                   (symbol-name (caar c-syntactic-context)))
>                     (> (point) (point-min)))
>               (beginning-of-line 0)
>               (setq c-syntactic-context (c-guess-basic-syntax)))
>             (setq indent
>                   (apply '+ (mapcar 'c-get-offset c-syntactic-context))))
>           (setq align (- align indent))))
2385c2404
<     (if (< (point) (c-point 'boi))
---
>     (cond ((> align 0)
2386a2406,2408
>          (insert (make-string align ? )))
>         ((< (point) (c-point 'boi))
>          (back-to-indentation)))
2391d2412
<       )




-- 
Manfred Wassmann
PGP and GnuPG public keys available at http://germany.keyserver.net
PGP: 24B81049 Fingerprint: D7 10 EE 2B 74 16 C0 64  B4 5F BA B2 90 29 3D AF
GPG: 6B299971 Fingerprint: A598 A41F 57A3 5D69 83D2  8027 1274 F8CD 6B29 9971
 +++  I18N ?  For international language set LANG=POSIX  +++




Reply to: