From mboxrd@z Thu Jan 1 00:00:00 1970 From: James TD Smith Subject: [PATCH] Fix link display in imenus and the refile interface Date: Sun, 21 Sep 2008 15:31:23 +0100 Message-ID: <20080921143009.11248.62834.stgit@nyarlathotep.internal.mohorovi.cc> References: Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KhPyL-0003vc-G4 for emacs-orgmode@gnu.org; Sun, 21 Sep 2008 10:31:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KhPyH-0003un-5k for emacs-orgmode@gnu.org; Sun, 21 Sep 2008 10:31:36 -0400 Received: from [199.232.76.173] (port=57545 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KhPyG-0003uW-Uc for emacs-orgmode@gnu.org; Sun, 21 Sep 2008 10:31:32 -0400 Received: from 81-86-40-42.dsl.pipex.com ([81.86.40.42]:54678 helo=yog-sothoth.mohorovi.cc) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KhPyF-0007OY-Vu for emacs-orgmode@gnu.org; Sun, 21 Sep 2008 10:31:32 -0400 Received: from nyarlathotep.internal.mohorovi.cc (Debian-exim@nyarlathotep.internal.mohorovi.cc [10.0.0.5]) by yog-sothoth.mohorovi.cc (8.14.2/8.14.2) with ESMTP id m8LEVNmV039269 for ; Sun, 21 Sep 2008 15:31:23 +0100 (BST) (envelope-from ahktenzero@mohorovi.cc) Received: from [127.0.0.1] (helo=nyarlathotep.internal.mohorovi.cc ident=ahktenzero) by nyarlathotep.internal.mohorovi.cc with esmtp (Exim 4.69) (envelope-from ) id 1KhPy7-0002zn-AG for emacs-orgmode@gnu.org; Sun, 21 Sep 2008 15:31:23 +0100 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 + + * 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 * 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)