On 01/30/2015 07:13 PM, Nicolas Goaziou wrote:
> Sami Airaksinen <samia...@gmail.com> writes:
>
>> I got confused, do you want a comment in the source code or in the commit
>> message?
> The former.
>
>> So comment in the source code would be something like,
>> "tangle-file traversal returns reversed list of tangled files and we want
>> to evaluate the first target"
> That's fine.
>
>> If explanation is for car+last combo: (car (last ...)) the car is needed
>> because (last ...) returns the last link which is list of one element.
> No it isn't about car+last but why we're interested in the last element
> instead of the first one.
>
> Thanks,

-- 
Sami Airaksinen

From 6fcb4b222e308c97d4c90b96ac73234c1951f307 Mon Sep 17 00:00:00 2001
From: Sami Airaksinen <samia...@gmail.com>
Date: Thu, 29 Jan 2015 23:10:02 +0200
Subject: [PATCH] org.el: org-babel-load-file loads first tangle file

(org-babel-load-file): When org-mode FILE has multiple target files
for tangle blocks, `exported-file' will be set to last found
target file, which might not be the `file'.

Therefore fix for this bug is to select the last element of that
tangled file list, which is the tangle target file of the first found
tangle block, most typically the `file'.

TINYCHANGE
---
 lisp/org.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index b0e4380..e87de90 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -235,8 +235,9 @@ file to byte-code before it is loaded."
     ;; tangle if the org-mode file is newer than the elisp file
     (unless (and (file-exists-p exported-file)
 		 (> (funcall age file) (funcall age exported-file)))
+      ;; tangle-file traversal returns reversed list of tangled files and we want to evaluate the first target
       (setq exported-file
-	    (car (org-babel-tangle-file file exported-file "emacs-lisp"))))
+	    (car (last (org-babel-tangle-file file exported-file "emacs-lisp")))))
     (message "%s %s"
 	     (if compile
 		 (progn (byte-compile-file exported-file 'load)
-- 
1.9.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to