From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] add "link" :results type for Babel Date: Wed, 11 Apr 2018 22:55:29 +0200 Message-ID: <87fu41zcn2.fsf@nicolasgoaziou.fr> References: <87vacztlvw.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6MmI-0005r2-Uk for emacs-orgmode@gnu.org; Wed, 11 Apr 2018 16:55:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6MmE-0006Ys-RU for emacs-orgmode@gnu.org; Wed, 11 Apr 2018 16:55:38 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:37681) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f6MmE-0006Xo-97 for emacs-orgmode@gnu.org; Wed, 11 Apr 2018 16:55:34 -0400 In-Reply-To: <87vacztlvw.fsf@gmail.com> (stardiviner's message of "Tue, 10 Apr 2018 18:07:47 +0800") 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" To: stardiviner Cc: org-mode Hello, stardiviner writes: > This patch try to support following way: > > #+begin_src sh :results link :file "/tmp/test.txt" > echo "hello" > /tmp/test.txt > echo "test" > #+end_src > > #+RESULTS: > [[file:/tmp/test.txt]] > > Because: > > - ~org-babel-execute-src-block~ > - ~(org-babel-get-src-block-info)~ > - (let* ((info .. (apply #'org-babel-merge-params ...)))) > - ~org-babel-merge-params~ > - [ ] *because* code ~(`(,(or :file :file-ext) . ,value) ...)~ > lines logic in function ~org-babel-get-src-block-info~, it > merge "file" ~:results~, so override params plist :results > value ~link~. > - [ ] So I put ~link~ and ~graphics~ "~:results~" type into a > separate group in constant > ~org-babel-common-header-args-w-values~. > > If anybody has better way, please improve my code. IIRC, there is no technical difference between ":results graphics" and ":results link". So, what about simply stating that `link' and `graphics' are equivalent, like, e.g., `table' and `vector' or `scalar' and `verbatim'? Note that `graphics' results are not properly documented in the current manual. They should probably go in "Working with Source Code/Results of Evaluation/Format" section. > - (results . ((file list vector table scalar verbatim) > + (results . ( > + ;; separate group to avoid been override by "file" > + ;; :results in `org-babel-merge-params'. > + (link) `link' is not an output type. `graphics' is not defined here either. > +(ert-deftest test-ob/result-file-link-type-header-argument () > + "Ensure that the result is a link to a file. > +The file is just a link to :file value. Inhibit non-empty result write to :file." > + (org-test-with-temp-text "#+begin_src shell :results value link :file \"/tmp/test.txt\" > +echo \"hello\" > /tmp/test.txt > +echo \"test\" > +#+end_src" > + (org-babel-execute-src-block) > + (goto-char (point-min)) > + (should (search-forward "[[file:/tmp/test.txt]]" nil nil)) > + (should (with-temp-buffer > + (insert-file-contents "/tmp/test.txt") > + (string= > + "hello\n" > + (buffer-substring-no-properties (point-min) (point-max))))))) Note that this test already passes when "link" is substituted with "graphics". Regards, -- Nicolas Goaziou