Hello Org,
I like #+LINK keywords because they make documents self-sufficient:
anyone opening my document can follow these links or export the buffer;
they do not need to run some Elisp to add to org-link-parameters.
One thing I don't know how to customize, however, is how these links are
exported when they have no description. Let's say I define this
abbreviation:
#+LINK: bug https://debbugs.gnu.org/
If I jot down references to [[bug:12345]] in my document, these will be
exported as:
https://debbugs.gnu.org/12345
Whereas I'd prefer:
bug:12345
Looking at org-element-link-parser, I see that this is because the
:contents-begin and :contents-end properties are nil, since they
correspond to an unmatched optional group in org-link-bracket-re.
I could probably customize org-link-parameters, but then my document
would not be self-sufficient anymore. Besides, depending on the
document I might use the same abbreviation for different URLs.
Would it make sense to add a way for abbreviated links with no
description to fallback to LINKKEY:TAG[1] instead of the full URL? If
so, what would be the best way to go about it?
(1) A single variable (e.g. org-link-abbrev-default-description), default
nil, which a user could set to 'key-tag or just 'tag.
(2) A third entry in org-link-abbrev-alist(-local), default nil, which a
user could set to 'key-tag or just 'tag.
(3) Something else (e.g. a new alist).
I've attached a very crude patch for (1): now if I stick this footer in
my Org files:
#+LINK: bug https://debbugs.gnu.org/
# Local variables:
# org-link-abbrev-default-description: key-tag
# end:
Then [[bug:12345]] is exported as
bug:12345.
WDYT? If the idea is sound, I will clean up the patch, clarify
docstrings, add :safe predicates and unit tests, and re-submit.
Thank you for your time.