emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: James TD Smith <ahktenzero@mohorovi.cc>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix link display in imenus and the refile interface
Date: Sun, 21 Sep 2008 15:31:23 +0100	[thread overview]
Message-ID: <20080921143009.11248.62834.stgit@nyarlathotep.internal.mohorovi.cc> (raw)
In-Reply-To: <F6A92091-9F3C-41C3-938B-3C780529DA04@uva.nl>

I've fixed both problems. 

Replace links with their descriptions in when generating the items for imenus
and the refile interface. For links with no description the link target is used
instead.
---

 lisp/ChangeLog     |    6 ++++++
 lisp/org-compat.el |    2 +-
 lisp/org.el        |   16 ++++++++++++++--
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 56e290e..9fe09d1 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-21  James TD Smith  <ahktenzero@mohorovi.cc>
+
+	* org.el (org-get-refile-targets): Replace links with their
+	descriptions
+	(org-imenu-get-tree): Replace links with their descriptions
+
 2008-09-20  James TD Smith  <ahktenzero@mohorovi.cc>
 
 	* org-remember.el (org-remember-apply-template): Add a new
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index b4d2660..dc8d9cb 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -261,7 +261,7 @@ that can be added."
   (if (featurep 'xemacs)
       (add-text-properties 0 (length string) properties string)
     (apply 'propertize string properties)))
- 
+
 (provide 'org-compat)
 
 ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
diff --git a/lisp/org.el b/lisp/org.el
index b1f6829..74a2a11 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7866,7 +7866,7 @@ on the system \"/user@host:\"."
 		(while (re-search-forward descre nil t)
 		  (goto-char (point-at-bol))
 		  (when (looking-at org-complex-heading-regexp)
-		    (setq txt (match-string 4)
+		    (setq txt (org-link-display-format (match-string 4))
 			  re (concat "^" (regexp-quote
 					  (buffer-substring (match-beginning 1)
 							    (match-end 4)))))
@@ -14676,7 +14676,8 @@ Show the heading too, if it is currently invisible."
 	  (setq level (org-reduced-level (funcall outline-level)))
 	  (when (<= level n)
 	    (looking-at org-complex-heading-regexp)
-	    (setq head (org-match-string-no-properties 4)
+	    (setq head (org-link-display-format
+			(org-match-string-no-properties 4))
 		  m (org-imenu-new-marker))
 	    (org-add-props head nil 'org-imenu-marker m 'org-imenu t)
 	    (if (>= level last-level)
@@ -14693,6 +14694,17 @@ Show the heading too, if it is currently invisible."
 		 (if (eq major-mode 'org-mode)
 		     (org-show-context 'org-goto))))))
 
+(defun org-link-display-format (link)
+  "Replace a link with either the description, or the link target
+if no description is present"
+  (save-match-data
+    (if (string-match org-bracket-link-analytic-regexp link)
+	(replace-match (or (match-string 5 link)
+			   (concat (match-string 1 link)
+				   (match-string 3 link)))
+		       nil nil link)
+      link)))
+
 ;; Speedbar support
 
 (defvar org-speedbar-restriction-lock-overlay (org-make-overlay 1 1)

  reply	other threads:[~2008-09-21 14:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-20 21:08 [PATCH 0/9] Update my last patchset James TD Smith
2008-09-20 21:08 ` [PATCH 1/9] Some improvements to the modeline clock display James TD Smith
2008-09-20 21:08 ` [PATCH 2/9] Fix X clipboard handling in emacs21 James TD Smith
2008-09-20 21:08 ` [PATCH 3/9] Show durations of clocked times in timeline James TD Smith
2008-09-20 21:09 ` [PATCH 4/9] Fix link display in imenus and the refile interface James TD Smith
2008-09-21  6:25   ` Carsten Dominik
2008-09-21 14:31     ` James TD Smith [this message]
2008-09-21 19:40       ` [PATCH] " Carsten Dominik
2008-09-20 21:09 ` [PATCH 5/9] Fix note insertion in entries with drawers James TD Smith
2008-10-16  4:50   ` Carsten Dominik
2008-09-20 21:09 ` [PATCH 6/9] Add some functions for handling checklists James TD Smith
2008-09-20 21:09 ` [PATCH 7/9] Add some new interaction between remember and clocked tasks James TD Smith
2008-09-20 21:09 ` [PATCH 8/9] Add a % expansion for inserting properties in remember buffers James TD Smith
2008-09-20 21:09 ` [PATCH 9/9] Some bugfixes for org-plot James TD Smith
2008-09-21  4:48 ` [PATCH 0/9] Update my last patchset Carsten Dominik
2008-09-21 12:21   ` James TD Smith
2008-09-21 12:43     ` Carsten Dominik

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=20080921143009.11248.62834.stgit@nyarlathotep.internal.mohorovi.cc \
    --to=ahktenzero@mohorovi.cc \
    --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).