GNU bug report logs - #35373
[PATCH] (info "(emacs) Safe File Variables")

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Mon, 22 Apr 2019 01:18:03 UTC

Severity: wishlist

Merged with 6615, 29451, 34130

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35373 in the body.
You can then email your comments to 35373 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35373; Package emacs. (Mon, 22 Apr 2019 01:18:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 22 Apr 2019 01:18:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] (info "(emacs) Safe File Variables")
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))))))




Merged 6615 29451 34130 35373. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 22 Apr 2019 02:09:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35373; Package emacs. (Tue, 23 Apr 2019 01:35:01 GMT) Full text and rfc822 format available.

Message #10 received at 35373 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: 積丹尼 Dan Jacobson
 <jidanni <at> jidanni.org>
Cc: 35373 <at> debbugs.gnu.org
Subject: Re: bug#35373: [PATCH] (info "(emacs) Safe File Variables")
Date: Mon, 22 Apr 2019 21:34:10 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > To make it work in any file,

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

This could be a nice feature to add to Emacs.

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35373; Package emacs. (Tue, 23 Apr 2019 19:31:02 GMT) Full text and rfc822 format available.

Message #13 received at 35373 <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Richard Stallman <rms <at> gnu.org>
Cc: 35373 <at> debbugs.gnu.org
Subject: Re: bug#35373: [PATCH] (info "(emacs) Safe File Variables")
Date: Wed, 24 Apr 2019 03:29:58 +0800
>> # Local Variables:
>> # compile-command: "cc @FILE@ ..."
>> # End:

Yes, the brilliant thing about this is @FILE@ is the only item needed.

Naysayers would say "first you want @FILE@, next week you will want
@PWD@, next month you will want @CURRENT_DATE@..."

But that's not true. All the rest can be simply determined by the shell,
e.g., $PWD.

Naysayers will also say "For the filename just use $(ls -t|sed q). Case
closed." Yes but that is playing Russian roulette.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35373; Package emacs. (Tue, 23 Apr 2019 22:06:02 GMT) Full text and rfc822 format available.

Message #16 received at 35373 <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Richard Stallman <rms <at> gnu.org>
Cc: 35373 <at> debbugs.gnu.org
Subject: Re: bug#35373: [PATCH] (info "(emacs) Safe File Variables")
Date: Wed, 24 Apr 2019 06:05:25 +0800
(Alas my personal implementation sometimes runs into problems...)

Debugger entered--Lisp error: (wrong-type-argument stringp (save-excursion (beginning-of-line) (if (or (looking-at makefile-macroassign-regex) (looking-at makefile-dependency-regex) (makefile-previous-dependency)) (concat "make " (match-string-no-properties 1)) (or (car compile-history) "make "))))
  string-match("@FILE@" (save-excursion (beginning-of-line) (if (or (looking-at makefile-macroassign-regex) (looking-at makefile-dependency-regex) (makefile-previous-dependency)) (concat "make " (match-string-no-properties 1)) (or (car compile-history) "make "))) 0)
  replace-regexp-in-string("@FILE@" "Makefile" (save-excursion (beginning-of-line) (if (or (looking-at makefile-macroassign-regex) (looking-at makefile-dependency-regex) (makefile-previous-dependency)) (concat "make " (match-string-no-properties 1)) (or (car compile-history) "make "))) t)
  (setq compile-command (replace-regexp-in-string "@FILE@" (file-name-nondirectory buffer-file-name) compile-command t))
  (if (and compile-command (local-variable-if-set-p 'compile-command)) (setq compile-command (replace-regexp-in-string "@FILE@" (file-name-nondirectory buffer-file-name) compile-command t)))
  (lambda nil (if (and compile-command (local-variable-if-set-p 'compile-command)) (setq compile-command (replace-regexp-in-string "@FILE@" (file-name-nondirectory buffer-file-name) compile-command t))))()
  run-hooks(hack-local-variables-hook)
  hack-local-variables-apply()
  hack-local-variables(no-mode)
  run-mode-hooks(makefile-gmake-mode-hook)
  makefile-gmake-mode()
  set-auto-mode-0(makefile-gmake-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(t t)
  find-file-noselect-1(#<buffer Makefile> "/tmp/Makefile" nil nil "/tmp/Makefile" nil)
  find-file-noselect("/tmp/Makefile" nil nil nil)
  find-file("/tmp/Makefile")
  find-file-at-point(nil)
  (let ((ffap-url-fetcher (if current-prefix-arg (function my-browse-url-default-browser) (function w3m-browse-url))) (current-prefix-arg nil)) (find-file-at-point filename))
  my-ffap()
  funcall-interactively(my-ffap)
  call-interactively(my-ffap nil nil)
  command-execute(my-ffap)






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35373; Package emacs. (Wed, 24 Apr 2019 22:28:02 GMT) Full text and rfc822 format available.

Message #19 received at 35373 <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Richard Stallman <rms <at> gnu.org>
Cc: 35373 <at> debbugs.gnu.org
Subject: Re: bug#35373: [PATCH] (info "(emacs) Safe File Variables")
Date: Thu, 25 Apr 2019 06:26:56 +0800
And it seems
hack-local-variables-hook
should also be
hack-local-variables-hook-pre
hack-local-variables-hook-post
to avoid such bugs (or an example of how to use it safely given.)
(No I don't want to just "advise" the function.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35373; Package emacs. (Thu, 25 Apr 2019 02:12:02 GMT) Full text and rfc822 format available.

Message #22 received at 35373 <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Richard Stallman <rms <at> gnu.org>
Cc: 35373 <at> debbugs.gnu.org
Subject: Re: bug#35373: [PATCH] (info "(emacs) Safe File Variables")
Date: Thu, 25 Apr 2019 10:11:32 +0800
No, I don't know why it blows up. Reproduce with
https://www.jidanni.org/comp/configuration/.emacs
$ > /tmp/Makefile
$ emacs /tmp/Makefile




bug closed, send any further explanations to 6615 <at> debbugs.gnu.org and jidanni <at> jidanni.org Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 01 Oct 2019 19:29:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 02 Nov 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 175 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.