emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Omit file description when :file-desc has nil value
@ 2020-09-05 19:19 Huszaghmatt
  2020-09-06  4:19 ` Kyle Meyer
  0 siblings, 1 reply; 14+ messages in thread
From: Huszaghmatt @ 2020-09-05 19:19 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Emacs-Orgmode

[-- Attachment #1: Type: text/plain, Size: 2379 bytes --]

     
 

 
 
 
 
 

 
 Kyle Meyer  <kyle@kyleam.com (mailto:kyle@kyleam.com)>  writes:  >  A use case was given in the initial patch:  >   <https://orgmode.org/list/87vclky211.fsf@med.uni-goettingen.de/T/#u>.  >  The test for this behavior mentioned there is  >  test-ob/file-desc-header-argument.  >   >  That thread links to another thread by gmane ID. That's this one:  >   https://orgmode.org/list/87limm4eo2.fsf@med.uni-goettingen.de/T/#u  Thanks for the reply, Kyle, and thanks for pointing me to that thread. I understand that this would break existing functionality, but I think my solution makes more sense. For one, I think that the current implementation is a bit confusing. More importantly though, it makes it impossible to both provide a default value for :file-desc and omit it in some cases. The benefit (as mentioned in that thread) is that in those select cases, the same argument would not need to be provided twice. I think the cost of the current functionality outweighs the benefit. What are your t
houghts? I've got a pending patch (https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/msg00041.html) that allows a user to provide lambdas as default header arguments (evaluated during source block execution or export). This makes the use of defaults much more attractive in my mind because they can provide context aware values. Similarly, it increases the cost of the current implementation because then this facility cannot be used for :file-desc. I guess there are other solutions we could explore, such as an empty string (is an empty file descriptor ever a valid use case?) taking the place of the current functionality, or fully eliminating the file descriptor. However, this is starting to feel like a lot of hacks and would be very confusing to new users. Moreover, it really just pushes the problem down the road rather than fixing it outright.  >  Right, to reflect the current behavior established as a result of the  >  above thread, I think that should be reworded to distinguis
h between an  >  absent :file-desc header and one with no argument. Sorry for not  >  catching that when reviewing your initial patch. No worries, and I agree the documentation should be updated. I'm happy to provide the patch myself, but I'd like to talk through whether the current implementation is the correct one before I do. Best Matt 

 
 
 
 

 
     

[-- Attachment #2: Type: text/html, Size: 3655 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH] Omit file description when :file-desc has nil value
@ 2020-09-03  6:19 Matt Huszagh
  2020-09-03  6:53 ` Matt Huszagh
  2020-09-04  5:21 ` Kyle Meyer
  0 siblings, 2 replies; 14+ messages in thread
From: Matt Huszagh @ 2020-09-03  6:19 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ob-core.el-Omit-file-description-when-file-desc.patch --]
[-- Type: text/x-patch, Size: 1303 bytes --]

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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-10-07  3:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-05 19:19 [PATCH] Omit file description when :file-desc has nil value Huszaghmatt
2020-09-06  4:19 ` Kyle Meyer
2020-09-09 19:50   ` Matt Huszagh
2020-09-15 17:09     ` Matt Huszagh
2020-09-24  5:23       ` Kyle Meyer
2020-09-24  6:16         ` Matt Huszagh
2020-09-24 23:07           ` Kyle Meyer
2020-09-29 21:33             ` Matt Huszagh
2020-10-03  6:08               ` Kyle Meyer
2020-10-06 13:17                 ` Matt Huszagh
2020-10-07  3:19                   ` Kyle Meyer
  -- strict thread matches above, loose matches on Subject: below --
2020-09-03  6:19 Matt Huszagh
2020-09-03  6:53 ` Matt Huszagh
2020-09-04  5:21 ` Kyle Meyer

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).