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 $^ > $@)