From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: org-store-link without having to press Enter? Date: Tue, 14 Jan 2014 17:55:09 -0500 Message-ID: <87vbxm41iq.fsf@alphaville.bos.redhat.com> References: <86k3e2clzz.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3CtO-0006dJ-Ox for emacs-orgmode@gnu.org; Tue, 14 Jan 2014 17:55:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3CtI-0000Yg-7J for emacs-orgmode@gnu.org; Tue, 14 Jan 2014 17:55:30 -0500 Received: from plane.gmane.org ([80.91.229.3]:51012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3CtH-0000YY-SY for emacs-orgmode@gnu.org; Tue, 14 Jan 2014 17:55:24 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W3CtF-0006p5-GI for emacs-orgmode@gnu.org; Tue, 14 Jan 2014 23:55:21 +0100 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Jan 2014 23:55:21 +0100 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Jan 2014 23:55:21 +0100 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@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org "Sebastien Vauban" 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