diff options
author | Bastien Guerry <bzg@altern.org> | 2013-02-25 10:15:44 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2013-02-25 10:15:44 +0100 |
commit | 49772f1f260f89fd9b5d621e5bf06f9126dab1e0 (patch) | |
tree | 56692b293a2c2fc4f96638340fc7140ccae4fe7e | |
parent | 3a0e559ad976eaf8e6e6d4b304209d310e282a7d (diff) | |
download | org-mode-49772f1f260f89fd9b5d621e5bf06f9126dab1e0.tar.gz |
Remove hidden links when comparing items or entries.
* org.el (org-sort-remove-invisible): Add a docstring.
(org-sort-entries): Remove hidden links when comparing
entries.
* org-list.el (org-sort-list): Remove hidden links when
comparing list items.
Thanks to François Pinard for suggesting this.
-rw-r--r-- | lisp/org-list.el | 14 | ||||
-rw-r--r-- | lisp/org.el | 12 |
2 files changed, 18 insertions, 8 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el index d8f8dd8..c9cfe81 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -2786,7 +2786,10 @@ If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies a function to be called with point at the beginning of the record. It must return either a string or a number that should serve as the sorting key for that record. It will then use -COMPARE-FUNC to compare entries." +COMPARE-FUNC to compare entries. + +Sorting is done against the visible part of the headlines, it +ignores hidden links." (interactive "P") (let* ((case-func (if with-case 'identity 'downcase)) (struct (org-list-struct)) @@ -2826,11 +2829,14 @@ COMPARE-FUNC to compare entries." (when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+") (cond ((= dcst ?n) - (string-to-number (buffer-substring (match-end 0) - (point-at-eol)))) + (string-to-number + (org-sort-remove-invisible + (buffer-substring (match-end 0) (point-at-eol))))) ((= dcst ?a) (funcall case-func - (buffer-substring (match-end 0) (point-at-eol)))) + (org-sort-remove-invisible + (buffer-substring + (match-end 0) (point-at-eol))))) ((= dcst ?t) (cond ;; If it is a timer list, convert timer to seconds diff --git a/lisp/org.el b/lisp/org.el index 3e6cd6c..a445f37 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8320,6 +8320,7 @@ Optional argument WITH-CASE means sort case-sensitively." (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) @@ -8343,7 +8344,7 @@ Else, if the cursor is before the first entry, sort the top-level items. Else, the children of the entry at point are sorted. Sorting can be alphabetically, numerically, by date/time as given by -a time stamp, by a property or by priority. +a time stamp, by a property, by priority order, or by a custom function. The command prompts for the sorting type unless it has been given to the function through the SORTING-TYPE argument, which needs to be a character, @@ -8369,7 +8370,10 @@ called with point at the beginning of the record. It must return either a string or a number that should serve as the sorting key for that record. Comparing entries ignores case by default. However, with an optional argument -WITH-CASE, the sorting considers case as well." +WITH-CASE, the sorting considers case as well. + +Sorting is done against the visible part of the headlines, it ignores hidden +links." (interactive "P") (let ((case-func (if with-case 'identity 'downcase)) (cmstr @@ -8481,11 +8485,11 @@ WITH-CASE, the sorting considers case as well." (cond ((= dcst ?n) (if (looking-at org-complex-heading-regexp) - (string-to-number (match-string 4)) + (string-to-number (org-sort-remove-invisible (match-string 4))) nil)) ((= dcst ?a) (if (looking-at org-complex-heading-regexp) - (funcall case-func (match-string 4)) + (funcall case-func (org-sort-remove-invisible (match-string 4))) nil)) ((= dcst ?t) (let ((end (save-excursion (outline-next-heading) (point)))) |