emacs-orgmode
[Top][All Lists]
Advanced

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

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


From: Dan Davison
Subject: Re: [Orgmode] Re: [babel] using tramp when tangling
Date: Wed, 17 Mar 2010 21:08:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

address@hidden (Rémi Vanicat) writes:

> 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):

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 via email to

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