emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Show human-readable link descriptions first when inserting l


From: Dave Abrahams
Subject: [O] [PATCH] Show human-readable link descriptions first when inserting links
Date: Wed, 11 Jan 2012 11:23:41 -0500
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.92 (darwin)

This patch makes it easy to select links from among a forest of
similar-looking machine-readable forms.  Without it, the human-readable
descriptions tend to fall off the right side of the window.

>From fa9522e8dd1ef602574d0fb58f8f610ef82b15d7 Mon Sep 17 00:00:00 2001
From: Dave Abrahams <address@hidden>
Date: Thu, 22 Sep 2011 15:11:27 -0400
Subject: [PATCH] Show human-readable link descriptions first when inserting
 links

---
 lisp/org.el |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 3953890..34ae6c4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9016,6 +9016,12 @@ Note: this function also decodes single byte encodings 
like
     (setq s (replace-match "%40" t t s)))
   s)
 
+(defun org-pretty-link (link)
+  "Return a human-digestible representation of a given LINK,
+whose car must be a raw link and whose cadr must be either a link
+description or nil."
+  (concat (or (cadr link) "<no description>") "\t[[" (car link) "]]"))
+
 ;;;###autoload
 (defun org-insert-link-global ()
   "Insert a link like Org-mode does.
@@ -9098,9 +9104,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-pretty-link
                  (reverse org-stored-links) "\n"))))
       (let ((cw (selected-window)))
        (select-window (get-buffer-window "*Org Links*" 'visible))
@@ -9109,7 +9113,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-pretty-link org-stored-links)
                            org-insert-link-history))
       (setq all-prefixes (append (mapcar 'car org-link-abbrev-alist-local)
                                 (mapcar 'car org-link-abbrev-alist)
-- 
1.7.5.4

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]