forked from mirrors/org-mode
Let sort-by-time handle [H]H:MM strings and add a :sort parameter for clocktables
* org-clock.el (org-clocktable-write-default): New parameter ":sort" to sort a column by a sorting type. E.g., a value of :sort (1 . ?a) will sort the first column alphabetically. The sorting line is the third one, table-wise, which is usually the first line that contains user data. * org.texi (The clock table): Document the new :sort parameter. * org.el (org-do-sort): Recognize [H]H:MM strings as time values and allow sort-by-time to process them. * org-table.el (org-table-sort-lines): Mention that sorting by time also recognize [H]H:MM time values.
This commit is contained in:
parent
6ff38b1f6d
commit
132da2db35
|
@ -6533,6 +6533,8 @@ but you can specify your own function using the @code{:formatter} parameter.
|
|||
:tcolumns @r{Number of columns to be used for times. If this is smaller}
|
||||
@r{than @code{:maxlevel}, lower levels will be lumped into one column.}
|
||||
:level @r{Should a level number column be included?}
|
||||
:sort @r{A cons cell like containing the column to sort and a sorting type.}
|
||||
@r{E.g., @code{:sort (1 . ?a)} sorts the first column alphabetically.}
|
||||
:compact @r{Abbreviation for @code{:level nil :indent t :narrow 40! :tcolumns 1}}
|
||||
@r{All are overwritten except if there is an explicit @code{:narrow}}
|
||||
:timestamp @r{A timestamp for the entry, when available. Look for SCHEDULED,}
|
||||
|
|
|
@ -2339,6 +2339,7 @@ from the dynamic block definition."
|
|||
org-clock-clocktable-language-setup))
|
||||
(multifile (plist-get params :multifile))
|
||||
(block (plist-get params :block))
|
||||
(sort (plist-get params :sort))
|
||||
(ts (plist-get params :tstart))
|
||||
(te (plist-get params :tend))
|
||||
(header (plist-get params :header))
|
||||
|
@ -2545,6 +2546,11 @@ from the dynamic block definition."
|
|||
(when org-hide-emphasis-markers
|
||||
;; we need to align a second time
|
||||
(org-table-align))
|
||||
(when sort
|
||||
(save-excursion
|
||||
(org-table-goto-line 3)
|
||||
(org-table-goto-column (car sort))
|
||||
(org-table-sort-lines nil (cdr sort))))
|
||||
(when recalc
|
||||
(if (eq formula '%)
|
||||
(save-excursion
|
||||
|
|
|
@ -1642,7 +1642,8 @@ should be in the last line to be included into the sorting.
|
|||
|
||||
The command then prompts for the sorting type which can be
|
||||
alphabetically, numerically, or by time (as given in a time stamp
|
||||
in the field). Sorting in reverse order is also possible.
|
||||
in the field, or as a HH:MM value). Sorting in reverse order is
|
||||
also possible.
|
||||
|
||||
With prefix argument WITH-CASE, alphabetic sorting will be case-sensitive.
|
||||
|
||||
|
|
19
lisp/org.el
19
lisp/org.el
|
@ -8885,9 +8885,10 @@ When sorting is done, call `org-after-sorting-entries-or-items-hook'."
|
|||
(defun org-do-sort (table what &optional with-case sorting-type)
|
||||
"Sort TABLE of WHAT according to SORTING-TYPE.
|
||||
The user will be prompted for the SORTING-TYPE if the call to this
|
||||
function does not specify it. WHAT is only for the prompt, to indicate
|
||||
what is being sorted. The sorting key will be extracted from
|
||||
the car of the elements of the table.
|
||||
function does not specify it.
|
||||
WHAT is only for the prompt, to indicate what is being sorted.
|
||||
The sorting key will be extracted from the car of the elements of
|
||||
the table.
|
||||
If WITH-CASE is non-nil, the sorting will be case-sensitive."
|
||||
(unless sorting-type
|
||||
(message
|
||||
|
@ -8911,11 +8912,13 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
|
|||
((= dcst ?t)
|
||||
(setq extractfun
|
||||
(lambda (x)
|
||||
(if (or (string-match org-ts-regexp x)
|
||||
(string-match org-ts-regexp-both x))
|
||||
(org-float-time
|
||||
(org-time-string-to-time (match-string 0 x)))
|
||||
0))
|
||||
(cond ((or (string-match org-ts-regexp x)
|
||||
(string-match org-ts-regexp-both x))
|
||||
(org-float-time
|
||||
(org-time-string-to-time (match-string 0 x))))
|
||||
((string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" x)
|
||||
(org-hh:mm-string-to-minutes x))
|
||||
(t 0)))
|
||||
comparefun (if (= dcst sorting-type) '< '>)))
|
||||
(t (error "Invalid sorting type `%c'" sorting-type)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue