* [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style @ 2015-06-04 13:30 Daniel P. Berrange 2015-06-04 13:41 ` Peter Maydell 0 siblings, 1 reply; 11+ messages in thread From: Daniel P. Berrange @ 2015-06-04 13:30 UTC (permalink / raw) To: qemu-devel; +Cc: qemu-trivial, John Snow, Markus Armbruster Some default emacs setups indent by 2 spaces and uses tabs which is counter to the QEMU coding style rules. Adding a .dir-locals.el file in the top level of the GIT repo will inform emacs about the QEMU coding style, and so assist contributors in avoiding common style mistakes before they submit patches. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- .dir-locals.el | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..3ac0cfc --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,2 @@ +((c-mode . ((c-file-style . "stroustrup") + (indent-tabs-mode . nil)))) -- 2.4.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-06-04 13:30 [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style Daniel P. Berrange @ 2015-06-04 13:41 ` Peter Maydell 2015-06-04 14:15 ` Daniel P. Berrange 2015-06-18 9:28 ` Markus Armbruster 0 siblings, 2 replies; 11+ messages in thread From: Peter Maydell @ 2015-06-04 13:41 UTC (permalink / raw) To: Daniel P. Berrange Cc: QEMU Trivial, John Snow, QEMU Developers, Markus Armbruster On 4 June 2015 at 14:30, Daniel P. Berrange <berrange@redhat.com> wrote: > Some default emacs setups indent by 2 spaces and uses tabs > which is counter to the QEMU coding style rules. Adding a > .dir-locals.el file in the top level of the GIT repo will > inform emacs about the QEMU coding style, and so assist > contributors in avoiding common style mistakes before > they submit patches. > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com> > --- > .dir-locals.el | 2 ++ > 1 file changed, 2 insertions(+) > create mode 100644 .dir-locals.el > > diff --git a/.dir-locals.el b/.dir-locals.el > new file mode 100644 > index 0000000..3ac0cfc > --- /dev/null > +++ b/.dir-locals.el > @@ -0,0 +1,2 @@ > +((c-mode . ((c-file-style . "stroustrup") > + (indent-tabs-mode . nil)))) My .emacs defines a style like this: (defconst qemu-c-style '((indent-tabs-mode . nil) (c-basic-offset . 4) (tab-width . 8) (c-comment-only-line-offset . 0) (c-offsets-alist . ((statement-block-intro . +) (substatement-open . 0) (label . 0) (statement-cont . +) (innamespace . 0) (inline-open . 0) )) (c-hanging-braces-alist . ((brace-list-open) (brace-list-intro) (brace-list-entry) (brace-list-close) (brace-entry-open) (block-close . c-snug-do-while) ;; structs have hanging braces on open (class-open . (after)) ;; ditto if statements (substatement-open . (after)) ;; and no auto newline at the end (class-close) )) ) "QEMU C Programming Style") which is a superset of Stroustrup and gets a few more corner cases right, I think. -- PMM ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-06-04 13:41 ` Peter Maydell @ 2015-06-04 14:15 ` Daniel P. Berrange 2015-06-18 9:28 ` Markus Armbruster 1 sibling, 0 replies; 11+ messages in thread From: Daniel P. Berrange @ 2015-06-04 14:15 UTC (permalink / raw) To: Peter Maydell; +Cc: QEMU Trivial, John Snow, QEMU Developers, Markus Armbruster On Thu, Jun 04, 2015 at 02:41:42PM +0100, Peter Maydell wrote: > On 4 June 2015 at 14:30, Daniel P. Berrange <berrange@redhat.com> wrote: > > Some default emacs setups indent by 2 spaces and uses tabs > > which is counter to the QEMU coding style rules. Adding a > > .dir-locals.el file in the top level of the GIT repo will > > inform emacs about the QEMU coding style, and so assist > > contributors in avoiding common style mistakes before > > they submit patches. > > > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com> > > --- > > .dir-locals.el | 2 ++ > > 1 file changed, 2 insertions(+) > > create mode 100644 .dir-locals.el > > > > diff --git a/.dir-locals.el b/.dir-locals.el > > new file mode 100644 > > index 0000000..3ac0cfc > > --- /dev/null > > +++ b/.dir-locals.el > > @@ -0,0 +1,2 @@ > > +((c-mode . ((c-file-style . "stroustrup") > > + (indent-tabs-mode . nil)))) > > My .emacs defines a style like this: > > (defconst qemu-c-style > '((indent-tabs-mode . nil) > (c-basic-offset . 4) > (tab-width . 8) > (c-comment-only-line-offset . 0) > (c-offsets-alist . ((statement-block-intro . +) > (substatement-open . 0) > (label . 0) > (statement-cont . +) > (innamespace . 0) > (inline-open . 0) > )) > (c-hanging-braces-alist . > ((brace-list-open) > (brace-list-intro) > (brace-list-entry) > (brace-list-close) > (brace-entry-open) > (block-close . c-snug-do-while) > ;; structs have hanging braces on open > (class-open . (after)) > ;; ditto if statements > (substatement-open . (after)) > ;; and no auto newline at the end > (class-close) > )) > ) > "QEMU C Programming Style") > > which is a superset of Stroustrup and gets a few more > corner cases right, I think. I'm not fussed about what we use as long as we have something, so I'm happy to do a v3 using your suggested style instead :) Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-06-04 13:41 ` Peter Maydell 2015-06-04 14:15 ` Daniel P. Berrange @ 2015-06-18 9:28 ` Markus Armbruster 2015-06-18 12:47 ` Peter Maydell 1 sibling, 1 reply; 11+ messages in thread From: Markus Armbruster @ 2015-06-18 9:28 UTC (permalink / raw) To: Peter Maydell; +Cc: QEMU Trivial, John Snow, QEMU Developers Peter Maydell <peter.maydell@linaro.org> writes: > On 4 June 2015 at 14:30, Daniel P. Berrange <berrange@redhat.com> wrote: >> Some default emacs setups indent by 2 spaces and uses tabs >> which is counter to the QEMU coding style rules. Adding a >> .dir-locals.el file in the top level of the GIT repo will >> inform emacs about the QEMU coding style, and so assist >> contributors in avoiding common style mistakes before >> they submit patches. >> >> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> >> --- >> .dir-locals.el | 2 ++ >> 1 file changed, 2 insertions(+) >> create mode 100644 .dir-locals.el >> >> diff --git a/.dir-locals.el b/.dir-locals.el >> new file mode 100644 >> index 0000000..3ac0cfc >> --- /dev/null >> +++ b/.dir-locals.el >> @@ -0,0 +1,2 @@ >> +((c-mode . ((c-file-style . "stroustrup") >> + (indent-tabs-mode . nil)))) > > My .emacs defines a style like this: > > (defconst qemu-c-style > '((indent-tabs-mode . nil) > (c-basic-offset . 4) > (tab-width . 8) > (c-comment-only-line-offset . 0) > (c-offsets-alist . ((statement-block-intro . +) > (substatement-open . 0) > (label . 0) > (statement-cont . +) > (innamespace . 0) > (inline-open . 0) > )) > (c-hanging-braces-alist . > ((brace-list-open) > (brace-list-intro) > (brace-list-entry) > (brace-list-close) > (brace-entry-open) > (block-close . c-snug-do-while) > ;; structs have hanging braces on open > (class-open . (after)) > ;; ditto if statements > (substatement-open . (after)) > ;; and no auto newline at the end > (class-close) > )) > ) > "QEMU C Programming Style") > > which is a superset of Stroustrup and gets a few more > corner cases right, I think. Trouble is I can't figure out how to get that into Emacs using nothing but files in the QEMU tree. From within the tree, we can file- and directory-local variables, and it just works as long as Emacs deems the variables safe. When not, Emacs prompts for confirmation. I'd rather not go there. Using an existing C style is a textbook example of safe local variables (literally, the Emacs manual does it). Adding simple customizations on top should be feasible. However, I can't see how I could define a new C style there without pushing the "local variables" feature well beyond its intended use, and triggering the confirmation prompts. If we take Dan's patch, every Emacs user who hasn't already configured a suitable style profits. Users who have may have to adjust their configuration to work with or around Dan's patch. "That action is best which procures the greatest happiness for the greatest numbers." Let's take Dan's patch. I can post a follow-up extending tab avoidance to files that don't use c-mode. Reviewed-by: Markus Armbruster <armbru@redhat.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-06-18 9:28 ` Markus Armbruster @ 2015-06-18 12:47 ` Peter Maydell 2015-06-18 14:05 ` Markus Armbruster 0 siblings, 1 reply; 11+ messages in thread From: Peter Maydell @ 2015-06-18 12:47 UTC (permalink / raw) To: Markus Armbruster; +Cc: QEMU Trivial, John Snow, QEMU Developers On 18 June 2015 at 10:28, Markus Armbruster <armbru@redhat.com> wrote: > However, I can't see how I could define a new C style there without > pushing the "local variables" feature well beyond its intended use, and > triggering the confirmation prompts. We wouldn't want to define a new C style, but in general the items I have in my config over the Stroustrup defaults are going to be there because I've noticed something where Stroustrup doesn't indent right... > If we take Dan's patch, every Emacs user who hasn't already configured a > suitable style profits. Users who have may have to adjust their > configuration to work with or around Dan's patch. Is there some way to tell whether your emacs has picked up the local style info rather than the one you have in your .emacs ? -- PMM ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-06-18 12:47 ` Peter Maydell @ 2015-06-18 14:05 ` Markus Armbruster 2015-08-25 0:15 ` John Snow 0 siblings, 1 reply; 11+ messages in thread From: Markus Armbruster @ 2015-06-18 14:05 UTC (permalink / raw) To: Peter Maydell; +Cc: QEMU Trivial, John Snow, QEMU Developers Peter Maydell <peter.maydell@linaro.org> writes: > On 18 June 2015 at 10:28, Markus Armbruster <armbru@redhat.com> wrote: >> However, I can't see how I could define a new C style there without >> pushing the "local variables" feature well beyond its intended use, and >> triggering the confirmation prompts. > > We wouldn't want to define a new C style, but in general the items > I have in my config over the Stroustrup defaults are going to be there > because I've noticed something where Stroustrup doesn't indent right... As far as I can see, the difference bwteen stroustrup style and yours is a few tweaks to c-offsets-alist and c-hanging-braces-alist. I'm not sure how to do that from .dir-locals.el. >> If we take Dan's patch, every Emacs user who hasn't already configured a >> suitable style profits. Users who have may have to adjust their >> configuration to work with or around Dan's patch. > > Is there some way to tell whether your emacs has picked up the local > style info rather than the one you have in your .emacs ? The obvious way is to check the buffer-local variables. Buffer-local variable c-indentation-style is the name of the style in use. Without anything in .emacs or local variables, it's "gnu". With your (c-add-style "qemu" qemu-c-style) in .emacs, it should be "qemu". With Dan's .dir-locals.el, it should be "stroustrup". When you can't or don't want to create or modify a .dir-locals.el, you can do something like this instead: (dir-locals-set-class-variables 'qemu '((c-mode . ((c-file-style . "qemu"))))) (dir-locals-set-directory-class "~/work/qemu" 'qemu) This *overrides* .dir-locals.el in my testing. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-06-18 14:05 ` Markus Armbruster @ 2015-08-25 0:15 ` John Snow 2015-09-15 15:31 ` Eric Blake 0 siblings, 1 reply; 11+ messages in thread From: John Snow @ 2015-08-25 0:15 UTC (permalink / raw) To: Markus Armbruster, Peter Maydell; +Cc: QEMU Trivial, QEMU Developers On 06/18/2015 10:05 AM, Markus Armbruster wrote: > Peter Maydell <peter.maydell@linaro.org> writes: > >> On 18 June 2015 at 10:28, Markus Armbruster <armbru@redhat.com> wrote: >>> However, I can't see how I could define a new C style there without >>> pushing the "local variables" feature well beyond its intended use, and >>> triggering the confirmation prompts. >> >> We wouldn't want to define a new C style, but in general the items >> I have in my config over the Stroustrup defaults are going to be there >> because I've noticed something where Stroustrup doesn't indent right... > > As far as I can see, the difference bwteen stroustrup style and yours is > a few tweaks to c-offsets-alist and c-hanging-braces-alist. I'm not > sure how to do that from .dir-locals.el. > >>> If we take Dan's patch, every Emacs user who hasn't already configured a >>> suitable style profits. Users who have may have to adjust their >>> configuration to work with or around Dan's patch. >> >> Is there some way to tell whether your emacs has picked up the local >> style info rather than the one you have in your .emacs ? > > The obvious way is to check the buffer-local variables. Buffer-local > variable c-indentation-style is the name of the style in use. Without > anything in .emacs or local variables, it's "gnu". With your > (c-add-style "qemu" qemu-c-style) in .emacs, it should be "qemu". With > Dan's .dir-locals.el, it should be "stroustrup". > > When you can't or don't want to create or modify a .dir-locals.el, you > can do something like this instead: > > (dir-locals-set-class-variables 'qemu '((c-mode . ((c-file-style . "qemu"))))) > (dir-locals-set-directory-class "~/work/qemu" 'qemu) > > This *overrides* .dir-locals.el in my testing. > ping -- any love for this for 2.5? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-08-25 0:15 ` John Snow @ 2015-09-15 15:31 ` Eric Blake 2015-09-15 15:54 ` Daniel P. Berrange 0 siblings, 1 reply; 11+ messages in thread From: Eric Blake @ 2015-09-15 15:31 UTC (permalink / raw) To: John Snow, Markus Armbruster, Peter Maydell; +Cc: QEMU Trivial, QEMU Developers [-- Attachment #1: Type: text/plain, Size: 2057 bytes --] ping On 08/24/2015 06:15 PM, John Snow wrote: > > > On 06/18/2015 10:05 AM, Markus Armbruster wrote: >> Peter Maydell <peter.maydell@linaro.org> writes: >> >>> On 18 June 2015 at 10:28, Markus Armbruster <armbru@redhat.com> wrote: >>>> However, I can't see how I could define a new C style there without >>>> pushing the "local variables" feature well beyond its intended use, and >>>> triggering the confirmation prompts. >>> >>> We wouldn't want to define a new C style, but in general the items >>> I have in my config over the Stroustrup defaults are going to be there >>> because I've noticed something where Stroustrup doesn't indent right... >> >> As far as I can see, the difference bwteen stroustrup style and yours is >> a few tweaks to c-offsets-alist and c-hanging-braces-alist. I'm not >> sure how to do that from .dir-locals.el. >> >>>> If we take Dan's patch, every Emacs user who hasn't already configured a >>>> suitable style profits. Users who have may have to adjust their >>>> configuration to work with or around Dan's patch. >>> >>> Is there some way to tell whether your emacs has picked up the local >>> style info rather than the one you have in your .emacs ? >> >> The obvious way is to check the buffer-local variables. Buffer-local >> variable c-indentation-style is the name of the style in use. Without >> anything in .emacs or local variables, it's "gnu". With your >> (c-add-style "qemu" qemu-c-style) in .emacs, it should be "qemu". With >> Dan's .dir-locals.el, it should be "stroustrup". >> >> When you can't or don't want to create or modify a .dir-locals.el, you >> can do something like this instead: >> >> (dir-locals-set-class-variables 'qemu '((c-mode . ((c-file-style . "qemu"))))) >> (dir-locals-set-directory-class "~/work/qemu" 'qemu) >> >> This *overrides* .dir-locals.el in my testing. >> > > ping -- any love for this for 2.5? > > -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-09-15 15:31 ` Eric Blake @ 2015-09-15 15:54 ` Daniel P. Berrange 2015-09-15 16:22 ` Markus Armbruster 0 siblings, 1 reply; 11+ messages in thread From: Daniel P. Berrange @ 2015-09-15 15:54 UTC (permalink / raw) To: Eric Blake Cc: QEMU Trivial, Peter Maydell, John Snow, Markus Armbruster, QEMU Developers On Tue, Sep 15, 2015 at 09:31:08AM -0600, Eric Blake wrote: > ping > > On 08/24/2015 06:15 PM, John Snow wrote: > > > > > > On 06/18/2015 10:05 AM, Markus Armbruster wrote: > >> Peter Maydell <peter.maydell@linaro.org> writes: > >> > >>> On 18 June 2015 at 10:28, Markus Armbruster <armbru@redhat.com> wrote: > >>>> However, I can't see how I could define a new C style there without > >>>> pushing the "local variables" feature well beyond its intended use, and > >>>> triggering the confirmation prompts. > >>> > >>> We wouldn't want to define a new C style, but in general the items > >>> I have in my config over the Stroustrup defaults are going to be there > >>> because I've noticed something where Stroustrup doesn't indent right... > >> > >> As far as I can see, the difference bwteen stroustrup style and yours is > >> a few tweaks to c-offsets-alist and c-hanging-braces-alist. I'm not > >> sure how to do that from .dir-locals.el. > >> > >>>> If we take Dan's patch, every Emacs user who hasn't already configured a > >>>> suitable style profits. Users who have may have to adjust their > >>>> configuration to work with or around Dan's patch. > >>> > >>> Is there some way to tell whether your emacs has picked up the local > >>> style info rather than the one you have in your .emacs ? > >> > >> The obvious way is to check the buffer-local variables. Buffer-local > >> variable c-indentation-style is the name of the style in use. Without > >> anything in .emacs or local variables, it's "gnu". With your > >> (c-add-style "qemu" qemu-c-style) in .emacs, it should be "qemu". With > >> Dan's .dir-locals.el, it should be "stroustrup". > >> > >> When you can't or don't want to create or modify a .dir-locals.el, you > >> can do something like this instead: > >> > >> (dir-locals-set-class-variables 'qemu '((c-mode . ((c-file-style . "qemu"))))) > >> (dir-locals-set-directory-class "~/work/qemu" 'qemu) > >> > >> This *overrides* .dir-locals.el in my testing. > >> > > > > ping -- any love for this for 2.5? So just to re-cap..... My original proposed .dir-locals.el was pretty short: ((c-mode . ((c-file-style . "stroustrup") (indent-tabs-mode . nil)))) IIUC, the quote above says it is possible to override this with more developer custom styles if desired, so it shouldn't cause any obvious disadvantage / problem to contributors to have this set by default. I have tried an alternative .dir-locals.el that contains all of Peter's rules (from http://wiki.linaro.org/PeterMaydell/QemuEmacsStyle) which looks like this: ;; Based on https://wiki.linaro.org/PeterMaydell/QemuEmacsStyle ;; which aims to apply CODING_STYLE guidelines ((c-mode . ( (c-file-style . "stroustrup") (indent-tabs-mode . nil) (tab-width . 8) (c-comment-only-line-offset . 1) (c-hanging-braces-alist . ((substatement-open before after))) (c-offsets-alist . ( (statement-block-intro . +) (substatement-open . 0) (label . 0) (statement-cont . +) (innamespace . 0) (inline-open . 0) )) (c-hanging-braces-alist . ( (brace-list-open) (brace-list-intro) (brace-list-entry) (brace-list-close) (brace-entry-open) (block-close . c-snug-do-while) ;; structs have hanging braces on open (class-open . (after)) ;; ditto if statements (substatement-open . (after)) ;; and no auto newline at the end (class-close) )) ))) The main downside/problem I found with having this more comprehensive .dir-locals.el file, is that emacs will raise a warning at launch time: "The local variables list in /home/berrange/src/virt/qemu contains vlaues that may not be safe (*). Do you want to apply it? You can type y -- to apply the local variables list. n -- to ignore the local variables list. ! -- to apply the local variables list and permanently mark these values (*) as safe (in the future, they will be set automatically)" It will ask this every time it launches unless you say "!" whereupon it modifies your $HOME/.emacs to disable the warning Personally I be fine with both the minimal approach or the more comprehensive approach of Peter's, but I'd probably tend towards the minimal approach to avoid the warnings problem. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-09-15 15:54 ` Daniel P. Berrange @ 2015-09-15 16:22 ` Markus Armbruster 2015-09-15 17:53 ` Michael Tokarev 0 siblings, 1 reply; 11+ messages in thread From: Markus Armbruster @ 2015-09-15 16:22 UTC (permalink / raw) To: Daniel P. Berrange Cc: QEMU Trivial, Peter Maydell, John Snow, QEMU Developers "Daniel P. Berrange" <berrange@redhat.com> writes: > On Tue, Sep 15, 2015 at 09:31:08AM -0600, Eric Blake wrote: >> ping >> >> On 08/24/2015 06:15 PM, John Snow wrote: >> > >> > >> > On 06/18/2015 10:05 AM, Markus Armbruster wrote: >> >> Peter Maydell <peter.maydell@linaro.org> writes: >> >> >> >>> On 18 June 2015 at 10:28, Markus Armbruster <armbru@redhat.com> wrote: >> >>>> However, I can't see how I could define a new C style there without >> >>>> pushing the "local variables" feature well beyond its intended use, and >> >>>> triggering the confirmation prompts. >> >>> >> >>> We wouldn't want to define a new C style, but in general the items >> >>> I have in my config over the Stroustrup defaults are going to be there >> >>> because I've noticed something where Stroustrup doesn't indent right... >> >> >> >> As far as I can see, the difference bwteen stroustrup style and yours is >> >> a few tweaks to c-offsets-alist and c-hanging-braces-alist. I'm not >> >> sure how to do that from .dir-locals.el. >> >> >> >>>> If we take Dan's patch, every Emacs user who hasn't already configured a >> >>>> suitable style profits. Users who have may have to adjust their >> >>>> configuration to work with or around Dan's patch. >> >>> >> >>> Is there some way to tell whether your emacs has picked up the local >> >>> style info rather than the one you have in your .emacs ? >> >> >> >> The obvious way is to check the buffer-local variables. Buffer-local >> >> variable c-indentation-style is the name of the style in use. Without >> >> anything in .emacs or local variables, it's "gnu". With your >> >> (c-add-style "qemu" qemu-c-style) in .emacs, it should be "qemu". With >> >> Dan's .dir-locals.el, it should be "stroustrup". >> >> >> >> When you can't or don't want to create or modify a .dir-locals.el, you >> >> can do something like this instead: >> >> >> >> (dir-locals-set-class-variables 'qemu '((c-mode >> >> . ((c-file-style . "qemu"))))) >> >> (dir-locals-set-directory-class "~/work/qemu" 'qemu) >> >> >> >> This *overrides* .dir-locals.el in my testing. >> >> >> > >> > ping -- any love for this for 2.5? > > So just to re-cap..... > > My original proposed .dir-locals.el was pretty short: > > ((c-mode . ((c-file-style . "stroustrup") > (indent-tabs-mode . nil)))) > > IIUC, the quote above says it is possible to override this with more > developer custom styles if desired, so it shouldn't cause any obvious > disadvantage / problem to contributors to have this set by default. > > I have tried an alternative .dir-locals.el that contains all of > Peter's rules (from http://wiki.linaro.org/PeterMaydell/QemuEmacsStyle) > which looks like this: > > > ;; Based on https://wiki.linaro.org/PeterMaydell/QemuEmacsStyle > ;; which aims to apply CODING_STYLE guidelines > ((c-mode . ( > (c-file-style . "stroustrup") > (indent-tabs-mode . nil) > (tab-width . 8) > (c-comment-only-line-offset . 1) > (c-hanging-braces-alist . ((substatement-open before after))) > (c-offsets-alist . ( > (statement-block-intro . +) > (substatement-open . 0) > (label . 0) > (statement-cont . +) > (innamespace . 0) > (inline-open . 0) > )) > (c-hanging-braces-alist . ( > (brace-list-open) > (brace-list-intro) > (brace-list-entry) > (brace-list-close) > (brace-entry-open) > (block-close . c-snug-do-while) > ;; structs have hanging braces on open > (class-open . (after)) > ;; ditto if statements > (substatement-open . (after)) > ;; and no auto newline at the end > (class-close) > )) > ))) > > The main downside/problem I found with having this more comprehensive > .dir-locals.el file, is that emacs will raise a warning at launch time: > > "The local variables list in /home/berrange/src/virt/qemu > contains vlaues that may not be safe (*). > > Do you want to apply it? You can type > y -- to apply the local variables list. > n -- to ignore the local variables list. > ! -- to apply the local variables list and permanently > mark these values (*) as safe (in the future, they > will be set automatically)" > > It will ask this every time it launches unless you say "!" > whereupon it modifies your $HOME/.emacs to disable the warning > > Personally I be fine with both the minimal approach or the more > comprehensive approach of Peter's, but I'd probably tend towards > the minimal approach to avoid the warnings problem. Seconded. The "minimal approach" has been on the list since June, and it has my R-by. It's clearly better than nothing. Let's commit it now. We can always improve on it later. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style 2015-09-15 16:22 ` Markus Armbruster @ 2015-09-15 17:53 ` Michael Tokarev 0 siblings, 0 replies; 11+ messages in thread From: Michael Tokarev @ 2015-09-15 17:53 UTC (permalink / raw) To: Markus Armbruster, Daniel P. Berrange Cc: QEMU Trivial, Peter Maydell, John Snow, QEMU Developers 15.09.2015 19:22, Markus Armbruster wrote: > "Daniel P. Berrange" <berrange@redhat.com> writes: [] >> Personally I be fine with both the minimal approach or the more >> comprehensive approach of Peter's, but I'd probably tend towards >> the minimal approach to avoid the warnings problem. > > Seconded. > > The "minimal approach" has been on the list since June, and it has my > R-by. It's clearly better than nothing. Let's commit it now. We can > always improve on it later. Ok, let's apply it. BTW, Marcus, your R-By wasn't actually clear, to which version it applies. Now I see that after your comment. Applied, finally, to -trivial now, thank you all! Should I add some more r-by or s-by? :) Thanks! /mjt ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-09-15 17:54 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-06-04 13:30 [Qemu-devel] [PATCH v2] Add .dir-locals.el file to configure emacs coding style Daniel P. Berrange 2015-06-04 13:41 ` Peter Maydell 2015-06-04 14:15 ` Daniel P. Berrange 2015-06-18 9:28 ` Markus Armbruster 2015-06-18 12:47 ` Peter Maydell 2015-06-18 14:05 ` Markus Armbruster 2015-08-25 0:15 ` John Snow 2015-09-15 15:31 ` Eric Blake 2015-09-15 15:54 ` Daniel P. Berrange 2015-09-15 16:22 ` Markus Armbruster 2015-09-15 17:53 ` Michael Tokarev
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.