From: "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: org-store-link without having to press Enter?
Date: Wed, 15 Jan 2014 10:24:08 +0100 [thread overview]
Message-ID: <86eh49bnt3.fsf@somewhere.org> (raw)
In-Reply-To: 87vbxm41iq.fsf@alphaville.bos.redhat.com
Hello Nick,
Nick Dokos wrote:
> Sebastien Vauban writes:
>>
>> I'd like to use org-store-link in a piece of code. However, it currently
>> requires the user to select some link from a list of store links.
>
> I think you mean org-insert-link, right?
Yes; you're right!
>> If I always want to select the last one -- that is, the default
>> option --, how can I bypass the required RET?
>>
>> I can do this:
>>
>> (execute-kbd-macro "\C-c\C-l\C-m")
>>
>> But I find it fragile because it relies on key bindings which could
>> change in time.
>>
>> How could I do otherwise?
>
> I don't know if there is an API, but org-store-link just adds the link
> info to the front of the list org-stored-links, so the last link added
> is (car org-stored-links). Each element of org-stored-links is
> a two-element list (link description). Both of these are strings
> (possibly strings with text properties).
>
> So something like this might work:
>
> (let ((link (car org-stored-links)))
> (insert (format "[[%s][%s]]" (car link) (cadr link))))
>
> at least for now... It's imo "better" than the keyboard macro but it's
> still pretty low level and ugly.
It does work. THANKS! -- I prefer it over my own version.
I thought there could exist some way to (pre-)send the input to be read
when prompted by a function. It seems not (I guess you'd have mentioned
it otherwise...).
I wonder as well how I could do the `execute-kbd-macro' if there wasn't
a key bound to the command I'm interested in. I tried things like the
following, with no success:
(execute-kbd-macro "M-x org-insert-link\C-m")
Best regards,
Seb
--
Sebastien Vauban
next prev parent reply other threads:[~2014-01-15 9:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 21:05 org-store-link without having to press Enter? Sebastien Vauban
2014-01-14 22:55 ` Nick Dokos
2014-01-15 9:24 ` Sebastien Vauban [this message]
2014-01-15 16:44 ` Bastien
2014-01-15 17:22 ` Nick Dokos
2014-01-17 9:17 ` Bastien
2014-01-20 14:38 ` Bastien
2014-02-18 13:50 ` Sebastien Vauban
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=86eh49bnt3.fsf@somewhere.org \
--to=sva-news-d0wtavr13harg/idocfnwg@public.gmane.org \
--cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
/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).