emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [BUG] org-context called from link in org-agenda entry returns wrong


From: Harald Judt
Subject: Re: [BUG] org-context called from link in org-agenda entry returns wrong values [9.5 (9.5-g0a86ad @ /home/.emacs.d/elpa/org-9.5/)]
Date: Fri, 8 Oct 2021 13:38:10 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

Am 07.10.21 um 06:10 schrieb Ihor Radchenko:
Harald Judt <h.judt@gmx.at> writes:

Hi,

I am using this function to copy links from the agenda to the clipboard:

(defun my-copy-org-url ()
      (interactive)
      (let* ((link-info (assoc :link (org-context)))
...

org-context is ancient. It relies on org-links being fontified using
'org-link face and would fail for any non-standard link with :face link
parameter. Moreover, the return value will be different depending on
org-link-descriptive setting.

We should probably deprecate this function and encourage using
org-element-context. So, I recommend rewriting your code with
org-element-context.

Thank you, that helped me updating the function, which works fine with org-element-context:

  (defun my-copy-org-url ()
    (interactive)
    (let* ((raw-link (plist-get (nth 1 (org-element-context)) :raw-link)))
      (if (not raw-link)
          (error "Point not in an org link.")
        (kill-new raw-link)
        (message "Org link URL copied to clipboard."))))

Regards,
Harald

--
`Experience is the best teacher.'

PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD

Attachment: OpenPGP_0x4FFFAB21B8580ABD.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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