Maurizio Vitale <[email protected]>
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
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-orgmode