emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Matt Huszagh <huszaghmatt@gmail.com>
Cc: Emacs-Orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Omit file description when :file-desc has nil value
Date: Sat, 03 Oct 2020 02:08:09 -0400	[thread overview]
Message-ID: <87a6x3kfjq.fsf@kyleam.com> (raw)
In-Reply-To: <878scs2rpg.fsf@gmail.com>

Matt Huszagh writes:

> Subject: [PATCH] list/ob-core.el: Allow passing empty vector to :file-desc to
>  omit description

s/list/lisp/

> diff --git a/doc/org-manual.org b/doc/org-manual.org
> index e7d25b90e..a790f3225 100644
> --- a/doc/org-manual.org
> +++ b/doc/org-manual.org
> @@ -17482,10 +17482,12 @@ default behavior is to automatically determine the result type.
>    #+end_example
>  
>    #+cindex: @samp{file-desc}, header argument
> -  The =file-desc= header argument defines the description (see
> -  [[*Link Format]]) for the link.  If =file-desc= is present but has no value,
> +  The =file-desc= header argument defines the description (see [[*Link
> +  Format]]) for the link.  If =file-desc= is present but has no value,
>    the =file= value is used as the link description.  When this
> -  argument is not present, the description is omitted.
> +  argument is not present, the description is omitted.  If you want to
> +  provide the =file-disc= argument but omit the description, you can

s/file-disc/file-desc/

> +  provide it with an empty vector (i.e., :file-desc []).

> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> index 5dc68cba4..19f6af288 100644
> --- a/etc/ORG-NEWS
> +++ b/etc/ORG-NEWS
> @@ -24,8 +24,19 @@ Earlier, IDs generated using =ts= method had a hard-coded format (i.e. =20200923
>  The new option allows user to customise the format.
>  Defaults are unchanged.
>  
> +*** New argument for ~file-desc~ babel header
[...]
>  ** New features
> -*** =ob-python= improvements to =:return= header argument 
> +*** =ob-python= improvements to =:return= header argument

This space change is touching unrelated code.

>  The =:return= header argument in =ob-python= now works for session
>  blocks as well as non-session blocks.  Also, it now works with the
> diff --git a/lisp/ob-core.el b/lisp/ob-core.el
> index 7300f239e..075e3f928 100644
> --- a/lisp/ob-core.el
> +++ b/lisp/ob-core.el
> @@ -646,6 +646,14 @@ a list with the following pattern:
>        (replace-regexp-in-string
>         (org-src-coderef-regexp coderef) "" expand nil nil 1))))
>  
> +(defun org-babel--file-desc (params result)
> +  "Retrieve file description."
> +  (pcase (assq :file-desc params)
> +    (`nil nil)

All right, so this is the no header case...

> +    (`(:file-desc) result)

...this is for when org-babel-read maps the value to nil...

> +    (`(:file-desc . ,(and (pred stringp) val)) val)

...and when org-babel-read maps it to a string...

> +    (`(:file-desc . []) nil)))

...and this the explicit vector.

Operationally any value that org-babel-read doesn't map to nil or a
string leads to nil.  The pcase expression then could be reduced to

    (pcase (assq :file-desc params)
      (`(:file-desc) result)
      (`(:file-desc . ,(and (pred stringp) val)) val))

However, I'm okay with it as is, particularly the [] arm, because I
think it helps readability wise to explicitly spell out the documented
case.

So, with the typo/spurious space change clean-ups, this looks good to
me.  IIRC from a previous thread, you haven't yet completed the
copyright paperwork.  Is that the case?

Thanks.


  reply	other threads:[~2020-10-03  6:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6x3kfjq.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=huszaghmatt@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).