[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: |
Wed, 15 Jan 2014 12:22:52 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Bastien <address@hidden> 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) "<no description>"))
> - (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