* [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions
@ 2018-09-04 7:03 Peter Krempa
2018-10-04 11:34 ` Peter Krempa
0 siblings, 1 reply; 6+ messages in thread
From: Peter Krempa @ 2018-09-04 7:03 UTC (permalink / raw)
To: qemu-devel; +Cc: Eric Blake, Markus Armbruster, Peter Krempa
The files have a json suffix but look terrible with json syntax
hilighting enabled. Add a magic modeline for vim to switch to python
file format for hilighting similarly to the emacs modeline already
present.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
qapi/block-core.json | 1 +
qapi/block.json | 1 +
qapi/char.json | 1 +
qapi/common.json | 1 +
qapi/crypto.json | 1 +
qapi/introspect.json | 1 +
qapi/job.json | 1 +
qapi/migration.json | 1 +
qapi/misc.json | 1 +
qapi/net.json | 1 +
qapi/qapi-schema.json | 1 +
qapi/rocker.json | 1 +
qapi/run-state.json | 1 +
qapi/sockets.json | 1 +
qapi/tpm.json | 1 +
qapi/trace.json | 1 +
qapi/transaction.json | 1 +
qapi/ui.json | 1 +
18 files changed, 18 insertions(+)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 4c7a37afdc..e75bc8dd03 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
##
# == Block core (VM unrelated)
diff --git a/qapi/block.json b/qapi/block.json
index 11f01f28ef..f94ab0c09f 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
##
# = Block devices
diff --git a/qapi/char.json b/qapi/char.json
index b7b2a05766..d167f74699 100644
--- a/qapi/char.json
+++ b/qapi/char.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/common.json b/qapi/common.json
index c367adc4b6..5a3a71a5bf 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
##
# = Common data types
diff --git a/qapi/crypto.json b/qapi/crypto.json
index a51b434412..6ccb97079b 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/introspect.json b/qapi/introspect.json
index 3d22166b2b..ff6fb9fe52 100644
--- a/qapi/introspect.json
+++ b/qapi/introspect.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
# Copyright (C) 2015 Red Hat, Inc.
#
diff --git a/qapi/job.json b/qapi/job.json
index a121b615fb..ddef257f7e 100644
--- a/qapi/job.json
+++ b/qapi/job.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
##
# == Background jobs
diff --git a/qapi/migration.json b/qapi/migration.json
index f62d3f9a4b..17b0e00252 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/misc.json b/qapi/misc.json
index d450cfef21..2f04983517 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/net.json b/qapi/net.json
index c86f351161..e736e1a26b 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
index 65b6dc2f6f..09d745bdcf 100644
--- a/qapi/qapi-schema.json
+++ b/qapi/qapi-schema.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
##
# = Introduction
#
diff --git a/qapi/rocker.json b/qapi/rocker.json
index 3587661161..8e3486592b 100644
--- a/qapi/rocker.json
+++ b/qapi/rocker.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
##
# = Rocker switch device
diff --git a/qapi/run-state.json b/qapi/run-state.json
index 332e44897b..704a330a6c 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/sockets.json b/qapi/sockets.json
index fc81d8d5e8..b335b6b872 100644
--- a/qapi/sockets.json
+++ b/qapi/sockets.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
##
# = Socket data types
diff --git a/qapi/tpm.json b/qapi/tpm.json
index d50deef5e9..ae7953cb04 100644
--- a/qapi/tpm.json
+++ b/qapi/tpm.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/trace.json b/qapi/trace.json
index 799b254a18..e5ffbad800 100644
--- a/qapi/trace.json
+++ b/qapi/trace.json
@@ -1,4 +1,5 @@
# -*- mode: python -*-
+# vim: ft=python
#
# Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
#
diff --git a/qapi/transaction.json b/qapi/transaction.json
index d7e4274550..588112383a 100644
--- a/qapi/transaction.json
+++ b/qapi/transaction.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
diff --git a/qapi/ui.json b/qapi/ui.json
index 4ca91bb45a..918ab84a5a 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1,4 +1,5 @@
# -*- Mode: Python -*-
+# vim: ft=python
#
##
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions
2018-09-04 7:03 [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions Peter Krempa
@ 2018-10-04 11:34 ` Peter Krempa
2018-12-05 12:33 ` Peter Krempa
0 siblings, 1 reply; 6+ messages in thread
From: Peter Krempa @ 2018-10-04 11:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Markus Armbruster
On Tue, Sep 04, 2018 at 09:03:10 +0200, Peter Krempa wrote:
> The files have a json suffix but look terrible with json syntax
> hilighting enabled. Add a magic modeline for vim to switch to python
> file format for hilighting similarly to the emacs modeline already
> present.
>
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
Ping?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions
2018-10-04 11:34 ` Peter Krempa
@ 2018-12-05 12:33 ` Peter Krempa
2018-12-05 14:09 ` Marc-André Lureau
0 siblings, 1 reply; 6+ messages in thread
From: Peter Krempa @ 2018-12-05 12:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 500 bytes --]
On Thu, Oct 04, 2018 at 13:34:12 +0200, Peter Krempa wrote:
> On Tue, Sep 04, 2018 at 09:03:10 +0200, Peter Krempa wrote:
> > The files have a json suffix but look terrible with json syntax
> > hilighting enabled. Add a magic modeline for vim to switch to python
> > file format for hilighting similarly to the emacs modeline already
> > present.
> >
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
>
> Ping?
Ping 2. It looks like no new json files were added meanwhile.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions
2018-12-05 12:33 ` Peter Krempa
@ 2018-12-05 14:09 ` Marc-André Lureau
2018-12-05 16:20 ` Markus Armbruster
0 siblings, 1 reply; 6+ messages in thread
From: Marc-André Lureau @ 2018-12-05 14:09 UTC (permalink / raw)
To: Peter Krempa; +Cc: QEMU, Markus Armbruster
Hi
On Wed, Dec 5, 2018 at 4:34 PM Peter Krempa <pkrempa@redhat.com> wrote:
>
> On Thu, Oct 04, 2018 at 13:34:12 +0200, Peter Krempa wrote:
> > On Tue, Sep 04, 2018 at 09:03:10 +0200, Peter Krempa wrote:
> > > The files have a json suffix but look terrible with json syntax
> > > hilighting enabled. Add a magic modeline for vim to switch to python
> > > file format for hilighting similarly to the emacs modeline already
> > > present.
> > >
> > > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > > ---
> >
> > Ping?
>
> Ping 2. It looks like no new json files were added meanwhile.
I use both emacs and vim. We solved this for me with emacs .editorconf
file_type_emacs.
The vim plugin doesn't have an equivalent, however, the documentation
suggest vim_filetype, but you need to add
to .vimrc:
function! FiletypeHook(config)
if has_key(a:config, 'vim_filetype')
let &filetype = a:config['vim_filetype']
endif
return 0 " Return 0 to show no error happened
endfunction
call editorconfig#AddNewHook(function('FiletypeHook'))
I think this is a better solution than having to add modelines
everywhere, what do you think?
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions
2018-12-05 14:09 ` Marc-André Lureau
@ 2018-12-05 16:20 ` Markus Armbruster
2018-12-05 21:49 ` Eric Blake
0 siblings, 1 reply; 6+ messages in thread
From: Markus Armbruster @ 2018-12-05 16:20 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: Peter Krempa, QEMU
Marc-André Lureau <marcandre.lureau@gmail.com> writes:
> Hi
>
> On Wed, Dec 5, 2018 at 4:34 PM Peter Krempa <pkrempa@redhat.com> wrote:
>>
>> On Thu, Oct 04, 2018 at 13:34:12 +0200, Peter Krempa wrote:
>> > On Tue, Sep 04, 2018 at 09:03:10 +0200, Peter Krempa wrote:
>> > > The files have a json suffix but look terrible with json syntax
>> > > hilighting enabled. Add a magic modeline for vim to switch to python
>> > > file format for hilighting similarly to the emacs modeline already
>> > > present.
>> > >
>> > > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>> > > ---
>> >
>> > Ping?
>>
>> Ping 2. It looks like no new json files were added meanwhile.
>
> I use both emacs and vim. We solved this for me with emacs .editorconf
> file_type_emacs.
>
> The vim plugin doesn't have an equivalent, however, the documentation
> suggest vim_filetype, but you need to add
> to .vimrc:
>
> function! FiletypeHook(config)
> if has_key(a:config, 'vim_filetype')
> let &filetype = a:config['vim_filetype']
> endif
>
> return 0 " Return 0 to show no error happened
> endfunction
>
> call editorconfig#AddNewHook(function('FiletypeHook'))
>
> I think this is a better solution than having to add modelines
> everywhere, what do you think?
These .json files are not valid JSON. They *are* valid Python (except
for a few tests, which could perhaps be fixed). Makes me wonder why on
earth we insist on naming them .json and create all this trouble.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions
2018-12-05 16:20 ` Markus Armbruster
@ 2018-12-05 21:49 ` Eric Blake
0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2018-12-05 21:49 UTC (permalink / raw)
To: Markus Armbruster, Marc-André Lureau; +Cc: Peter Krempa, QEMU
On 12/5/18 10:20 AM, Markus Armbruster wrote:
>> The vim plugin doesn't have an equivalent, however, the documentation
>> suggest vim_filetype, but you need to add
>> to .vimrc:
>>
>> function! FiletypeHook(config)
>> if has_key(a:config, 'vim_filetype')
>> let &filetype = a:config['vim_filetype']
>> endif
>>
>> return 0 " Return 0 to show no error happened
>> endfunction
>>
>> call editorconfig#AddNewHook(function('FiletypeHook'))
>>
>> I think this is a better solution than having to add modelines
>> everywhere, what do you think?
>
> These .json files are not valid JSON. They *are* valid Python (except
> for a few tests, which could perhaps be fixed). Makes me wonder why on
> earth we insist on naming them .json and create all this trouble.
I've previously posted patches that bulk-renames the QAPI files from
.json to .qapi, but too close to a release cycle to be applied at the
time. I'd have to refresh them to match new files in the meantime, but
as long as we are arguing that editorconfig is a smart way to go, it's a
fairly simple tweak to editorconfig to match the preferred suffix we use
for QAPI files.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-12-05 21:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-04 7:03 [Qemu-devel] [PATCH] qapi: Add vim magic modelines for qapi definitions Peter Krempa
2018-10-04 11:34 ` Peter Krempa
2018-12-05 12:33 ` Peter Krempa
2018-12-05 14:09 ` Marc-André Lureau
2018-12-05 16:20 ` Markus Armbruster
2018-12-05 21:49 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).