Re: [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode

2017-09-01 Thread Markus Armbruster
Marc-André Lureau  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 
> ---
>  .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 $^ > $@)



Re: [Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode

2017-08-31 Thread Eric Blake
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 
> ---

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH 1/2] .dir-locals.el: add makefiles to auto-mode

2017-08-31 Thread 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 
---
 .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