From: Dave Abrahams <dave@boostpro.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Show human-readable link descriptions first when inserting links
Date: Wed, 11 Jan 2012 11:23:41 -0500 [thread overview]
Message-ID: <m2lipexl6a.fsf@pluto.luannocracy.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 198 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Show-human-readable-link-descriptions-first-when-ins.patch --]
[-- Type: text/x-patch, Size: 1994 bytes --]
From fa9522e8dd1ef602574d0fb58f8f610ef82b15d7 Mon Sep 17 00:00:00 2001
From: Dave Abrahams <dave@boostpro.com>
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
[-- Attachment #3: Type: text/plain, Size: 63 bytes --]
--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
next reply other threads:[~2012-01-11 16:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-11 16:23 Dave Abrahams [this message]
2012-04-23 13:15 ` [PATCH] Show human-readable link descriptions first when inserting links Bastien
2012-04-23 19:49 ` Dave Abrahams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2lipexl6a.fsf@pluto.luannocracy.com \
--to=dave@boostpro.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).