Rainer M Krug <rai...@krugs.de> writes:

> Kyle Meyer <k...@kyleam.com> writes:
>
>> Rainer M Krug <rai...@krugs.de> writes:
>>
>>> Hi
>>>
>>> it seems that tangling from an indirect buffer does not work. Is this by
>>> design or a bug?
>>
>> I don't think that's by design.
>>
>>> Would it be possible to make this possible?
>>
>> Does the below patch work for you?  If so, I can test it more thoroughly
>> and send a proper patch.
>
> Yes - works perfectly. I would really appreciate this. Please submit.

Patch against maint attached.

>From 57beac5636d8be61c0e778d8b3f6da9d6ad208a6 Mon Sep 17 00:00:00 2001
From: Kyle Meyer <k...@kyleam.com>
Date: Tue, 8 Sep 2015 23:48:44 -0400
Subject: [PATCH] Fix tangling in indirect buffers

* lisp/ob-tangle.el (org-babel-tangle-single-block): Get file name from
  base buffer.
(org-babel-tangle): Use file name from attribute list returned by
org-babel-tangle-single-block.

Reported-by: Rainer M Krug <rai...@krugs.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/100845>
---
 lisp/ob-tangle.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index d20c2b3..cf48db3 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -242,7 +242,7 @@ (defun org-babel-tangle (&optional arg target-file lang)
 			 (base-name (cond
 				     ((string= "yes" tangle)
 				      (file-name-sans-extension
-				       (buffer-file-name)))
+				       (nth 1 spec)))
 				     ((string= "no" tangle) nil)
 				     ((> (length tangle) 0) tangle)))
 			 (file-name (when base-name
@@ -427,7 +427,7 @@ (defun org-babel-tangle-single-block
 	 (start-line
 	  (save-restriction (widen)
 			    (+ 1 (line-number-at-pos (point)))))
-	 (file (buffer-file-name))
+	 (file (buffer-file-name (buffer-base-buffer)))
 	 (src-lang (nth 0 info))
 	 (params (nth 2 info))
 	 (extra (nth 3 info))
-- 
2.5.1

--
Kyle

Reply via email to