From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: org-store-link without having to press Enter? Date: Wed, 15 Jan 2014 17:44:46 +0100 Message-ID: <87lhyhry81.fsf@bzg.ath.cx> References: <86k3e2clzz.fsf@somewhere.org> <87vbxm41iq.fsf@alphaville.bos.redhat.com> <86eh49bnt3.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3Tai-0004v9-PM for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 11:45:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3TaY-0007i5-C5 for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 11:45:20 -0500 Received: from plane.gmane.org ([80.91.229.3]:46679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3TaY-0007hl-5p for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 11:45:10 -0500 Received: from public by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W3TaU-0002pV-Oe for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 17:45:06 +0100 In-Reply-To: <86eh49bnt3.fsf@somewhere.org> (Sebastien Vauban's message of "Wed, 15 Jan 2014 10:24:08 +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: Sebastien Vauban Cc: public-emacs-orgmode-mXXj517/zsQ@plane.gmane.org --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi Sébastien, please test the attached patch against master. It creates a new command `org-insert-last-stored-link' bound to `C-c M-l'. You can use `C-2 C-c M-l' to insert the last two links. So the set of commands around inserting links would be: C-c l => store link (the suggested user binding) C-c C-l => insert a link C-c C-M-l => insert all links as a list C-u C-c C-M-l => insert all links as a list and keep them C-1 C-c C-M-l => insert the last stored link C-c M-l => short for the previous keybinding I also find myself in this workflow: 1. collect various links through a session 2. store the last one for a new task 3. dump all links into some "read later" heading so I think this feature deserves to be in core. What do you and others think? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org-insert-all-links.patch diff --git a/lisp/org.el b/lisp/org.el index ecd84e9..85e7ce5 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9930,14 +9930,29 @@ This command can be called in any mode to insert a link in Org-mode syntax." (org-load-modules-maybe) (org-run-like-in-org-mode 'org-insert-link)) -(defun org-insert-all-links (&optional keep) - "Insert all links in `org-stored-links'." +(defun org-insert-all-links (&optional keep not-as-list-item) + "Insert all links in `org-stored-links'. +When `keep' is non-nil, do not delete then link from `org-stored-links'. +When `not-as-list-item', insert the link directly, not as a list item." (interactive "P") - (let ((links (copy-sequence org-stored-links)) l) - (while (setq l (if keep (pop links) (pop org-stored-links))) - (insert "- ") + (let ((org-keep-stored-link-after-insertion (equal keep '(4))) + (links (copy-seq org-stored-links)) + (cnt 1) l) + (if (null org-stored-links) + (message "No link to insert") + (while (and (or (listp keep) (>= keep cnt)) + (setq l (if (listp keep) + (pop links) + (pop org-stored-links)))) + (setq cnt (1+ cnt)) + (unless not-as-list-item (insert "- ")) (org-insert-link nil (car l) (or (cadr l) "")) - (insert "\n")))) + (unless not-as-list-item (insert "\n")))))) + +(defun org-insert-last-stored-link (arg) + "Insert the last link stored in `org-stored-links'." + (interactive "p") + (org-insert-all-links arg t)) (defun org-link-fontify-links-to-this-file () "Fontify links to the current file in `org-stored-links'." @@ -19198,6 +19213,7 @@ boundaries." (org-defkey org-mode-map "\C-c\C-x\C-n" 'org-next-link) (org-defkey org-mode-map "\C-c\C-x\C-p" 'org-previous-link) (org-defkey org-mode-map "\C-c\C-l" 'org-insert-link) +(org-defkey org-mode-map "\C-c\M-l" 'org-insert-last-stored-link) (org-defkey org-mode-map "\C-c\C-\M-l" 'org-insert-all-links) (org-defkey org-mode-map "\C-c\C-o" 'org-open-at-point) (org-defkey org-mode-map "\C-c%" 'org-mark-ring-push) --=-=-= Content-Type: text/plain -- Bastien --=-=-=--