From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH v4] ol.el: add description format parameter to org-link-parameters
Date: Sun, 10 Jul 2022 17:26:51 +0700 [thread overview]
Message-ID: <tae9hc$vgv$1@ciao.gmane.io> (raw)
In-Reply-To: <87v8s8n1bm.fsf@heagren.com>
On 08/07/2022 02:57, Hugo Heagren wrote:
> Since the last version of this patch, I have:
Thank you, this version should be more reliable.
> tl;dr The question is: what is the Good Behaviour when
> :default-description is set to something, which is meant to return a
> string and returns 'nil instead? Should it be treated like an empty
> string, or as an error?
Just an idea: if the :default-description function returns "" then use
empty description, if it returns nil then try
`org-link-make-description-function'.
Unsure if it is better but I would consider `or' instead of `cond':
(or description
(let ((make (org-link-get-parameter type :default-description)))
(and make (condition-case ; ...
)))
(and org-link-make-description-function
(condition-case ; ...
))
desc)
So it becomes a kind of responsibility chain and nil becomes a valid and
useful value.
I am in doubts concerning "default-description" as the parameter name. I
would consider either more specific "insert-description" or shorter
"description". Concerning the former, sometimes I do not mind to have
default description for export shared by most of backends without
necessity to explicitly write :export function handling all backends.
E.g. for <info:org#Protocols> generate
https://orgmode.org/manual/Protocols.html target and 'info "(org)
Protocols"' description that is suitable for LaTeX/PDF, HTML, Markdown.
If something like this were implemented, default-description would
become ambiguous if it is related to insert or to export.
> +(defmacro test-ol-with-link-parameters-as (type parameters &rest body)
[...]
> + ;; Copy all keys in `parameters' and their original values to
> + ;; `orig-parameters'. For `parity': nil = odd, non-nill = even
> + `(let (parity orig-parameters)
> + (dolist (p ',parameters)
Have I missed something or the whole macro may be simplified to just
copy `org-link-parameters'?
`(let ((org-link-parameters (copy-tree org-link-parameters)))
(org-link-set-parameters ,type ,@parameters)
,@body))
Otherwise `gensym'-generated name should be used instead of hardcoded
rtn to avoid accidental modification of the variable by the body code:
> + (let ((_ (org-link-set-parameters ,type ,@parameters))
> + ;; Do body
> + (rtn (progn ,@body)))
In addition, `declare' form should be added to `defmacro' to specify
which argument is considered as its body.
> + (setq type
> + (cond
My opinion is that it should be inside
(let ((initial-input ...
and maybe even be a sibling of
(def (org-link-get-parameter type
to keep related code more local.
> - ((not org-link-make-description-function) desc)
> + (desc)
> + ((org-link-get-parameter type :default-description)
> + (let ((def (org-link-get-parameter type :default-description)))
I have not tested, so I may be wrong in respect to the following. It
seems, you rises priority of desc value that earlier was a fallback. The
reason why I am in doubts, is that it seems, desc is initialized from
current link description when point is withing an existing link and in
such cases desc likely should be preserved. I can not say that I like
that it is responsibility of all description functions to return the
desc argument if it is supplied.
> (t (condition-case nil
> (funcall org-link-make-description-function link desc)
Notice that before you modification `funcall' was guarded by "(not
org-link-make-description-function)" test.
I like the idea of description specific to link type and it is sour that
previous attempts to implement the feature was not completed.
next prev parent reply other threads:[~2022-07-10 10:28 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 23:15 ol.el: add description format parameter to org-link-parameters Hugo Heagren
2022-03-28 23:15 ` [PATCH] " Hugo Heagren
2022-04-04 9:49 ` Ihor Radchenko
2022-04-05 19:29 ` [PATCH v2] " Hugo Heagren
2022-04-07 5:13 ` Ihor Radchenko
2022-06-21 12:03 ` [PATCH v3] " Hugo Heagren
2022-06-21 13:41 ` Robert Pluim
2022-07-07 19:57 ` [PATCH v4] " Hugo Heagren
2022-07-09 3:31 ` Ihor Radchenko
2022-07-14 13:08 ` [PATCH v5] " Hugo Heagren
2022-07-16 9:09 ` Ihor Radchenko
2022-07-16 21:20 ` Hugo Heagren
2022-07-17 6:11 ` Max Nikulin
2022-07-17 10:27 ` Ihor Radchenko
2022-07-17 10:18 ` Ihor Radchenko
2022-07-17 20:59 ` [PATCH v6] " Hugo Heagren
2022-07-18 10:55 ` Max Nikulin
2022-07-23 7:48 ` [PATCH v7] " Hugo Heagren
2022-07-23 7:59 ` Max Nikulin
2022-07-23 13:06 ` Ihor Radchenko
2022-07-23 15:46 ` Max Nikulin
2022-07-24 10:34 ` Max Nikulin
2022-07-24 13:15 ` Ihor Radchenko
2022-07-25 11:55 ` [PATCH v8] " Hugo Heagren
2022-07-29 12:54 ` Max Nikulin
2022-07-29 19:05 ` [PATCH v9] " Hugo Heagren
2022-07-30 6:29 ` Ihor Radchenko
[not found] ` <87tu6zf2o1.fsf@heagren.com>
2022-07-30 8:02 ` Ihor Radchenko
2022-07-30 12:34 ` [PATCH] ol-info: Enable :insert-description feature Max Nikulin
2022-08-06 7:00 ` Ihor Radchenko
2022-08-14 16:41 ` [PATCH v2] ol-info: Define :insert-description function Max Nikulin
2022-08-19 4:28 ` Ihor Radchenko
2022-08-19 12:26 ` Max Nikulin
2022-08-20 7:29 ` Ihor Radchenko
2022-08-21 14:49 ` Max Nikulin
2022-08-22 4:10 ` Ihor Radchenko
2022-08-24 14:37 ` [PATCH v3] " Max Nikulin
2022-08-26 13:15 ` Ihor Radchenko
2022-09-04 15:05 ` [PATCH] ol-info: Enable :insert-description feature Max Nikulin
2022-09-05 6:36 ` Ihor Radchenko
2022-08-06 6:06 ` [PATCH v9] ol.el: add description format parameter to org-link-parameters Ihor Radchenko
2022-07-29 1:47 ` [PATCH v7] " Ihor Radchenko
2022-07-29 7:05 ` Bastien Guerry
2022-07-10 10:26 ` Max Nikulin [this message]
2022-06-21 15:01 ` [PATCH v3] " Max Nikulin
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='tae9hc$vgv$1@ciao.gmane.io' \
--to=manikulin@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).