summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-07-28 10:44:10 +0200
committerBastien Guerry <bzg@altern.org>2012-07-28 10:44:10 +0200
commit90f3940e1405be87801c0a49b82b448031194681 (patch)
treed6180f64ef3af7ac28da13eb9980115ea65135a9
parent3a18eefe9d119be77889e1fa087163f303408935 (diff)
downloadorg-mode-90f3940e1405be87801c0a49b82b448031194681.tar.gz
New command `org-insert-all-links'.
* org.el (org-insert-all-links): New command. (org-insert-link): `org-keep-stored-link-after-insertion' is now checked when the link to insert has been defined, regardless on how it has been defined. Also don't read the description interactively when the `default-description' parameter was given. (org-mode-map): Bind `org-insert-all-links' to `C-c C-L'.
-rw-r--r--lisp/org.el23
1 files changed, 17 insertions, 6 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 018926b..944ebde 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9176,6 +9176,15 @@ 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'."
+ (interactive "P")
+ (let ((links (copy-sequence org-stored-links)) l)
+ (while (setq l (if keep (pop links) (pop org-stored-links)))
+ (insert "- ")
+ (org-insert-link nil (car l) (cadr l))
+ (insert "\n"))))
+
(defun org-insert-link (&optional complete-file link-location default-description)
"Insert a link. At the prompt, enter the link.
@@ -9289,12 +9298,13 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
(kill-buffer "*Org Links*"))
(setq entry (assoc link org-stored-links))
(or entry (push link org-insert-link-history))
- (if (funcall (if (equal complete-file '(64)) 'not 'identity)
- (not org-keep-stored-link-after-insertion))
- (setq org-stored-links (delq (assoc link org-stored-links)
- org-stored-links)))
(setq desc (or desc (nth 1 entry)))))
+ (if (funcall (if (equal complete-file '(64)) 'not 'identity)
+ (not org-keep-stored-link-after-insertion))
+ (setq org-stored-links (delq (assoc link org-stored-links)
+ org-stored-links)))
+
(if (string-match org-plain-link-re link)
;; URL-like link, normalize the use of angular brackets.
(setq link (org-make-link (org-remove-angle-brackets link))))
@@ -9342,9 +9352,9 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
(if org-make-link-description-function
(setq desc (funcall org-make-link-description-function link desc))
- (if default-description (setq desc default-description)))
+ (if default-description (setq desc default-description)
+ (setq desc (read-string "Description: " desc))))
- (setq desc (read-string "Description: " desc))
(unless (string-match "\\S-" desc) (setq desc nil))
(if remove (apply 'delete-region remove))
(insert (org-make-link-string link desc))))
@@ -17796,6 +17806,7 @@ BEG and END default to the buffer 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\C-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)
(org-defkey org-mode-map "\C-c&" 'org-mark-ring-goto)