emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [BUG] link abbreviations do not work inside property drawers [9.5.2


From: tony aldon
Subject: Re: [BUG] link abbreviations do not work inside property drawers [9.5.2 (release_9.5.2-38-g682ccd @ /home/ignacio/repos/emacs/lisp/org/)]
Date: Wed, 27 Apr 2022 11:18:32 +0200

I quietly followed the conversation.  Thank you for the advice.

On Wed, Apr 27, 2022 at 9:06 AM Ignacio Casso <ignaciocasso@hotmail.com> wrote:

Ihor Radchenko <yantar92@gmail.com> writes:

> Ignacio Casso <ignaciocasso@hotmail.com> writes:
>
>>> A better approach could be using org-link-expand-abbrev. It is an API
>>> function and should be forward-compatible.
>>
>> Do you mean something like this?
>>
>> (defun org-open-at-point-global ()
>>     ...
>>     (cond ((org-in-regexp org-link-any-re)
>>         (org-link-open-from-string
>>             (org-link-expand-abbrev (match-string-no-properties 0))))
>>           ...))
>>
>> Right now that is not enough because `org-link-expand-abbrev' only works
>> for links without square brackets, like "abbrev:suffix", and
>> `org-link-any-re' matches links with square brackets, like
>> "[[abbrev:suffix]]". That could be easily worked around in
>> `org-open-at-point-global' but maybe it would be better to change
>> `org-link-expand-abbrev' to work with both forms.
>
> Fair point. Then, the most future-proof way would be calling
> org-element-link-parser. It should take care about abbrev expansion and
> other edge cases. Then, you just need to use :raw-link property of the
> parsed link element.
>
> Best,
> Ihor

And then we come full circle, since that is what is being done already
but in a temporal buffer (so without access to
`org-link-abbrev-alist-local'), and your original concerns in your first
reply apply: doing it inside `org-open-at-point' would duplicate a lot
of code.

So I guess the issue is not as orthogonal as I though with the one of
the parser and it would be complicated to fix it properly, as you said
in your first email. If no one else has reported this problem or replied
to this thread, I guess that probably the best thing to do is fixing
this in my own config and move on for now:

I'll copy here the advice that fixes it, in case anyone needs to add it
to their config too:

(defun my-advice (orig-fun &rest args)
  (let ((org-link-abbrev-alist
         (append org-link-abbrev-alist org-link-abbrev-alist-local)))
    (apply orig-fun args)))

(advice-add 'org-open-at-point-global :around 'my-advice)

Best regards, and thanks for taking a look at this,

--Ignacio


reply via email to

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