Subject: bug#35373: [PATCH] (info "(emacs) Safe File Variables")

From: 積丹尼 Dan Jacobson <[email-masked]>
Date: Mon, 22 Apr 2019 09:10:24 +0800

-- Append to (info "(emacs) Safe File Variables") --

Sometimes simply postprocessing the local variables is much more
appropriate than eval.

Consider the example on the previous page,

     # Local Variables:
     # compile-command: "cc foo.c ..."
     # End:

To make it work in any file,

     # Local Variables:
     # compile-command: "cc @FILE@ ..."
     # End:

use

(add-hook
 'hack-local-variables-hook
 (function
  (lambda ()
    (if (local-variable-p 'compile-command)
	(setq compile-command
	      (replace-regexp-in-string
	       "@FILE@"
	       (file-name-nondirectory buffer-file-name)
	       compile-command t))))))