[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org-store-link without having to press Enter?
From: |
Nick Dokos |
Subject: |
Re: [O] org-store-link without having to press Enter? |
Date: |
Tue, 14 Jan 2014 17:55:09 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
"Sebastien Vauban" <address@hidden>
writes:
> Hello,
>
> 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?
> 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.
Nick