* [PATCH] link descriptions in :file results of src blocks
@ 2012-03-27 8:56 Andreas Leha
2012-03-27 9:16 ` Bastien
2012-03-31 14:09 ` Eric Schulte
0 siblings, 2 replies; 8+ messages in thread
From: Andreas Leha @ 2012-03-27 8:56 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 867 bytes --]
Hi all,
this small patch adds :filelinkdescr to the list of possible header
arguments for babel source blocks.
Its intented functionality is to allow source blocks to return links to
files with description.
Two small examples:
,----[ example1 ]
| #+begin_src R :results graphics :file test.png :filelinkdescr here
| plot(1:10)
| #+end_src
|
| #+results:
| [[file:test.png][here]]
`----
,----[ example2 ]
| #+begin_src R :results graphics :file test2.png :filelinkdescr
| plot(1:10)
| #+end_src
|
| #+results:
| [[file:test2.png][test2.png]]
`----
If used with value ("here" in the example1) that value will become the
description. If used without value (as in example2), the description is
taken from either the :file header argument or the results of the code block
evaluation (in that order).
Have not done much testing yet, though.
Regards,
Andreas
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-new-source-block-header-argument-filelinkdescr.patch --]
[-- Type: text/x-diff, Size: 1408 bytes --]
From 698570cb9938ee1f4dd1472cb13b32d08d108cbb Mon Sep 17 00:00:00 2001
From: Andreas Leha <andreas@lehas.net>
Date: Tue, 27 Mar 2012 10:33:32 +0200
Subject: [PATCH] new source block header argument :filelinkdescr
---
lisp/ob.el | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/lisp/ob.el b/lisp/ob.el
index d27a394..0efef3e 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -400,6 +400,7 @@ then run `org-babel-pop-to-session'."
(eval . ((never query)))
(exports . ((code results both none)))
(file . :any)
+ (filelinkdescr . :any)
(hlines . ((no yes)))
(mkdirp . ((yes no)))
(no-expand)
@@ -1833,7 +1834,14 @@ code ---- the results are extracted in the syntax of the source
(progn
(setq result (org-babel-clean-text-properties result))
(when (member "file" result-params)
- (setq result (org-babel-result-to-file result))))
+ (progn (when (assoc :filelinkdescr (nth 2 info))
+ (let ((filelinkdescr (or (cdr (assoc :filelinkdescr (nth 2 info)))
+ (cdr (assoc :file (nth 2 info)))
+ result)))
+ (when filelinkdescr
+ (setq result
+ (list result filelinkdescr)))))
+ (setq result (org-babel-result-to-file result)))))
(unless (listp result) (setq result (format "%S" result))))
(if (and result-params (member "silent" result-params))
(progn
--
1.7.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] link descriptions in :file results of src blocks
2012-03-27 8:56 [PATCH] link descriptions in :file results of src blocks Andreas Leha
@ 2012-03-27 9:16 ` Bastien
2012-03-31 14:09 ` Eric Schulte
1 sibling, 0 replies; 8+ messages in thread
From: Bastien @ 2012-03-27 9:16 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Hi Andreas,
I let Eric handle this patch. Even if the change is small,
it is significant: in this case, it's nice to send a ChangeLog
(as stated in http://orgmode.org/worg/org-contribute.html),
otherwise Eric will have to add it. Thanks to take this in
consideration for future patches!
Best,
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link descriptions in :file results of src blocks
2012-03-27 8:56 [PATCH] link descriptions in :file results of src blocks Andreas Leha
2012-03-27 9:16 ` Bastien
@ 2012-03-31 14:09 ` Eric Schulte
2012-03-31 19:59 ` Andreas Leha
1 sibling, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2012-03-31 14:09 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> Hi all,
>
> this small patch adds :filelinkdescr to the list of possible header
> arguments for babel source blocks.
> Its intented functionality is to allow source blocks to return links to
> files with description.
>
> Two small examples:
>
> ,----[ example1 ]
> | #+begin_src R :results graphics :file test.png :filelinkdescr here
> | plot(1:10)
> | #+end_src
> |
> | #+results:
> | [[file:test.png][here]]
> `----
>
> ,----[ example2 ]
> | #+begin_src R :results graphics :file test2.png :filelinkdescr
> | plot(1:10)
> | #+end_src
> |
> | #+results:
> | [[file:test2.png][test2.png]]
> `----
>
> If used with value ("here" in the example1) that value will become the
> description. If used without value (as in example2), the description is
> taken from either the :file header argument or the results of the code block
> evaluation (in that order).
>
> Have not done much testing yet, though.
>
> Regards,
> Andreas
>
Hi Andreas,
I would like to apply this patch, however I have some questions about
the use of the :file argument and the result itself to fill in the
description if the :filelinkdescr header argument is left blank. Also,
I would suggest that :file-desc is a better name for this header
argument.
In my opinion using the :file argument as a description changes (or at
least adds to) the meaning of the :file header argument. Is there a
significant benefit to this behavior? If not I'd prefer that an empty
:file-desc header argument have no effect.
Thanks for this patch, which I think adds nice functionality and which I
would like to apply -- although I'll likely want to make the changes
above after application.
Cheers,
>
>
> From 698570cb9938ee1f4dd1472cb13b32d08d108cbb Mon Sep 17 00:00:00 2001
> From: Andreas Leha <andreas@lehas.net>
> Date: Tue, 27 Mar 2012 10:33:32 +0200
> Subject: [PATCH] new source block header argument :filelinkdescr
>
> ---
> lisp/ob.el | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/lisp/ob.el b/lisp/ob.el
> index d27a394..0efef3e 100644
> --- a/lisp/ob.el
> +++ b/lisp/ob.el
> @@ -400,6 +400,7 @@ then run `org-babel-pop-to-session'."
> (eval . ((never query)))
> (exports . ((code results both none)))
> (file . :any)
> + (filelinkdescr . :any)
> (hlines . ((no yes)))
> (mkdirp . ((yes no)))
> (no-expand)
> @@ -1833,7 +1834,14 @@ code ---- the results are extracted in the syntax of the source
> (progn
> (setq result (org-babel-clean-text-properties result))
> (when (member "file" result-params)
> - (setq result (org-babel-result-to-file result))))
> + (progn (when (assoc :filelinkdescr (nth 2 info))
> + (let ((filelinkdescr (or (cdr (assoc :filelinkdescr (nth 2 info)))
> + (cdr (assoc :file (nth 2 info)))
> + result)))
> + (when filelinkdescr
> + (setq result
> + (list result filelinkdescr)))))
> + (setq result (org-babel-result-to-file result)))))
> (unless (listp result) (setq result (format "%S" result))))
> (if (and result-params (member "silent" result-params))
> (progn
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link descriptions in :file results of src blocks
2012-03-31 19:59 ` Andreas Leha
@ 2012-03-31 19:01 ` Eric Schulte
2012-04-01 8:09 ` Andreas Leha
0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2012-03-31 19:01 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
[...]
>> I would like to apply this patch, however I have some questions about
>> the use of the :file argument and the result itself to fill in the
>> description if the :filelinkdescr header argument is left blank. Also,
>> I would suggest that :file-desc is a better name for this header
>> argument.
>
> Hi Eric,
>
> thanks for considering this patch. Feel free to change the term to
> anything more appropriate.
>
>>
>> In my opinion using the :file argument as a description changes (or at
>> least adds to) the meaning of the :file header argument. Is there a
>> significant benefit to this behavior? If not I'd prefer that an empty
>> :file-desc header argument have no effect.
>
> My original use case was indeed making a code block to
> produce [[file.pdf][file.pdf]] instead of [[file.pdf]] (see
> http://permalink.gmane.org/gmane.emacs.orgmode/53941). So, if you
> remove the possibility to specify an empty :file-desc, for me that would
> mean to give the file name twice, as in
> : #+begin_src R :results graphics :file test2.png :file-desc test2.png
> which would be avoidable with my proposed behaviour.
>
> I could live with that, though I'd still prefer not to have to type more
> than necessary...
>
Makes sense, I've just pushed up a solution which builds on your initial
patch by
1. changing :filelinkdescr to :file-desc
2. when an empty :file-desc header argument is specified it's value is
set to the value of the file path resulting in
[[file.pdf][file.pdf]]
3. adding documentation and a test case
Please let me know if this misses any part of your intended use case.
Thanks for the contribution!
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link descriptions in :file results of src blocks
2012-03-31 14:09 ` Eric Schulte
@ 2012-03-31 19:59 ` Andreas Leha
2012-03-31 19:01 ` Eric Schulte
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Leha @ 2012-03-31 19:59 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <eric.schulte@gmx.com> writes:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi all,
>>
>> this small patch adds :filelinkdescr to the list of possible header
>> arguments for babel source blocks.
>> Its intented functionality is to allow source blocks to return links to
>> files with description.
>>
>> Two small examples:
>>
>> ,----[ example1 ]
>> | #+begin_src R :results graphics :file test.png :filelinkdescr here
>> | plot(1:10)
>> | #+end_src
>> |
>> | #+results:
>> | [[file:test.png][here]]
>> `----
>>
>> ,----[ example2 ]
>> | #+begin_src R :results graphics :file test2.png :filelinkdescr
>> | plot(1:10)
>> | #+end_src
>> |
>> | #+results:
>> | [[file:test2.png][test2.png]]
>> `----
>>
>> If used with value ("here" in the example1) that value will become the
>> description. If used without value (as in example2), the description is
>> taken from either the :file header argument or the results of the code block
>> evaluation (in that order).
>>
>> Have not done much testing yet, though.
>>
>> Regards,
>> Andreas
>>
>
> Hi Andreas,
>
> I would like to apply this patch, however I have some questions about
> the use of the :file argument and the result itself to fill in the
> description if the :filelinkdescr header argument is left blank. Also,
> I would suggest that :file-desc is a better name for this header
> argument.
Hi Eric,
thanks for considering this patch. Feel free to change the term to
anything more appropriate.
>
> In my opinion using the :file argument as a description changes (or at
> least adds to) the meaning of the :file header argument. Is there a
> significant benefit to this behavior? If not I'd prefer that an empty
> :file-desc header argument have no effect.
My original use case was indeed making a code block to
produce [[file.pdf][file.pdf]] instead of [[file.pdf]] (see
http://permalink.gmane.org/gmane.emacs.orgmode/53941). So, if you
remove the possibility to specify an empty :file-desc, for me that would
mean to give the file name twice, as in
: #+begin_src R :results graphics :file test2.png :file-desc test2.png
which would be avoidable with my proposed behaviour.
I could live with that, though I'd still prefer not to have to type more
than necessary...
Regards,
Andreas
>
> Thanks for this patch, which I think adds nice functionality and which I
> would like to apply -- although I'll likely want to make the changes
> above after application.
>
> Cheers,
>
>>
>>
>> From 698570cb9938ee1f4dd1472cb13b32d08d108cbb Mon Sep 17 00:00:00 2001
>> From: Andreas Leha <andreas@lehas.net>
>> Date: Tue, 27 Mar 2012 10:33:32 +0200
>> Subject: [PATCH] new source block header argument :filelinkdescr
>>
>> ---
>> lisp/ob.el | 10 +++++++++-
>> 1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/lisp/ob.el b/lisp/ob.el
>> index d27a394..0efef3e 100644
>> --- a/lisp/ob.el
>> +++ b/lisp/ob.el
>> @@ -400,6 +400,7 @@ then run `org-babel-pop-to-session'."
>> (eval . ((never query)))
>> (exports . ((code results both none)))
>> (file . :any)
>> + (filelinkdescr . :any)
>> (hlines . ((no yes)))
>> (mkdirp . ((yes no)))
>> (no-expand)
>> @@ -1833,7 +1834,14 @@ code ---- the results are extracted in the syntax of the source
>> (progn
>> (setq result (org-babel-clean-text-properties result))
>> (when (member "file" result-params)
>> - (setq result (org-babel-result-to-file result))))
>> + (progn (when (assoc :filelinkdescr (nth 2 info))
>> + (let ((filelinkdescr (or (cdr (assoc :filelinkdescr (nth 2 info)))
>> + (cdr (assoc :file (nth 2 info)))
>> + result)))
>> + (when filelinkdescr
>> + (setq result
>> + (list result filelinkdescr)))))
>> + (setq result (org-babel-result-to-file result)))))
>> (unless (listp result) (setq result (format "%S" result))))
>> (if (and result-params (member "silent" result-params))
>> (progn
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link descriptions in :file results of src blocks
2012-03-31 19:01 ` Eric Schulte
@ 2012-04-01 8:09 ` Andreas Leha
2012-04-01 12:38 ` Eric Schulte
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Leha @ 2012-04-01 8:09 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <eric.schulte@gmx.com> writes:
> [...]
>>> I would like to apply this patch, however I have some questions about
>>> the use of the :file argument and the result itself to fill in the
>>> description if the :filelinkdescr header argument is left blank. Also,
>>> I would suggest that :file-desc is a better name for this header
>>> argument.
>>
>> Hi Eric,
>>
>> thanks for considering this patch. Feel free to change the term to
>> anything more appropriate.
>>
>>>
>>> In my opinion using the :file argument as a description changes (or at
>>> least adds to) the meaning of the :file header argument. Is there a
>>> significant benefit to this behavior? If not I'd prefer that an empty
>>> :file-desc header argument have no effect.
>>
>> My original use case was indeed making a code block to
>> produce [[file.pdf][file.pdf]] instead of [[file.pdf]] (see
>> http://permalink.gmane.org/gmane.emacs.orgmode/53941). So, if you
>> remove the possibility to specify an empty :file-desc, for me that would
>> mean to give the file name twice, as in
>> : #+begin_src R :results graphics :file test2.png :file-desc test2.png
>> which would be avoidable with my proposed behaviour.
>>
>> I could live with that, though I'd still prefer not to have to type more
>> than necessary...
>>
>
> Makes sense, I've just pushed up a solution which builds on your initial
> patch by
>
> 1. changing :filelinkdescr to :file-desc
>
> 2. when an empty :file-desc header argument is specified it's value is
> set to the value of the file path resulting in
> [[file.pdf][file.pdf]]
>
> 3. adding documentation and a test case
>
> Please let me know if this misses any part of your intended use case.
>
> Thanks for the contribution!
Hi Eric,
I seem not to be able to see that push. My git log contains only
,----
| 8d43aa2 test the new file-desc header argument
| 670c7f3 simplified implementation of :file-desc header argument
| 1193844 documentation for the new file-desc header argument
| 59800b2 change name of filelinkdescr to file-desc
| a58a4f0 new source block header argument :filelinkdescr
`----
and indeed, the functionality you describe in 2. seems not to be
available. What did I miss?
Regards,
Andreas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link descriptions in :file results of src blocks
2012-04-01 8:09 ` Andreas Leha
@ 2012-04-01 12:38 ` Eric Schulte
2012-04-01 18:34 ` Andreas Leha
0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2012-04-01 12:38 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> Eric Schulte <eric.schulte@gmx.com> writes:
>
>> [...]
>>>> I would like to apply this patch, however I have some questions about
>>>> the use of the :file argument and the result itself to fill in the
>>>> description if the :filelinkdescr header argument is left blank. Also,
>>>> I would suggest that :file-desc is a better name for this header
>>>> argument.
>>>
>>> Hi Eric,
>>>
>>> thanks for considering this patch. Feel free to change the term to
>>> anything more appropriate.
>>>
>>>>
>>>> In my opinion using the :file argument as a description changes (or at
>>>> least adds to) the meaning of the :file header argument. Is there a
>>>> significant benefit to this behavior? If not I'd prefer that an empty
>>>> :file-desc header argument have no effect.
>>>
>>> My original use case was indeed making a code block to
>>> produce [[file.pdf][file.pdf]] instead of [[file.pdf]] (see
>>> http://permalink.gmane.org/gmane.emacs.orgmode/53941). So, if you
>>> remove the possibility to specify an empty :file-desc, for me that would
>>> mean to give the file name twice, as in
>>> : #+begin_src R :results graphics :file test2.png :file-desc test2.png
>>> which would be avoidable with my proposed behaviour.
>>>
>>> I could live with that, though I'd still prefer not to have to type more
>>> than necessary...
>>>
>>
>> Makes sense, I've just pushed up a solution which builds on your initial
>> patch by
>>
>> 1. changing :filelinkdescr to :file-desc
>>
>> 2. when an empty :file-desc header argument is specified it's value is
>> set to the value of the file path resulting in
>> [[file.pdf][file.pdf]]
>>
>> 3. adding documentation and a test case
>>
>> Please let me know if this misses any part of your intended use case.
>>
>> Thanks for the contribution!
>
> Hi Eric,
>
> I seem not to be able to see that push. My git log contains only
> ,----
> | 8d43aa2 test the new file-desc header argument
> | 670c7f3 simplified implementation of :file-desc header argument
> | 1193844 documentation for the new file-desc header argument
> | 59800b2 change name of filelinkdescr to file-desc
> | a58a4f0 new source block header argument :filelinkdescr
> `----
> and indeed, the functionality you describe in 2. seems not to be
> available. What did I miss?
>
Hi Andreas,
The commit implementing the behavior described in (2) is 670c7f3.
Please take a look at the test-ob/file-desc-header-argument test case.
If it is passing on your system (as it is on mine) then the behavior
described in (2) is in fact implemented.
Best,
>
> Regards,
> Andreas
>
>
>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] link descriptions in :file results of src blocks
2012-04-01 12:38 ` Eric Schulte
@ 2012-04-01 18:34 ` Andreas Leha
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Leha @ 2012-04-01 18:34 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <eric.schulte@gmx.com> writes:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Eric Schulte <eric.schulte@gmx.com> writes:
>>
>>> [...]
>>>>> I would like to apply this patch, however I have some questions about
>>>>> the use of the :file argument and the result itself to fill in the
>>>>> description if the :filelinkdescr header argument is left blank. Also,
>>>>> I would suggest that :file-desc is a better name for this header
>>>>> argument.
>>>>
>>>> Hi Eric,
>>>>
>>>> thanks for considering this patch. Feel free to change the term to
>>>> anything more appropriate.
>>>>
>>>>>
>>>>> In my opinion using the :file argument as a description changes (or at
>>>>> least adds to) the meaning of the :file header argument. Is there a
>>>>> significant benefit to this behavior? If not I'd prefer that an empty
>>>>> :file-desc header argument have no effect.
>>>>
>>>> My original use case was indeed making a code block to
>>>> produce [[file.pdf][file.pdf]] instead of [[file.pdf]] (see
>>>> http://permalink.gmane.org/gmane.emacs.orgmode/53941). So, if you
>>>> remove the possibility to specify an empty :file-desc, for me that would
>>>> mean to give the file name twice, as in
>>>> : #+begin_src R :results graphics :file test2.png :file-desc test2.png
>>>> which would be avoidable with my proposed behaviour.
>>>>
>>>> I could live with that, though I'd still prefer not to have to type more
>>>> than necessary...
>>>>
>>>
>>> Makes sense, I've just pushed up a solution which builds on your initial
>>> patch by
>>>
>>> 1. changing :filelinkdescr to :file-desc
>>>
>>> 2. when an empty :file-desc header argument is specified it's value is
>>> set to the value of the file path resulting in
>>> [[file.pdf][file.pdf]]
>>>
>>> 3. adding documentation and a test case
>>>
>>> Please let me know if this misses any part of your intended use case.
>>>
>>> Thanks for the contribution!
>>
>> Hi Eric,
>>
>> I seem not to be able to see that push. My git log contains only
>> ,----
>> | 8d43aa2 test the new file-desc header argument
>> | 670c7f3 simplified implementation of :file-desc header argument
>> | 1193844 documentation for the new file-desc header argument
>> | 59800b2 change name of filelinkdescr to file-desc
>> | a58a4f0 new source block header argument :filelinkdescr
>> `----
>> and indeed, the functionality you describe in 2. seems not to be
>> available. What did I miss?
>>
>
> Hi Andreas,
>
> The commit implementing the behavior described in (2) is 670c7f3.
> Please take a look at the test-ob/file-desc-header-argument test case.
> If it is passing on your system (as it is on mine) then the behavior
> described in (2) is in fact implemented.
>
> Best,
>
Hi Eric,
I tested with a wrong version of org-mode. It works in fact as
expected. Thanks for your work on this one and sorry for the fake
alarm.
Regards,
Andreas
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-04-01 18:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-27 8:56 [PATCH] link descriptions in :file results of src blocks Andreas Leha
2012-03-27 9:16 ` Bastien
2012-03-31 14:09 ` Eric Schulte
2012-03-31 19:59 ` Andreas Leha
2012-03-31 19:01 ` Eric Schulte
2012-04-01 8:09 ` Andreas Leha
2012-04-01 12:38 ` Eric Schulte
2012-04-01 18:34 ` Andreas Leha
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).