* [PATCH] org.el: org-babel-load-file loads first tangle file
@ 2015-01-29 21:49 Sami Airaksinen
2015-01-30 9:44 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Sami Airaksinen @ 2015-01-29 21:49 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 698 bytes --]
Hi,
I use quite sophisticated (read complicated) initialization of my emacs.
Now I finally updated my emacs and org-mode upto date and found out that
org-babel-load-file doesn't work as previously.
I don't know if you have already noticed but if your tangled source
org-mode file has multiple target files for the tangle blocks, it loads
the file which was found last. This most often isn't the file name that
was given as input. There could be more generic solution to this, but I
though that it might be best to keep this patching simple as possible.
This is my first patch proposal so I hope I'm doing right and adding it
as an attachment to this post
--
Sami Airaksinen
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-org-babel-load-file-loads-first-tangle-file.patch --]
[-- Type: text/x-patch; name="0001-org.el-org-babel-load-file-loads-first-tangle-file.patch", Size: 1291 bytes --]
From fe2c30fb06935ce871485b4e3816313d59d96cbe Mon Sep 17 00:00:00 2001
From: Sami Airaksinen <samiaira@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'.
Suggestion from a patch proposal by Sami Airaksinen
TINYCHANGE
---
lisp/org.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/org.el b/lisp/org.el
index b0e4380..2bc7f30 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -236,7 +236,7 @@ file to byte-code before it is loaded."
(unless (and (file-exists-p exported-file)
(> (funcall age file) (funcall age exported-file)))
(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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] org.el: org-babel-load-file loads first tangle file
2015-01-29 21:49 [PATCH] org.el: org-babel-load-file loads first tangle file Sami Airaksinen
@ 2015-01-30 9:44 ` Nicolas Goaziou
2015-01-30 12:55 ` Sami Airaksinen
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2015-01-30 9:44 UTC (permalink / raw)
To: Sami Airaksinen; +Cc: emacs-orgmode
Hello,
Sami Airaksinen <samiaira@gmail.com> writes:
> I use quite sophisticated (read complicated) initialization of my emacs.
> Now I finally updated my emacs and org-mode upto date and found out that
> org-babel-load-file doesn't work as previously.
>
> I don't know if you have already noticed but if your tangled source
> org-mode file has multiple target files for the tangle blocks, it loads
> the file which was found last. This most often isn't the file name that
> was given as input. There could be more generic solution to this, but I
> though that it might be best to keep this patching simple as possible.
>
> This is my first patch proposal so I hope I'm doing right and adding it
> as an attachment to this post
It looks good, thank you.
However, could you also add a comment above the modified line in order
to explain the car+last call?
[...]
> Suggestion from a patch proposal by Sami Airaksinen
The line above is not necessary since you're the author of the patch
anyway.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] org.el: org-babel-load-file loads first tangle file
2015-01-30 9:44 ` Nicolas Goaziou
@ 2015-01-30 12:55 ` Sami Airaksinen
2015-01-30 17:13 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Sami Airaksinen @ 2015-01-30 12:55 UTC (permalink / raw)
To: Sami Airaksinen, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
I got confused, do you want a comment in the source code or in the commit
message?
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"
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.
[-- Attachment #2: Type: text/html, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] org.el: org-babel-load-file loads first tangle file
2015-01-30 12:55 ` Sami Airaksinen
@ 2015-01-30 17:13 ` Nicolas Goaziou
2015-01-31 22:20 ` Sami Airaksinen
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2015-01-30 17:13 UTC (permalink / raw)
To: Sami Airaksinen; +Cc: emacs-orgmode
Sami Airaksinen <samiaira@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,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] org.el: org-babel-load-file loads first tangle file
2015-01-30 17:13 ` Nicolas Goaziou
@ 2015-01-31 22:20 ` Sami Airaksinen
2015-01-31 23:04 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Sami Airaksinen @ 2015-01-31 22:20 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 696 bytes --]
On 01/30/2015 07:13 PM, Nicolas Goaziou wrote:
> Sami Airaksinen <samiaira@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-org-babel-load-file-loads-first-tangle-file.patch --]
[-- Type: text/x-patch; name="0001-org.el-org-babel-load-file-loads-first-tangle-file.patch", Size: 1417 bytes --]
From 6fcb4b222e308c97d4c90b96ac73234c1951f307 Mon Sep 17 00:00:00 2001
From: Sami Airaksinen <samiaira@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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] org.el: org-babel-load-file loads first tangle file
2015-01-31 22:20 ` Sami Airaksinen
@ 2015-01-31 23:04 ` Nicolas Goaziou
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2015-01-31 23:04 UTC (permalink / raw)
To: Sami Airaksinen; +Cc: emacs-orgmode
Sami Airaksinen <samiaira@gmail.com> writes:
> From 6fcb4b222e308c97d4c90b96ac73234c1951f307 Mon Sep 17 00:00:00 2001
> From: Sami Airaksinen <samiaira@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'.
Applied. Thank you.
Regards,
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-01-31 23:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-29 21:49 [PATCH] org.el: org-babel-load-file loads first tangle file Sami Airaksinen
2015-01-30 9:44 ` Nicolas Goaziou
2015-01-30 12:55 ` Sami Airaksinen
2015-01-30 17:13 ` Nicolas Goaziou
2015-01-31 22:20 ` Sami Airaksinen
2015-01-31 23:04 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).