* bug#35373: [PATCH] (info "(emacs) Safe File Variables")
@ 2019-04-22 1:10 積丹尼 Dan Jacobson
2019-04-23 1:34 ` Richard Stallman
0 siblings, 1 reply; 6+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-04-22 1:10 UTC (permalink / raw)
To: 35373
-- 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))))))
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#35373: [PATCH] (info "(emacs) Safe File Variables")
2019-04-22 1:10 bug#35373: [PATCH] (info "(emacs) Safe File Variables") 積丹尼 Dan Jacobson
@ 2019-04-23 1:34 ` Richard Stallman
2019-04-23 19:29 ` 積丹尼 Dan Jacobson
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Richard Stallman @ 2019-04-23 1:34 UTC (permalink / raw)
To: ç©ä¸¹å°¼ Dan Jacobson; +Cc: 35373
[[[ 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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#35373: [PATCH] (info "(emacs) Safe File Variables")
2019-04-23 1:34 ` Richard Stallman
@ 2019-04-23 19:29 ` 積丹尼 Dan Jacobson
2019-04-23 22:05 ` 積丹尼 Dan Jacobson
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-04-23 19:29 UTC (permalink / raw)
To: Richard Stallman; +Cc: 35373
>> # 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#35373: [PATCH] (info "(emacs) Safe File Variables")
2019-04-23 1:34 ` Richard Stallman
2019-04-23 19:29 ` 積丹尼 Dan Jacobson
@ 2019-04-23 22:05 ` 積丹尼 Dan Jacobson
2019-04-24 22:26 ` 積丹尼 Dan Jacobson
2019-04-25 2:11 ` 積丹尼 Dan Jacobson
3 siblings, 0 replies; 6+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-04-23 22:05 UTC (permalink / raw)
To: Richard Stallman; +Cc: 35373
(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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#35373: [PATCH] (info "(emacs) Safe File Variables")
2019-04-23 1:34 ` Richard Stallman
2019-04-23 19:29 ` 積丹尼 Dan Jacobson
2019-04-23 22:05 ` 積丹尼 Dan Jacobson
@ 2019-04-24 22:26 ` 積丹尼 Dan Jacobson
2019-04-25 2:11 ` 積丹尼 Dan Jacobson
3 siblings, 0 replies; 6+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-04-24 22:26 UTC (permalink / raw)
To: Richard Stallman; +Cc: 35373
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.)
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#35373: [PATCH] (info "(emacs) Safe File Variables")
2019-04-23 1:34 ` Richard Stallman
` (2 preceding siblings ...)
2019-04-24 22:26 ` 積丹尼 Dan Jacobson
@ 2019-04-25 2:11 ` 積丹尼 Dan Jacobson
3 siblings, 0 replies; 6+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-04-25 2:11 UTC (permalink / raw)
To: Richard Stallman; +Cc: 35373
No, I don't know why it blows up. Reproduce with
https://www.jidanni.org/comp/configuration/.emacs
$ > /tmp/Makefile
$ emacs /tmp/Makefile
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-04-25 2:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-22 1:10 bug#35373: [PATCH] (info "(emacs) Safe File Variables") 積丹尼 Dan Jacobson
2019-04-23 1:34 ` Richard Stallman
2019-04-23 19:29 ` 積丹尼 Dan Jacobson
2019-04-23 22:05 ` 積丹尼 Dan Jacobson
2019-04-24 22:26 ` 積丹尼 Dan Jacobson
2019-04-25 2:11 ` 積丹尼 Dan Jacobson
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).