Skip to contentSkip to conversation

editorconfig: set emacs mode

PATCH Superseded Marc-André Lureau 5 participants 5 messages Aug 20, 2018 – Aug 21, 2018 Kbuild

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 editorconfig: set emacs mode

Some time ago, I proposed to use an (eval) in .dir-locals.el to set the mode for all json files and Makefile. Unfortunately, this isn't safe, and emacs will prompt the user, which isn't very friendly.

Fortunately, editorconfig provides a special config key which does allow to set the emacs mode. Set the emacs mode for JSON, GLSL and extra makefiles that are not yet covered. Drop modeline from JSON files.

---
 qapi/block-core.json                    |  2 --
 qapi/block.json                         |  2 --
 qapi/char.json                          |  3 ---
 qapi/common.json                        |  2 --
 qapi/crypto.json                        |  3 ---
 qapi/introspect.json                    |  2 --
 qapi/job.json                           |  2 --
 qapi/migration.json                     |  3 ---
 qapi/misc.json                          |  3 ---
 qapi/net.json                           |  3 ---
 qapi/qapi-schema.json                   |  1 -
 qapi/rocker.json                        |  2 --
 qapi/run-state.json                     |  3 ---
 qapi/sockets.json                       |  2 --
 qapi/tpm.json                           |  3 ---
 qapi/transaction.json                   |  3 ---
 qapi/ui.json                            |  3 ---
 .editorconfig                           | 13 +++++++++++++
 Makefile.target                         |  2 --
 docs/interop/firmware.json              |  2 --
 qga/qapi-schema.json                    |  2 --
 tests/qapi-schema/doc-good.json         |  1 -
 tests/qapi-schema/qapi-schema-test.json |  2 --
 23 files changed, 13 insertions(+), 51 deletions(-)
qapi/block-core.json +0 -2
index 4c7a37afdc..b1fb7ddf40 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # == Block core (VM unrelated)
 ##
qapi/block.json +0 -2
index 11f01f28ef..953e7de564 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = Block devices
 ##
qapi/char.json +0 -3
index b7b2a05766..955d52aa01 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = Character devices
 ##
qapi/common.json +0 -2
index c367adc4b6..236e5b3a0d 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = Common data types
 ##
qapi/crypto.json +0 -3
index a51b434412..9720f145ff 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = Cryptography
 ##
qapi/introspect.json +0 -2
index 137b39b992..e602a916f1 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-#
 # Copyright (C) 2015 Red Hat, Inc.
 #
 # Authors:
qapi/job.json +0 -2
index a121b615fb..5e60f04bae 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # == Background jobs
 ##
qapi/migration.json +0 -3
index 186e8a7303..3f96dfd5f5 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = Migration
 ##
qapi/misc.json +0 -3
index d450cfef21..a985d64739 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = Miscellanea
 ##
qapi/net.json +0 -3
index c86f351161..74ab3fe34e 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = Net devices
 ##
qapi/qapi-schema.json +0 -1
index 65b6dc2f6f..980c998173 100644
@@ -1,4 +1,3 @@
-# -*- Mode: Python -*-
 ##
 # = Introduction
 #
qapi/rocker.json +0 -2
index 3587661161..0026c7fd59 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = Rocker switch device
 ##
qapi/run-state.json +0 -3
index 332e44897b..14c88da0a9 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = VM run state
 ##
qapi/sockets.json +0 -2
index fc81d8d5e8..e83667c5c5 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-
 ##
 # = Socket data types
 ##
qapi/tpm.json +0 -3
index d50deef5e9..2a33556b22 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = TPM (trusted platform module) devices
 ##
qapi/transaction.json +0 -3
index d7e4274550..ec74f88288 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = Transactions
 ##
qapi/ui.json +0 -3
index 4ca91bb45a..03d0a19da3 100644
@@ -1,6 +1,3 @@
-# -*- Mode: Python -*-
-#
-
 ##
 # = Remote desktop
 ##
.editorconfig +13 -0
index b2022e391a..683c543be3 100644
@@ -6,10 +6,23 @@ end_of_line = lf
 insert_final_newline = true
 charset = utf-8
 
+[*.mak]
+indent_style = tab
+indent_size = 8
+file_type_emacs = makefile
+
 [Makefile*]
 indent_style = tab
 indent_size = 8
+file_type_emacs = makefile
 
 [*.{c,h}]
 indent_style = space
 indent_size = 4
+
+[*.{vert,frag}]
+file_type_emacs = glsl
+
+[*.json]
+indent_style = space
+file_type_emacs = python
Makefile.target +0 -2
index 4d56298bbf..75bae962cd 100644
@@ -1,5 +1,3 @@
-# -*- Mode: makefile -*-
-
 BUILD_DIR?=$(CURDIR)/..
 
 include ../config-host.mak
docs/interop/firmware.json +0 -2
index 28f9bc1591..a2b798118f 100644
@@ -1,5 +1,3 @@
-# -*- Mode: Python -*-
-#
 # Copyright (C) 2018 Red Hat, Inc.
 #
 # Authors:
qga/qapi-schema.json +0 -2
index dfbc4a5e32..447cea7701 100644
@@ -1,5 +1,3 @@
-# *-*- Mode: Python -*-*
-
 ##
 #
 # General note concerning the use of guest agent interfaces:
tests/qapi-schema/doc-good.json +0 -1
index 984cd8ed06..2de41344ff 100644
@@ -1,4 +1,3 @@
-# -*- Mode: Python -*-
 # Positive QAPI doc comment tests
 
 { 'pragma': { 'doc-required': true } }
tests/qapi-schema/qapi-schema-test.json +0 -2
index 11aa4c8f8d..765c30c9db 100644
@@ -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.18.0.547.g1d89318c48
#1 lore raw
Quoted 8 lines · Marc-André Lureau

Some time ago, I proposed to use an (eval) in .dir-locals.el to set the mode for all json files and Makefile. Unfortunately, this isn't safe, and emacs will prompt the user, which isn't very friendly.

Fortunately, editorconfig provides a special config key which does allow to set the emacs mode. Set the emacs mode for JSON, GLSL and extra makefiles that are not yet covered. Drop modeline from JSON files.

Does emacs apply info from the the editorconfig file by default, though?

thanks
-- PMM

#2 lore raw
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Marc-André Lureau

Some time ago, I proposed to use an (eval) in .dir-locals.el to set the mode for all json files and Makefile. Unfortunately, this isn't safe, and emacs will prompt the user, which isn't very friendly.

Quoted 6 lines
Quoted 4 lines

Fortunately, editorconfig provides a special config key which does allow to set the emacs mode. Set the emacs mode for JSON, GLSL and extra makefiles that are not yet covered. Drop modeline from JSON files.

Does emacs apply info from the the editorconfig file by default, though?

Per https://editorconfig.org/, no, you have to first install an emacs plugin to get editorconfig files to have any effect. So this patch is a non-starter unless distros start patching emacs to install that plugin by default.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw

Hi

Quoted 13 lines · Eric Blake
Quoted 11 lines · Peter Maydell
Quoted 8 lines · Marc-André Lureau

Some time ago, I proposed to use an (eval) in .dir-locals.el to set the mode for all json files and Makefile. Unfortunately, this isn't safe, and emacs will prompt the user, which isn't very friendly.

Fortunately, editorconfig provides a special config key which does allow to set the emacs mode. Set the emacs mode for JSON, GLSL and extra makefiles that are not yet covered. Drop modeline from JSON files.

Quoted 6 lines
Quoted 1 line

Does emacs apply info from the the editorconfig file by default, though?

Per https://editorconfig.org/, no, you have to first install an emacs plugin to get editorconfig files to have any effect. So this patch is a non-starter unless distros start patching emacs to install that plugin by default.

But .editorconfing is already present in qemu source tree. (and fwiw, it's installed by default with some starter kits, like prelude).

What's the issue adding the emacs mode in the config file?

Let's keep the modeline in existing files if you prefer, but it's still very limited (a majority of files are not covered). And I would rather see it gone, than having editor-specific lines in our source files.

thanks

#4 lore raw
Quoted 26 lines · Marc-André Lureau

Hi

Quoted 13 lines · Eric Blake
Quoted 11 lines · Peter Maydell
Quoted 8 lines · Marc-André Lureau

Some time ago, I proposed to use an (eval) in .dir-locals.el to set the mode for all json files and Makefile. Unfortunately, this isn't safe, and emacs will prompt the user, which isn't very friendly.

Fortunately, editorconfig provides a special config key which does allow to set the emacs mode. Set the emacs mode for JSON, GLSL and extra makefiles that are not yet covered. Drop modeline from JSON files.

Quoted 6 lines
Quoted 1 line

Does emacs apply info from the the editorconfig file by default, though?

Per https://editorconfig.org/, no, you have to first install an emacs plugin to get editorconfig files to have any effect. So this patch is a non-starter unless distros start patching emacs to install that plugin by default.

But .editorconfing is already present in qemu source tree. (and fwiw, it's installed by default with some starter kits, like prelude).

Quoted 6 lines

What's the issue adding the emacs mode in the config file?

Let's keep the modeline in existing files if you prefer, but it's still very limited (a majority of files are not covered). And I would rather see it gone, than having editor-specific lines in our source files.

I'm fine with adding stuff to .editorconfig that helps users.

Replacing Emacs file local variables by .editorconfig hurts Emacs users that don't have the plugin set up.

I suggest you respin with the deletions dropped, and the additions to .editorconfig limited to ones that still make a difference.