emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [babel] using tramp when tangling


From: Rémi Vanicat
Subject: [Orgmode] Re: [babel] using tramp when tangling
Date: Wed, 17 Mar 2010 20:57:21 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Maurizio Vitale <address@hidden> writes:

> I'd find useful to use tramp syntax in the :tangle specification.
> In my case it would be to specify sudo when tangling config files that
> are supposed to go to areas not writable by the user running Emacs. 
> Something like:
>
> #+begin_src sh :tangle /sudo::/etc/my_config_file
> ...
> #+end_src
>
> other people might be interested in remote access to tangle targets.
>
> Is there a way to achieve the above?
>
> If I try to tangle the above, I get something along the lines that
> "tramp cannot append to file". Would it be possible to have org-babel to
> (optionally) tangle to a buffer and then save to file in one go?

It's a bug of append-file. We could not use it: (code by Alexey Voinov,
stolen from magit):

--8<---------------cut here---------------start------------->8---
diff --git a/contrib/babel/lisp/org-babel-tangle.el 
b/contrib/babel/lisp/org-babel-tangle.el
index dd76195..c4ea0d8 100644
--- a/contrib/babel/lisp/org-babel-tangle.el
+++ b/contrib/babel/lisp/org-babel-tangle.el
@@ -127,7 +127,12 @@ exported source code blocks by language."
                         (insert (concat she-bang "\n"))
                         (setq she-banged (cons file-name she-banged)))
                       (org-babel-spec-to-string spec)
-                      (append-to-file nil nil file-name))
+                     (let ((content (buffer-string)))
+                       (with-temp-buffer
+                         (insert-file-contents file-name)
+                         (goto-char (point-max))
+                         (insert content)
+                         (write-region nil nil ignore-file))))
                     ;; update counter
                     (setq block-counter (+ 1 block-counter))
                     (add-to-list 'path-collector file-name)))))
--8<---------------cut here---------------end--------------->8---


-- 
Rémi Vanicat





reply via email to

[Prev in Thread] Current Thread [Next in Thread]