all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: "Rémi Vanicat" <vanicat@debian.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: [babel] using tramp when tangling
Date: Wed, 17 Mar 2010 21:08:54 -0400	[thread overview]
Message-ID: <87aau6jv15.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <87k4ta202m.dlv@debian.org> ("Rémi Vanicat"'s message of "Wed, 17 Mar 2010 20:57:21 +0100")

vanicat@debian.org (Rémi Vanicat) writes:

> Maurizio Vitale <mav@cuma.i-did-not-set--mail-host-address--so-tickle-me> 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):

Well that was solved quickly. Thanks Rémi, 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)))))

  reply	other threads:[~2010-03-18  1:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-17 18:39 [babel] using tramp when tangling Maurizio Vitale
2010-03-17 19:57 ` Rémi Vanicat
2010-03-18  1:08   ` Dan Davison [this message]
2010-03-17 20:06 ` Dan Davison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aau6jv15.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=vanicat@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.