From mboxrd@z Thu Jan 1 00:00:00 1970 From: vanicat@debian.org (=?utf-8?Q?R=C3=A9mi?= Vanicat) Subject: Re: [babel] using tramp when tangling Date: Wed, 17 Mar 2010 20:57:21 +0100 Message-ID: <87k4ta202m.dlv@debian.org> References: <87tyserdw0.fsf@cuma.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrzNK-0006RN-6a for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 15:57:54 -0400 Received: from [140.186.70.92] (port=39268 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrzNF-0006La-GI for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 15:57:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NrzND-0003s3-L5 for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 15:57:49 -0400 Received: from lo.gmane.org ([80.91.229.12]:52066) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NrzND-0003rp-B6 for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 15:57:47 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NrzN9-0002WA-HM for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 20:57:43 +0100 Received: from 88-136-167-220.adslgp.cegetel.net ([88.136.167.220]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Mar 2010 20:57:43 +0100 Received: from vanicat by 88-136-167-220.adslgp.cegetel.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Mar 2010 20:57:43 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Maurizio Vitale 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