浏览代码

Simplyfy links in imenu and refile display.

Patch by James TD Smith.
Carsten Dominik 16 年之前
父节点
当前提交
d670d20af2
共有 3 个文件被更改,包括 21 次插入2 次删除
  1. 4 0
      lisp/ChangeLog
  2. 2 0
      lisp/org-compat.el
  3. 15 2
      lisp/org.el

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2008-09-20  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.
+
 	* org-remember.el (org-remember-apply-template): Add a new
 	expansion for adding properties to remember items.
 

+ 2 - 0
lisp/org-compat.el

@@ -30,6 +30,8 @@
 
 ;;; Code:
 
+(require 'org-macs)
+
 (defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself
 (defconst org-format-transports-properties-p
   (let ((x "a"))

+ 15 - 2
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)))))
@@ -9037,6 +9037,7 @@ This is done in the same way as adding a state change note."
   (interactive)
   (org-add-log-setup 'note nil 'findpos nil))
 
+(defvar org-property-end-re)
 (defun org-add-log-setup (&optional purpose state findpos how &optional extra)
   "Set up the post command hook to take a note.
 If this is about to TODO state change, the new state is expected in STATE.
@@ -14676,7 +14677,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 +14695,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)