qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode
@ 2017-08-31 13:14 Marc-André Lureau
  2017-08-31 13:14 ` [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema " Marc-André Lureau
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Marc-André Lureau @ 2017-08-31 13:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, armbru, Marc-André Lureau, Stefan Hajnoczi

QEMU uses non-conventional makefile filenames. Ease the life of emacs
developpers a bit by appending to the auto-mode-alist.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 .dir-locals.el      | 7 ++++++-
 Makefile.target     | 2 --
 trace/Makefile.objs | 2 --
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 3ac0cfc6f0..13ec483765 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,2 +1,7 @@
 ((c-mode . ((c-file-style . "stroustrup")
-	    (indent-tabs-mode . nil))))
+            (indent-tabs-mode . nil)))
+ (nil . ((eval . (setq auto-mode-alist (append
+                                        '(("Makefile.*" . makefile-gmake-mode)
+                                          ("\\.mak\\'" . makefile-gmake-mode))
+                                        auto-mode-alist))))
+      ))
diff --git a/Makefile.target b/Makefile.target
index 7f42c45db8..159602c83c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -1,5 +1,3 @@
-# -*- Mode: makefile -*-
-
 BUILD_DIR?=$(CURDIR)/..
 
 include ../config-host.mak
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index afd571c3ec..d1f1e646e5 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -1,5 +1,3 @@
-# -*- mode: makefile -*-
-
 $(BUILD_DIR)/trace-events-all: $(trace-events-files)
 	$(call quiet-command,cat $^ > $@)
 
-- 
2.14.1.146.gd35faa819

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema to auto-mode
  2017-08-31 13:14 [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode Marc-André Lureau
@ 2017-08-31 13:14 ` Marc-André Lureau
  2017-08-31 16:19   ` Eric Blake
  2017-08-31 16:13 ` [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles " Eric Blake
  2017-09-01  9:29 ` Markus Armbruster
  2 siblings, 1 reply; 5+ messages in thread
From: Marc-André Lureau @ 2017-08-31 13:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, armbru, Marc-André Lureau, Eric Blake,
	Michael Roth

The json schema is more friendly to python-mode since it doesn't
follow strictly json (comments to start with).

All schema files add file variables to set the python mode, but most
tests didn't. This will cover all json files now.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qapi-schema.json                        | 1 -
 qapi/block-core.json                    | 2 --
 qapi/block.json                         | 2 --
 qapi/common.json                        | 2 --
 qapi/crypto.json                        | 3 ---
 qapi/event.json                         | 2 --
 qapi/introspect.json                    | 1 -
 qapi/rocker.json                        | 2 --
 qapi/trace.json                         | 1 -
 .dir-locals.el                          | 4 +++-
 qga/qapi-schema.json                    | 2 --
 tests/qapi-schema/doc-good.json         | 1 -
 tests/qapi-schema/qapi-schema-test.json | 2 --
 13 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 802ea53d00..232fafeb65 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1,4 +1,3 @@
-# -*- Mode: Python -*-
 ##
 # = Introduction
 #
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 833c602150..5bd14554aa 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # == QAPI block core definitions (vm unrelated)
 ##
diff --git a/qapi/block.json b/qapi/block.json
index 414b61bde7..979906625d 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = QAPI block definitions
 ##
diff --git a/qapi/common.json b/qapi/common.json
index 8355d5a2f3..25a9fdcbfd 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = QAPI common definitions
 ##
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 6b6fde367a..9ec7777603 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = QAPI crypto definitions
 ##
diff --git a/qapi/event.json b/qapi/event.json
index 6d22b025cc..6f15ec1542 100644
--- a/qapi/event.json
+++ b/qapi/event.json
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = Other events
 ##
diff --git a/qapi/introspect.json b/qapi/introspect.json
index cf77ff0669..83eaed3e43 100644
--- a/qapi/introspect.json
+++ b/qapi/introspect.json
@@ -1,4 +1,3 @@
-# -*- Mode: Python -*-
 #
 # QAPI/QMP introspection
 #
diff --git a/qapi/rocker.json b/qapi/rocker.json
index 3587661161..0026c7fd59 100644
--- a/qapi/rocker.json
+++ b/qapi/rocker.json
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = Rocker switch device
 ##
diff --git a/qapi/trace.json b/qapi/trace.json
index de6588d9f7..679b1e298a 100644
--- a/qapi/trace.json
+++ b/qapi/trace.json
@@ -1,4 +1,3 @@
-# -*- mode: python -*-
 #
 # Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
 #
diff --git a/.dir-locals.el b/.dir-locals.el
index 13ec483765..46a6c73ed1 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -2,6 +2,8 @@
             (indent-tabs-mode . nil)))
  (nil . ((eval . (setq auto-mode-alist (append
                                         '(("Makefile.*" . makefile-gmake-mode)
-                                          ("\\.mak\\'" . makefile-gmake-mode))
+                                          ("\\.mak\\'" . makefile-gmake-mode)
+                                          ;; json schema is not pure json
+                                          ("\\.json\\'" . python-mode))
                                         auto-mode-alist))))
       ))
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 90a0c8602b..757bb42521 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -1,5 +1,3 @@
-# *-*- Mode: Python -*-*
-
 ##
 #
 # General note concerning the use of guest agent interfaces:
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index cfdc0a8a81..4a34eaf3d1 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -1,4 +1,3 @@
-# -*- Mode: Python -*-
 # Positive QAPI doc comment tests
 
 { 'pragma': { 'doc-required': true } }
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index c72dbd8050..6e5635ef66 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -1,5 +1,3 @@
-# *-*- Mode: Python -*-*
-
 # This file is a stress test of supported qapi constructs that must
 # parse and compile correctly.
 
-- 
2.14.1.146.gd35faa819

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode
  2017-08-31 13:14 [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode Marc-André Lureau
  2017-08-31 13:14 ` [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema " Marc-André Lureau
@ 2017-08-31 16:13 ` Eric Blake
  2017-09-01  9:29 ` Markus Armbruster
  2 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2017-08-31 16:13 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: armbru, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

On 08/31/2017 08:14 AM, Marc-André Lureau wrote:
> QEMU uses non-conventional makefile filenames. Ease the life of emacs
> developpers a bit by appending to the auto-mode-alist.

s/emacs developpers/developers using emacs/ (typo, and avoids an
ambiguity on whether you are describing people that develop emacs rather
than qemu)

> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---

The idea itself makes sense to me; although I'm not enough of a Lisp
guru to state if your changes are the ideal way to do it.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema to auto-mode
  2017-08-31 13:14 ` [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema " Marc-André Lureau
@ 2017-08-31 16:19   ` Eric Blake
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2017-08-31 16:19 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: berrange, armbru, Michael Roth

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

On 08/31/2017 08:14 AM, Marc-André Lureau wrote:
> The json schema is more friendly to python-mode since it doesn't
> follow strictly json (comments to start with).

I found that hard to read, and missing a key word of 'emacs'.  Maybe
reword it as:

Under emacs, our QAPI files (.json suffix) are more friendly to edit
under python-mode than the per-suffix default of json-mode (in part
because of our use of comments).

> 
> All schema files add file variables to set the python mode, but most
> tests didn't. This will cover all json files now.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---

> +++ b/.dir-locals.el
> @@ -2,6 +2,8 @@
>              (indent-tabs-mode . nil)))
>   (nil . ((eval . (setq auto-mode-alist (append
>                                          '(("Makefile.*" . makefile-gmake-mode)
> -                                          ("\\.mak\\'" . makefile-gmake-mode))
> +                                          ("\\.mak\\'" . makefile-gmake-mode)
> +                                          ;; json schema is not pure json
> +                                          ("\\.json\\'" . python-mode))
>                                          auto-mode-alist))))
>        ))

Not sure if the comment could be worded better, maybe:

;; Our .json files are QAPI, and allow more than pure json

Again, the idea makes sense to me, but you may want to get feedback from
other power emacs users.

[Also, don't forget the 0/2 cover letter if you send v2]

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode
  2017-08-31 13:14 [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode Marc-André Lureau
  2017-08-31 13:14 ` [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema " Marc-André Lureau
  2017-08-31 16:13 ` [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles " Eric Blake
@ 2017-09-01  9:29 ` Markus Armbruster
  2 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2017-09-01  9:29 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, Stefan Hajnoczi

Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> QEMU uses non-conventional makefile filenames. Ease the life of emacs
> developpers a bit by appending to the auto-mode-alist.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  .dir-locals.el      | 7 ++++++-
>  Makefile.target     | 2 --
>  trace/Makefile.objs | 2 --
>  3 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/.dir-locals.el b/.dir-locals.el
> index 3ac0cfc6f0..13ec483765 100644
> --- a/.dir-locals.el
> +++ b/.dir-locals.el
> @@ -1,2 +1,7 @@
>  ((c-mode . ((c-file-style . "stroustrup")
> -	    (indent-tabs-mode . nil))))
> +            (indent-tabs-mode . nil)))
> + (nil . ((eval . (setq auto-mode-alist (append
> +                                        '(("Makefile.*" . makefile-gmake-mode)
> +                                          ("\\.mak\\'" . makefile-gmake-mode))
> +                                        auto-mode-alist))))
> +      ))

This makes Emacs ask for confirmation like this:

    The local variables list in /home/armbru/work/qemu/
    contains values 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.)

      * eval : (setq auto-mode-alist (append (quote (("Makefile.*" . makefile-gmake-mode) ("\\.mak\\'" . makefile-gmake-mode) ("\\.json\\'" . python-mode))) auto-mode-alist))

Not a nice user experience.  For detailed information why and how this
stuff works, see
https://www.gnu.org/software/emacs/manual/html_node/emacs/Safe-File-Variables.html

Why can't we simply use the usual file name extension like a normal
person?

If that's too much to ask, then I'd recommend adding modelines (like the
ones you delete) to the Makefiles that lack one.

> diff --git a/Makefile.target b/Makefile.target
> index 7f42c45db8..159602c83c 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -1,5 +1,3 @@
> -# -*- Mode: makefile -*-
> -
>  BUILD_DIR?=$(CURDIR)/..
>  
>  include ../config-host.mak
> diff --git a/trace/Makefile.objs b/trace/Makefile.objs
> index afd571c3ec..d1f1e646e5 100644
> --- a/trace/Makefile.objs
> +++ b/trace/Makefile.objs
> @@ -1,5 +1,3 @@
> -# -*- mode: makefile -*-
> -
>  $(BUILD_DIR)/trace-events-all: $(trace-events-files)
>  	$(call quiet-command,cat $^ > $@)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-01  9:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-31 13:14 [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode Marc-André Lureau
2017-08-31 13:14 ` [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema " Marc-André Lureau
2017-08-31 16:19   ` Eric Blake
2017-08-31 16:13 ` [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles " Eric Blake
2017-09-01  9:29 ` Markus Armbruster

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).