emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: emacs-orgmode@gnu.org
Cc: Bernt Hansen <bernt@norang.ca>
Subject: [PATCH] Open single link immediately
Date: Fri, 28 Aug 2009 13:23:00 -0400	[thread overview]
Message-ID: <1251480180-9815-1-git-send-email-bernt@norang.ca> (raw)

C-c C-o on a headline or in the agenda displays a menu of links to
choose from.  If there is only a single link then go there directly
skipping the menu.
---
This patch is available at git://git.norang.ca/org-mode.git for-carsten

 lisp/org.el |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a5181ab..f3d8976 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8073,21 +8073,22 @@ needed for the interpretation of abbreviated links."
 	(push (match-string 0) links))
       (setq links (reverse links))
       (unless links (error "No links"))
-      
-      (unless (and (integerp nth) (>= (length links) nth))
-	(save-excursion
-	  (save-window-excursion
-	    (delete-other-windows)
-	    (with-output-to-temp-buffer "*Select Link*"
-	      (princ "Select link\n\n")
-	      (mapc (lambda (l) (princ (format "[%d] %s\n" (incf cnt) l)))
-		    links))
-	    (org-fit-window-to-buffer (get-buffer-window "*Select Link*"))
-	    (message "Select link to open:")
-	    (setq c (read-char-exclusive))
-	      (and (get-buffer "*Select Link*") (kill-buffer "*Select Link*"))))
-	(setq nth (- c ?0)))
-      
+      (if (eq 1 (length links))
+	  (setq c 1)
+	(unless (and (integerp nth) (>= (length links) nth))
+	  (save-excursion
+	    (save-window-excursion
+	      (delete-other-windows)
+	      (with-output-to-temp-buffer "*Select Link*"
+		(princ "Select link\n\n")
+		(mapc (lambda (l) (princ (format "[%d] %s\n" (incf cnt) l)))
+		      links))
+	      (org-fit-window-to-buffer (get-buffer-window "*Select Link*"))
+	      (message "Select link to open:")
+	      (setq c (read-char-exclusive))
+	      (and (get-buffer "*Select Link*") (kill-buffer "*Select Link*"))))))
+      (setq nth (- c ?0))
+
       (unless (and (integerp nth) (>= (length links) nth))
 	(error "Invalid link selection"))
       (setq link (nth (1- nth) links)
-- 
1.6.4.1.331.gda1d56

             reply	other threads:[~2009-08-28 17:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-28 17:23 Bernt Hansen [this message]
2009-08-30  8:09 ` [PATCH] Open single link immediately Carsten Dominik
2009-08-30 14:27   ` Tim O'Callaghan

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=1251480180-9815-1-git-send-email-bernt@norang.ca \
    --to=bernt@norang.ca \
    --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).