Patchwork qemu: add .exrc

login
register
mail settings
Submitter Michael S. Tsirkin
Date July 19, 2012, 2:29 p.m.
Message ID <20120719142949.GA14567@redhat.com>
Download mbox | patch
Permalink /patch/171953/
State New
Headers show

Comments

Michael S. Tsirkin - July 19, 2012, 2:29 p.m.
I've been using this to get correct indenting with vim
in qemu for a while, but it's a bit easier if we
put the settings in the central place.
Note that
1. you still need to enable 'exrc' and 'secure'
   options in your vimrc for these settings to take effect.
2. you can create a .vimrc file if 'exrc' is on but there's
   need to bypass this configuration.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 .exrc | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 .exrc
Peter Maydell - July 19, 2012, 3:11 p.m.
On 19 July 2012 15:29, Michael S. Tsirkin <mst@redhat.com> wrote:
> I've been using this to get correct indenting with vim
> in qemu for a while, but it's a bit easier if we
> put the settings in the central place.
> Note that
> 1. you still need to enable 'exrc' and 'secure'
>    options in your vimrc for these settings to take effect.
> 2. you can create a .vimrc file if 'exrc' is on but there's
>    need to bypass this configuration.

I think editor configs could reasonably go on the wiki somewhere
but I'm not sure they belong in our git repo...

-- PMM
Michael S. Tsirkin - July 19, 2012, 3:24 p.m.
On Thu, Jul 19, 2012 at 04:11:21PM +0100, Peter Maydell wrote:
> On 19 July 2012 15:29, Michael S. Tsirkin <mst@redhat.com> wrote:
> > I've been using this to get correct indenting with vim
> > in qemu for a while, but it's a bit easier if we
> > put the settings in the central place.
> > Note that
> > 1. you still need to enable 'exrc' and 'secure'
> >    options in your vimrc for these settings to take effect.
> > 2. you can create a .vimrc file if 'exrc' is on but there's
> >    need to bypass this configuration.
> 
> I think editor configs could reasonably go on the wiki somewhere
> but I'm not sure they belong in our git repo...
> 
> -- PMM

kvm people need to work on both qemu and kernel which
have different styles, so switching styles manually gets old quickly.
The benefit is more people will send patches in the correct style.
What's the harm?
Stefan Hajnoczi - July 20, 2012, 10:26 a.m.
On Thu, Jul 19, 2012 at 4:24 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Thu, Jul 19, 2012 at 04:11:21PM +0100, Peter Maydell wrote:
>> On 19 July 2012 15:29, Michael S. Tsirkin <mst@redhat.com> wrote:
>> > I've been using this to get correct indenting with vim
>> > in qemu for a while, but it's a bit easier if we
>> > put the settings in the central place.
>> > Note that
>> > 1. you still need to enable 'exrc' and 'secure'
>> >    options in your vimrc for these settings to take effect.
>> > 2. you can create a .vimrc file if 'exrc' is on but there's
>> >    need to bypass this configuration.
>>
>> I think editor configs could reasonably go on the wiki somewhere
>> but I'm not sure they belong in our git repo...
>>
>> -- PMM
>
> kvm people need to work on both qemu and kernel which
> have different styles, so switching styles manually gets old quickly.
> The benefit is more people will send patches in the correct style.
> What's the harm?

From my .vimrc:

au BufNewFile,BufRead */qemu/*.c,*/qemu/*.h,*/qemu/*.hx,*/qemu/*tool
setlocal ts=4 sw=4 et

I agree that it's useful to have this, just like .gitignore or
.gdbinit.  It makes developer's lives easier and encourages consistent
coding style.

Stefan
Peter Maydell - July 20, 2012, 10:34 a.m.
On 20 July 2012 11:26, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> From my .vimrc:
>
> au BufNewFile,BufRead */qemu/*.c,*/qemu/*.h,*/qemu/*.hx,*/qemu/*tool
> setlocal ts=4 sw=4 et

Basically I think editor preferences are a local matter which
can reasonably differ between different developers, so they
shouldn't be in the git repo.

(a) haven't you just demonstrated that even vim users have
different preferred settings?
(b) where do we stop? emacs? bbedit? there are a lot of editors
out there...

In any case, 3 settings clearly don't encompass the whole of
QEMU's coding style. The relevant bit of my .emacs tweaks about
20 different settings...

-- PMM
陳韋任 - July 20, 2012, 10:37 a.m.
> In any case, 3 settings clearly don't encompass the whole of
> QEMU's coding style. The relevant bit of my .emacs tweaks about
> 20 different settings...

  Just leave the coding style checking to checkpatch.pl, I think?

Regards,
chenwj
Michael S. Tsirkin - July 20, 2012, 11:02 a.m.
On Fri, Jul 20, 2012 at 11:34:21AM +0100, Peter Maydell wrote:
> On 20 July 2012 11:26, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > From my .vimrc:
> >
> > au BufNewFile,BufRead */qemu/*.c,*/qemu/*.h,*/qemu/*.hx,*/qemu/*tool
> > setlocal ts=4 sw=4 et
> 
> Basically I think editor preferences are a local matter which
> can reasonably differ between different developers, so they
> shouldn't be in the git repo.

This is why I simply set the shiftwidth and set indenting by space.
Clearly no "can reasonably differ" applies here.

> (a) haven't you just demonstrated that even vim users have
> different preferred settings?

No, it's the same with the addition of tabstop=4, which *is*
a matter of taste (how many spaces you want shown if you edit
a file with tabs, like a makefile).

> (b) where do we stop? emacs? bbedit? there are a lot of editors
> out there...

If people ask for it we can consider. I doubt it will be a real problem.

> In any case, 3 settings clearly don't encompass the whole of
> QEMU's coding style.
> The relevant bit of my .emacs tweaks about
> 20 different settings...
> 
> -- PMM

If you don't use vim why do you even care about this patch?

Patch

diff --git a/.exrc b/.exrc
new file mode 100644
index 0000000..1853616
--- /dev/null
+++ b/.exrc
@@ -0,0 +1,3 @@ 
+set expandtab
+set shiftwidth=4
+set smarttab