From: Vitalie Spinu <spinuvit@gmail.com>
To: Rainer M Krug <Rainer@krugs.de>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Don't ask "File changed on disk" in org-babel-post-tangle-hook
Date: Fri, 07 Jun 2013 12:57:10 +0200 [thread overview]
Message-ID: <87fvwufat5.fsf_-_@gmail.com> (raw)
In-Reply-To: <87wqq6uxrg.fsf@krugs.de> (Rainer M. Krug's message of "Fri, 07 Jun 2013 10:32:19 +0200")
[-- Attachment #1: Type: text/plain, Size: 531 bytes --]
The problem with org-babel-post-tangle-hook is that user is always asked
yes-or-no-p for file reversion. Calling auto revert (as Rainer tried)
will not help.
The problem is in find-file-noselect in org-babel-find-file-noselect-refresh.
The following patch fixes it by silencing find-file-noselect. Besides
reversion question, there are a couple of other warning/questions that
are silenced, but given that org-babel-find-file-noselect-refresh is
used only for reverting tangled files, this is probably not an issue.
Vitalie
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-avoid-file-warnings-in-org-babel-post-tangle-hook.patch --]
[-- Type: text/x-diff, Size: 941 bytes --]
From 2f408019b940c7e3b742dd2941f725f97645b868 Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <spinuvit@gmail.com>
Date: Fri, 7 Jun 2013 12:43:55 +0200
Subject: [PATCH] avoid file warnings in org-babel-post-tangle-hook
* lisp/ob-tangle.el (org-babel-find-file-noselect-refresh): call
find-file-noselect with 'nowarn argument to surpress yes-or-no-p
reversion message.
---
lisp/ob-tangle.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 95d518a..82f2c10 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -114,7 +114,7 @@ result. The default value is `org-babel-trim'."
(defun org-babel-find-file-noselect-refresh (file)
"Find file ensuring that the latest changes on disk are
represented in the file."
- (find-file-noselect file)
+ (find-file-noselect file 'nowarn)
(with-current-buffer (get-file-buffer file)
(revert-buffer t t t)))
--
1.8.1.2
[-- Attachment #3: Type: text/plain, Size: 2376 bytes --]
>> Rainer M Krug <Rainer@krugs.de>
>> on Fri, 07 Jun 2013 10:32:19 +0200 wrote:
> Rainer M Krug <Rainer@krugs.de> writes:
> [snip (54 lines)]
>>>>> ,----
>>>>> | (defvar org-babel-tangled-file nil
>>>>> | "If non-nill, current file was tangled with org-babel-tangle")
>>>>> | (put 'org-babel-tangled-file 'safe-local-variable 'booleanp)
>>>>> |
>>>>> | (defun org-babel-mark-file-as-tangled ()
>>>>> | (add-file-local-variable 'org-babel-tangled-file t)
>>>>> | (basic-save-buffer))
>>>>> |
>>>>> | (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled)
>>>>> `----
>>>>>
>>>
>>> I think the above code should be considered an implementation rather
>>> than simply a test. This is exactly what the post-tangle hook is
>>> intended to support. Is there a motivating reason for this behavior to
>>> be "built in"?
>>
>> As pointed out, I think the possibility to easily add local variables to
>> the tangled file, will be valuable. I would opt for an the buil-in
>> option, as this could e.g. be used to set the file read-only in emacs,
>> adding svn information, etc.
>>
>> This could be achieved by supplying one variable containing strings,
>> which contains the names of the local variables to be added and their values.
>>
>> For the time being, I will add the suggested code to my emacs.org.
> I stumbled upon one problem, though: I want to mame the tengled file,
> when nopened in emacs, to have the minor mode auto-revert-mode. So I did
> the following, which obviously did not work:
> ,----
> | (defvar org-babel-tangled-file nil
> | "If non-nill, current file was tangled with org-babel-tangle")
> | (put 'org-babel-tangled-file 'safe-local-variable 'booleanp)
> |
> | (defun org-babel-mark-file-as-tangled ()
> | (add-file-local-variable 'org-babel-tangled-file t)
> | (add-file-local-variable 'buffer-read-only t)
> | (add-file-local-variable 'eval: (auto-revert-mode))
> | (basic-save-buffer))
> |
> | (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled)
> `----
> So is tere a way, of adding the line
> ,----
> | eval: (auto-revert-mode)
> `----
> to the file local variables, so that emacs sutomatically enables
> auto-revert-mode?
> Thanks,
> Rainer
>>
>>>
>>
> [snip (38 lines)]
next prev parent reply other threads:[~2013-06-07 10:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 14:04 Automatically adding local variables to tangled file Rainer M Krug
2013-06-05 14:32 ` Darlan Cavalcante Moreira
2013-06-05 15:41 ` Vitalie Spinu
2013-06-05 16:15 ` Rainer M Krug
2013-06-06 7:53 ` Sebastien Vauban
2013-06-06 16:01 ` Eric Schulte
2013-06-07 7:57 ` Rainer M Krug
2013-06-07 8:32 ` Rainer M Krug
2013-06-07 10:57 ` Vitalie Spinu [this message]
2013-06-07 13:23 ` [PATCH] Don't ask "File changed on disk" in org-babel-post-tangle-hook Eric Schulte
2013-06-07 13:47 ` Rainer M Krug
2013-06-08 18:23 ` Automatically adding local variables to tangled file Eric Schulte
2013-06-08 20:59 ` Achim Gratz
2013-06-08 21:17 ` Eric Schulte
2013-06-10 8:02 ` Rainer M Krug
2013-06-10 10:12 ` Problem in tangle-mode -- WAS: " Rainer M Krug
2013-06-10 15:58 ` Eric Schulte
2013-06-11 7:25 ` BUG - Problem in tangle-mode Rainer M Krug
2013-06-11 13:09 ` Eric Schulte
2013-06-11 18:25 ` Rainer M Krug
2013-06-12 15:15 ` Rainer M Krug
2013-06-12 21:42 ` Eric Schulte
2013-06-13 7:28 ` Rainer M Krug
2013-06-10 11:32 ` SOLVED: Automatically adding local variables to tangled file Rainer M Krug
2013-06-05 17:10 ` Thorsten Jolitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fvwufat5.fsf_-_@gmail.com \
--to=spinuvit@gmail.com \
--cc=Rainer@krugs.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.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).