From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: [PATCH] link descriptions in :file results of src blocks Date: Sat, 31 Mar 2012 21:59:54 +0200 Message-ID: <87vclky211.fsf@med.uni-goettingen.de> References: <87haxa4e2z.fsf@med.uni-goettingen.de> <87pqbsu9qt.fsf@gmx.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:35738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SE4Tc-0007c9-5u for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 16:00:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SE4TZ-0005Pz-DQ for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 16:00:43 -0400 Received: from plane.gmane.org ([80.91.229.3]:42990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SE4TZ-0005PT-2p for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 16:00:41 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SE4TU-0004KX-Vr for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 22:00:36 +0200 Received: from p57b6719b.dip.t-dialin.net ([87.182.113.155]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 31 Mar 2012 22:00:36 +0200 Received: from andreas.leha by p57b6719b.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 31 Mar 2012 22:00:36 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Eric Schulte writes: > Andreas Leha 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 >> 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