emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] using tramp when tangling
@ 2010-03-17 18:39 Maurizio Vitale
  2010-03-17 19:57 ` Rémi Vanicat
  2010-03-17 20:06 ` Dan Davison
  0 siblings, 2 replies; 4+ messages in thread
From: Maurizio Vitale @ 2010-03-17 18:39 UTC (permalink / raw)
  To: emacs-orgmode


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?

Thanks a lot for the excellent addition to org-mode.

       Maurizio 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [babel] using tramp when tangling
  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
  2010-03-17 20:06 ` Dan Davison
  1 sibling, 1 reply; 4+ messages in thread
From: Rémi Vanicat @ 2010-03-17 19:57 UTC (permalink / raw)
  To: emacs-orgmode

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

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [babel] using tramp when tangling
  2010-03-17 18:39 [babel] using tramp when tangling Maurizio Vitale
  2010-03-17 19:57 ` Rémi Vanicat
@ 2010-03-17 20:06 ` Dan Davison
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Davison @ 2010-03-17 20:06 UTC (permalink / raw)
  To: maurizio.vitale; +Cc: emacs-orgmode

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?

I would like this to be possible. As you suggest, the change would
involve not using append-to-file; it shouldn't be that hard. I've added
it to the org-babel TODO list, but if you or anyone else would like to
have a go that would be great.

Dan


>
> Thanks a lot for the excellent addition to org-mode.
>
>        Maurizio 
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [babel] using tramp when tangling
  2010-03-17 19:57 ` Rémi Vanicat
@ 2010-03-18  1:08   ` Dan Davison
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Davison @ 2010-03-18  1:08 UTC (permalink / raw)
  To: Rémi Vanicat; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-18  1:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2010-03-17 20:06 ` Dan Davison

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).