浏览代码

babel: Allow tramp syntax when supplying :tangle filename

Patch by Rémi Vanicat.
Dan Davison 15 年之前
父节点
当前提交
73d8e57685
共有 1 个文件被更改,包括 8 次插入1 次删除
  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)))))