浏览代码

org.el (org-sort-remove-invisible): Truly returns the visible part of the string

* org.el (org-sort-remove-invisible): Use defsust.  Do not
only check against invisible links, truly returns the visible
part of the string.

Thanks to François Pinard for suggesting this.
Bastien Guerry 12 年之前
父节点
当前提交
30d6dc8baa
共有 1 个文件被更改,包括 7 次插入8 次删除
  1. 7 8
      lisp/org.el

+ 7 - 8
lisp/org.el

@@ -8319,14 +8319,13 @@ Optional argument WITH-CASE means sort case-sensitively."
    (t
    (t
     (org-call-with-arg 'org-sort-entries with-case))))
     (org-call-with-arg 'org-sort-entries with-case))))
 
 
-(defun org-sort-remove-invisible (s)
-  "Remove invisible links from string S."
-  (remove-text-properties 0 (length s) org-rm-props s)
-  (while (string-match org-bracket-link-regexp s)
-    (setq s (replace-match (if (match-end 2)
-			       (match-string 3 s)
-			     (match-string 1 s)) t t s)))
-  s)
+(defsubst org-sort-remove-invisible (s)
+  "Return the visible string from string S."
+  (let (result)
+    (dotimes (c (length s))
+      (let ((st (substring s c (1+ c))))
+	(unless (get-text-property 0 'invisible st) (push st result))))
+    (mapconcat 'identity (reverse result) "")))
 
 
 (defvar org-priority-regexp) ; defined later in the file
 (defvar org-priority-regexp) ; defined later in the file