From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Re: [babel] using tramp when tangling Date: Wed, 17 Mar 2010 21:08:54 -0400 Message-ID: <87aau6jv15.fsf@stats.ox.ac.uk> References: <87tyserdw0.fsf@cuma.i-did-not-set--mail-host-address--so-tickle-me> <87k4ta202m.dlv@debian.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ns4ES-0003Fo-EH for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 21:09:04 -0400 Received: from [140.186.70.92] (port=60412 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ns4ER-0003Dd-1z for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 21:09:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ns4EO-0005mu-JS for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 21:09:02 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:44728) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ns4EO-0005mT-Cl for emacs-orgmode@gnu.org; Wed, 17 Mar 2010 21:09:00 -0400 In-Reply-To: <87k4ta202m.dlv@debian.org> (=?utf-8?Q?=22R=C3=A9mi?= Vanicat"'s message of "Wed, 17 Mar 2010 20:57:21 +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: =?utf-8?Q?R=C3=A9mi?= Vanicat Cc: emacs-orgmode@gnu.org vanicat@debian.org (R=C3=A9mi Vanicat) writes: > 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.=20 >> 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): Well that was solved quickly. Thanks R=C3=A9mi, I've applied that with a couple of minor changes. Dan > > 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)))))