From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: org-store-link without having to press Enter? Date: Wed, 15 Jan 2014 12:22:52 -0500 Message-ID: <877ga140sz.fsf@alphaville.bos.redhat.com> References: <86k3e2clzz.fsf@somewhere.org> <87vbxm41iq.fsf@alphaville.bos.redhat.com> <86eh49bnt3.fsf@somewhere.org> <87lhyhry81.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3UBS-0005nX-0R for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 12:23:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3UBM-0003dk-14 for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 12:23:17 -0500 Received: from plane.gmane.org ([80.91.229.3]:35898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3UBK-0003dV-Ig for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 12:23:11 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W3UBE-0004E1-NA for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 18:23:04 +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 ; Wed, 15 Jan 2014 18:23:04 +0100 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Jan 2014 18:23:04 +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 Bastien writes: > 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? > Much better! > > 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'. ^^^the > +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'." Not sure whether it's worth adding a comment here: I had to experiment a bit to convince myself that an interactive call without a prefix arg passed 1 as the value of arg. I found it unclear but that may be just my ignorance. > + (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) Nick