summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Abrahams <dave@boostpro.com>2012-04-20 19:41:02 +0200
committerBastien Guerry <bzg@altern.org>2012-04-21 00:43:02 +0200
commita84fa6eccd780f43f5da0899df3b6de728172bbb (patch)
tree5bbd0d9131d3cc0e571529552ac37b77eec5604e
parenta9d3ce0bcd3492eb0cd2aa7b0d1f6ee93276114b (diff)
downloadorg-mode-a84fa6eccd780f43f5da0899df3b6de728172bbb.tar.gz
org.el: Make links more readable when selecting them for insertion.
* org.el (org-link-prettify): New function to prettify links while displaying them with `org-insert-link'. (org-insert-link): Use the new function. TINYCHANGE
-rw-r--r--lisp/org.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 72681d0..c5bb2b1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9103,6 +9103,14 @@ Note: this function also decodes single byte encodings like
(setq s (replace-match "%40" t t s)))
s)
+(defun org-link-prettify (link)
+ "Return a human-readable representation of LINK.
+The car of LINK must be a raw link the cdr of LINK must be either
+a link description or nil."
+ (let ((desc (or (cadr link) "<no description>")))
+ (concat (format "%-45s" (substring desc 0 (min (length desc) 40)))
+ "[[" (car link) "]]")))
+
;;;###autoload
(defun org-insert-link-global ()
"Insert a link like Org-mode does.
@@ -9185,9 +9193,7 @@ be used as the default description."
Use TAB to complete link prefixes, then RET for type-specific completion support\n")
(when org-stored-links
(princ "\nStored links are available with <up>/<down> or M-p/n (most recent with RET):\n\n")
- (princ (mapconcat
- (lambda (x)
- (if (nth 1 x) (concat (car x) " (" (nth 1 x) ")") (car x)))
+ (princ (mapconcat 'org-link-prettify
(reverse org-stored-links) "\n"))))
(let ((cw (selected-window)))
(select-window (get-buffer-window "*Org Links*" 'visible))
@@ -9196,7 +9202,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
(org-fit-window-to-buffer))
(and (window-live-p cw) (select-window cw)))
;; Fake a link history, containing the stored links.
- (setq tmphist (append (mapcar 'car org-stored-links)
+ (setq tmphist (append (mapcar 'org-link-prettify org-stored-links)
org-insert-link-history))
(setq all-prefixes (append (mapcar 'car org-link-abbrev-alist-local)
(mapcar 'car org-link-abbrev-alist)