From: Harald Judt <h.judt@gmx.at>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-orgmode@gnu.org
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 [thread overview]
Message-ID: <5a1cb629-8437-41f5-fd75-674c949eaf5e@gmx.at> (raw)
In-Reply-To: <877depxyo9.fsf@localhost>
[-- Attachment #1.1.1: Type: text/plain, Size: 1264 bytes --]
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 #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 659 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
prev parent reply other threads:[~2021-10-08 11:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-06 9:44 [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/)] Harald Judt
2021-10-07 4:10 ` Ihor Radchenko
2021-10-08 11:38 ` Harald Judt [this message]
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=5a1cb629-8437-41f5-fd75-674c949eaf5e@gmx.at \
--to=h.judt@gmx.at \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@gmail.com \
/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).