From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vitalie Spinu Subject: [PATCH] Don't ask "File changed on disk" in org-babel-post-tangle-hook Date: Fri, 07 Jun 2013 12:57:10 +0200 Message-ID: <87fvwufat5.fsf_-_@gmail.com> References: <878v2omz5g.fsf@krugs.de> <51af4bfd.0c95ec0a.2372.097e@mx.google.com> <87ehcf6xey.fsf@gmail.com> <87ehcewdye.fsf@krugs.de> <87wqq6uxrg.fsf@krugs.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkuMA-0002wA-Ba for emacs-orgmode@gnu.org; Fri, 07 Jun 2013 06:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkuM5-0000xm-HY for emacs-orgmode@gnu.org; Fri, 07 Jun 2013 06:57:18 -0400 Received: from mail-wg0-x231.google.com ([2a00:1450:400c:c00::231]:51719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkuM5-0000vz-83 for emacs-orgmode@gnu.org; Fri, 07 Jun 2013 06:57:13 -0400 Received: by mail-wg0-f49.google.com with SMTP id a12so1147804wgh.28 for ; Fri, 07 Jun 2013 03:57:12 -0700 (PDT) In-Reply-To: <87wqq6uxrg.fsf@krugs.de> (Rainer M. Krug's message of "Fri, 07 Jun 2013 10:32:19 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rainer M Krug Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-avoid-file-warnings-in-org-babel-post-tangle-hook.patch >From 2f408019b940c7e3b742dd2941f725f97645b868 Mon Sep 17 00:00:00 2001 From: Vitalie Spinu 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 --=-=-= Content-Type: text/plain >> Rainer M Krug >> on Fri, 07 Jun 2013 10:32:19 +0200 wrote: > Rainer M Krug 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)] --=-=-=--