emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Omit file description when :file-desc has nil value


From: Matt Huszagh
Subject: [PATCH] Omit file description when :file-desc has nil value
Date: Wed, 02 Sep 2020 23:19:49 -0700

Hello,

This patch omits a file description when :file-desc has a nil
value. Previously, the following src block

#+BEGIN_SRC asymptote :results value file :file circle.pdf :file-desc 
:output-dir img/
  size(2cm);
  draw(unitcircle);
#+END_SRC

would yield

#+RESULTS:
[[file:img/circle.pdf][circle.pdf]]

This makes it impossible (I think) to provide :file-desc with a default
value and prevent the description in some cases. This patch would cause
the same code block to execute to

#+RESULTS:
[[file:img/circle.pdf]]

I feel I may be missing something in regard to why this previously had
the functionality it did. Is there a use case I've missed? To me, the
documentation seems to indicate that my patch is the desired behavior:

   The =file-desc= header argument defines the description (see
   [[*Link Format]]) for the link.  If =file-desc= has no value, the
   "description" part of the link will be omitted.

Full disclaimer: I wrote this section of the documentation as part of
this patch:

https://lists.gnu.org/archive/html/emacs-orgmode/2020-07/msg00320.html

Thanks
Matt

>From edcfa85add6ac71a1e13b7731779ccf4a8e12868 Mon Sep 17 00:00:00 2001
From: Matt Huszagh <huszaghmatt@gmail.com>
Date: Wed, 2 Sep 2020 23:06:10 -0700
Subject: [PATCH] lisp/ob-core.el: Omit file description when :file-desc has
 nil value

* lisp/ob-core.el (org-babel-insert-result): Omit file description
when :file-desc value evaluates to nil.

The previous implementation makes it impossible to provide a default
:file-desc and in some cases override it to omit the description.
---
 lisp/ob-core.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 578622232..55165ebc5 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2257,9 +2257,9 @@ INFO may provide the values of these header arguments (in 
the
         (setq result (org-no-properties result))
         (when (member "file" result-params)
           (setq result (org-babel-result-to-file
-                        result (when (assq :file-desc (nth 2 info))
-                                 (or (cdr (assq :file-desc (nth 2 info)))
-                                     result))))))
+                        result (when (and (assq :file-desc (nth 2 info))
+                                          (cdr (assq :file-desc (nth 2 info))))
+                                 (cdr (assq :file-desc (nth 2 info))))))))
        ((listp result))
        (t (setq result (format "%S" result))))
   (if (and result-params (member "silent" result-params))
-- 
2.28.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]