From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: Re: org-store-link without having to press Enter? Date: Wed, 15 Jan 2014 10:24:08 +0100 Message-ID: <86eh49bnt3.fsf@somewhere.org> References: <86k3e2clzz.fsf@somewhere.org> <87vbxm41iq.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org 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