Am 07.10.21 um 06:10 schrieb Ihor Radchenko:
Harald Judt <[email protected]> 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
OpenPGP_0x4FFFAB21B8580ABD.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature
