revised proposal: remove all indentation directives

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

 



Daniel Veillard <veillard@xxxxxxxxxx> wrote:
> On Thu, Apr 10, 2008 at 08:42:08AM +0100, Richard W.M. Jones wrote:
>>
>> I also say you should go for the full patch.
>
>   But please keep tabks in ChangeLog for indenting,

Glad we agree.
There's one more detail.
Some files (e.g. libvirt.c) end with these lines:

/*
 * vim: set tabstop=4:
 * vim: set shiftwidth=4:
 * vim: set expandtab:
 */
/*
 * Local variables:
 *  indent-tabs-mode: nil
 *  c-indent-level: 4
 *  c-basic-offset: 4
 *  tab-width: 4
 * End:
 */

while others (e.g., conf.c) only have the latter block.
I'm removing all of these lines regardless:

 *  tab-width: 4
 * vim: set tabstop=4:

The question is what directives to add to files that currently have none,
and how to normalize the existing things.  First of all, regarding the
vim: directives, they don't serve any purpose, by default.  It helps to
know that they're interpreted only when Vim's modeline option is enabled.
Some distros disable that option because honoring those directives poses
a security risk.  (Vim's default is to disable modeline for root, and
Debian's Vim does that for all users).  Even if you turn on the modeline
option, Vim searches only the first and last 5 lines by default, when
looking for directives, and so the ones above aren't ever honored.

So, unless someone objects soon, I'll remove all vim: directives.
-------------------------------------------------------

As for the emacs directives, I'm divided.
On one hand, it's nice to record project-wide guidelines in a way
that's hard to miss.  On the other, it's a shame to require this
mark-up in every single .c and .h file.

While I was planning to add 7 lines to each of the remaining 24 files,
consider this alternative:

Remove all such directives and instead instruct (via HACKING or some
such file) developers to use a small .emacs snippet that defines the
desired style for code in a libvirt/ subdir.  Then, the style would be
defined in just one place, in case we ever change it.

For example, add this to your Emacs start-up file:

;;; When editing C in libvirt, indent using spaces, not TABs.
(add-hook 'c-mode-hook
	  '(lambda () (if (string-match "/libvirt/" (buffer-file-name))
			  (setq indent-tabs-mode nil))))

and it has the same effect as inserting the following comment at the
end of every file (assuming your working directory name matches):

/*
 * Local variables:
 *  indent-tabs-mode: nil
 * End:
 */

I'm sure you can do something similar in Vim.

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]