diff options
author | Bastien Guerry <bzg@altern.org> | 2012-12-11 18:13:41 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2012-12-11 18:13:41 +0100 |
commit | 7f0e7cb9b98d6ad1ab6e559fef81c1394f0a748c (patch) | |
tree | 7113dc1848d7de3103bff1339addee98bc97cf97 | |
parent | 0c68a27ac9830395b8eb38009d2c028cc175043c (diff) | |
download | org-mode-7f0e7cb9b98d6ad1ab6e559fef81c1394f0a748c.tar.gz |
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.
-rw-r--r-- | lisp/org.el | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el index 0cd7c27..bc551fe 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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." (interactive "P") (let ((case-func (if with-case 'identity 'downcase)) + (cmstr + ;; The clock marker is lost when using `sort-subr', let's + ;; store the clocking string. + (when (equal (marker-buffer org-clock-marker) (current-buffer)) + (save-excursion + (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." (message "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:" what) (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)) '<))))) (run-hooks 'org-after-sorting-entries-or-items-hook) + ;; Reset the clock marker if needed + (when cmstr + (save-excursion + (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) |