|author||Bastien Guerry <email@example.com>||2012-12-11 17:13:41 (GMT)|
|committer||Bastien Guerry <firstname.lastname@example.org>||2012-12-11 17:13:41 (GMT)|
org.el (org-sort-entries): Bugfix: keep track of the clock marker when sorting entries.
* org.el (org-sort-entries): Bugfix: keep track of the clock marker when sorting entries. Enhance the docstring.
1 files changed, 16 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 0cd7c27..bc551fe 100644
@@ -8017,11 +8017,12 @@ a time stamp, by a property or by priority.
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,
-\(?n ?N ?a ?A ?t ?T ?s ?S ?d ?D ?p ?P ?r ?R ?f ?F). Here is the
+\(?n ?N ?a ?A ?t ?T ?s ?S ?d ?D ?p ?P ?o ?O ?r ?R ?f ?F). Here is the
precise meaning of each character:
n Numerically, by converting the beginning of the entry/item to a number.
a Alphabetically, ignoring the TODO keyword and the priority, if any.
+o By order of TODO keywords.
t By date/time, either the first active time stamp in the entry, or, if
none exist, by the first inactive one.
s By the scheduled date/time.
@@ -8041,6 +8042,13 @@ Comparing entries ignores case by default. However, with an optional argument
WITH-CASE, the sorting considers case as well."
(let ((case-func (if with-case 'identity 'downcase))
+ ;; The clock marker is lost when using `sort-subr', let's
+ ;; store the clocking string.
+ (when (equal (marker-buffer org-clock-marker) (current-buffer))
+ (goto-char org-clock-marker)
+ (looking-back "^.*") (match-string-no-properties 0))))
start beg end stars re re2
txt what tmp)
;; Find beginning and end of region to sort
@@ -8097,7 +8105,7 @@ WITH-CASE, the sorting considers case as well."
"Sort %s: [a]lpha [n]umeric [p]riority p[r]operty todo[o]rder [f]unc
[t]ime [s]cheduled [d]eadline [c]reated
- A/N/T/S/D/C/P/O/F means reversed:"
+ A/N/P/R/O/F/T/S/D/C means reversed:"
(setq sorting-type (read-char-exclusive))
@@ -8194,6 +8202,12 @@ WITH-CASE, the sorting considers case as well."
((= dcst ?f) compare-func)
((member dcst '(?p ?t ?s ?d ?c)) '<)))))
+ ;; Reset the clock marker if needed
+ (when cmstr
+ (goto-char start)
+ (search-forward cmstr nil t)
+ (move-marker org-clock-marker (point))))
(message "Sorting entries...done")))
(defun org-do-sort (table what &optional with-case sorting-type)