.dir-locals.el: add makefiles to auto-mode
PATCH 1/2 .dir-locals.el: add makefiles to auto-mode
QEMU uses non-conventional makefile filenames. Ease the life of emacs developpers a bit by appending to the auto-mode-alist.
--- .dir-locals.el | 7 ++++++- Makefile.target | 2 -- trace/Makefile.objs | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-)
.dir-locals.el +6 -1
@@ -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)))) + ))
Makefile.target +0 -2
@@ -1,5 +1,3 @@ -# -*- Mode: makefile -*- - BUILD_DIR?=$(CURDIR)/.. include ../config-host.mak
trace/Makefile.objs +0 -2
@@ -1,5 +1,3 @@ -# -*- mode: makefile -*- - $(BUILD_DIR)/trace-events-all: $(trace-events-files) $(call quiet-command,cat $^ > $@)
Signature · 1 line
2.14.1.146.gd35faa819
PATCH 2/2 .dir-locals.el: add json schema to auto-mode
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.
--- 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(-)
qapi-schema.json +0 -1
@@ -1,4 +1,3 @@ -# -*- Mode: Python -*- ## # = Introduction #
qapi/block-core.json +0 -2
@@ -1,5 +1,3 @@ -# -*- Mode: Python -*- - ## # == QAPI block core definitions (vm unrelated) ##
qapi/block.json +0 -2
@@ -1,5 +1,3 @@ -# -*- Mode: Python -*- - ## # = QAPI block definitions ##
qapi/common.json +0 -2
@@ -1,5 +1,3 @@ -# -*- Mode: Python -*- - ## # = QAPI common definitions ##
qapi/crypto.json +0 -3
@@ -1,6 +1,3 @@ -# -*- Mode: Python -*- -# - ## # = QAPI crypto definitions ##
qapi/event.json +0 -2
@@ -1,5 +1,3 @@ -# -*- Mode: Python -*- - ## # = Other events ##
qapi/introspect.json +0 -1
@@ -1,4 +1,3 @@ -# -*- Mode: Python -*- # # QAPI/QMP introspection #
qapi/rocker.json +0 -2
@@ -1,5 +1,3 @@ -# -*- Mode: Python -*- - ## # = Rocker switch device ##
qapi/trace.json +0 -1
@@ -1,4 +1,3 @@ -# -*- mode: python -*- # # Copyright (C) 2011-2016 Lluís Vilanova <[email protected]> #
.dir-locals.el +3 -1
@@ -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)))) ))
qga/qapi-schema.json +0 -2
@@ -1,5 +1,3 @@ -# *-*- Mode: Python -*-* - ## # # General note concerning the use of guest agent interfaces:
tests/qapi-schema/doc-good.json +0 -1
@@ -1,4 +1,3 @@ -# -*- Mode: Python -*- # Positive QAPI doc comment tests { 'pragma': { 'doc-required': true } }
tests/qapi-schema/qapi-schema-test.json +0 -2
@@ -1,5 +1,3 @@ -# *-*- Mode: Python -*-* - # This file is a stress test of supported qapi constructs that must # parse and compile correctly.
Signature · 1 line
2.14.1.146.gd35faa819
Re: [Qemu-devel] [PATCH 2/2] .dir-locals.el: add json schema to auto-mode
Quoted 2 lines · Marc-André Lureau
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).
Quoted 9 lines
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 <[email protected]>---
+++ b/.dir-locals.el
.dir-locals.el line 9
Quoted 9 lines
.dir-locals.el +3
-1@@ -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]
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 2 lines · Marc-André Lureau
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)
Quoted 3 lines
Signed-off-by Marc-André Lureau <[email protected]>---
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.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 15 lines · Marc-André Lureau
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 <[email protected]>--- .dir-locals.el | 7 ++++++- Makefile.target | 2 -- trace/Makefile.objs | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-).dir-locals.el +0
-0
.dir-locals.el line 7
Quoted 8 lines
.dir-locals.el +6
-1@@ -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.
Quoted 19 lines
Makefile.target +0
-2@@ -1,5 +1,3 @@ -# -*- Mode: makefile -*- - BUILD_DIR?=$(CURDIR)/.. include ../config-host.maktrace/Makefile.objs +0
-2@@ -1,5 +1,3 @@ -# -*- mode: makefile -*- - $(BUILD_DIR)/trace-events-all: $(trace-events-files) $(call quiet-command,cat $^ > $@)