summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-12-03 23:55:28 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-12-03 23:55:28 +0100
commit026fb75ddbddb8b8965c40b82a381ff5b8e92516 (patch)
tree48f39db73792c868d0c235da0279ed4bdccea038
parente72485336fdcaf568c4afc3ca76913f9ecb9495f (diff)
downloadorg-mode-026fb75ddbddb8b8965c40b82a381ff5b8e92516.tar.gz
ob-tangle: Respect buffer local variables
* lisp/ob-tangle.el (org-babel-tangle): Make sure buffer local variables from Org document are taken into consideration in tangled document. Reported-by: David Dynerman <emperordali@block-party.net> <http://permalink.gmane.org/gmane.emacs.orgmode/110577>
-rw-r--r--lisp/ob-tangle.el51
1 files changed, 32 insertions, 19 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 5e1b953..1b84fd2 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -271,25 +271,38 @@ used to limit the exported source code blocks by language."
(and (file-exists-p file-name)
(not (member file-name (mapcar #'car path-collector)))
(delete-file file-name))
- ;; drop source-block to file
- (with-temp-buffer
- (when (fboundp lang-f) (ignore-errors (funcall lang-f)))
- (when (and she-bang (not (member file-name she-banged)))
- (insert (concat she-bang "\n"))
- (setq she-banged (cons file-name she-banged)))
- (org-babel-spec-to-string spec)
- ;; We avoid append-to-file as it does not work with tramp.
- (let ((content (buffer-string)))
- (with-temp-buffer
- (when (file-exists-p file-name)
- (insert-file-contents file-name))
- (goto-char (point-max))
- ;; Handle :padlines unless first line in file
- (unless (or (string= "no" (cdr (assq :padline (nth 4 spec))))
- (= (point) (point-min)))
- (insert "\n"))
- (insert content)
- (write-region nil nil file-name))))
+ ;; Drop source-block to file. Preserve local
+ ;; file variables set in original Org buffer so
+ ;; that `org-babel-spec-to-string' doesn't
+ ;; ignore them.
+ (let ((org-babel-tangle-use-relative-file-links
+ org-babel-tangle-use-relative-file-links)
+ (org-babel-tangle-uncomment-comments
+ org-babel-tangle-uncomment-comments)
+ (org-babel-tangle-comment-format-beg
+ org-babel-tangle-comment-format-beg)
+ (org-src-preserve-indentation
+ org-src-preserve-indentation)
+ (org-babel-tangle-comment-format-end
+ org-babel-tangle-comment-format-end))
+ (with-temp-buffer
+ (when (fboundp lang-f) (ignore-errors (funcall lang-f)))
+ (when (and she-bang (not (member file-name she-banged)))
+ (insert (concat she-bang "\n"))
+ (setq she-banged (cons file-name she-banged)))
+ (org-babel-spec-to-string spec)
+ ;; We avoid append-to-file as it does not work with tramp.
+ (let ((content (buffer-string)))
+ (with-temp-buffer
+ (when (file-exists-p file-name)
+ (insert-file-contents file-name))
+ (goto-char (point-max))
+ ;; Handle :padlines unless first line in file
+ (unless (or (string= "no" (cdr (assq :padline (nth 4 spec))))
+ (= (point) (point-min)))
+ (insert "\n"))
+ (insert content)
+ (write-region nil nil file-name)))))
;; if files contain she-bangs, then make the executable
(when she-bang
(unless tangle-mode (setq tangle-mode #o755)))