Browse Source

babel: Allow tramp syntax when supplying :tangle filename

Patch by Rémi Vanicat.
Dan Davison 15 years ago
parent
commit
73d8e57685
1 changed files with 8 additions and 1 deletions
  1. 8 1
      contrib/babel/lisp/org-babel-tangle.el

+ 8 - 1
contrib/babel/lisp/org-babel-tangle.el

@@ -127,7 +127,14 @@ 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))
+		      ;; We avoid append-to-file as it does not work with tramp.
+		      (let ((content (buffer-string)))
+			(with-temp-buffer
+			  (if (file-exists-p file-name)
+			      (insert-file-contents file-name))
+			  (goto-char (point-max))
+			  (insert content)
+			  (write-region nil nil file-name))))
                     ;; update counter
                     (setq block-counter (+ 1 block-counter))
                     (add-to-list 'path-collector file-name)))))