diff options
author | Bastien Guerry <bzg@altern.org> | 2012-08-05 11:12:04 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2012-08-05 11:12:04 +0200 |
commit | de271e3751878311a5f64c5404acb286ebde36f0 (patch) | |
tree | cdbc4fcfe8ecadc48d03f470d2e242ac1bf68357 | |
parent | 6f571de2f0ec3a07f97cf1183a27711e7155988a (diff) | |
download | org-mode-de271e3751878311a5f64c5404acb286ebde36f0.tar.gz |
Introduce a new special property CLOCKSUM_T for today's clocked time.
* org.el (org-special-properties): New special property
CLOCKSUM_T.
(org-entry-properties): Handle the new special property.
* org-colview.el (org-columns): Handle a new special property
CLOCKSUM_T.
(org-agenda-colview-summarize, org-agenda-colview-compute):
Ditto.
* org-clock.el (org-clock-sum-today): New function.
(org-clock-sum): New argument PROPNAME to set a custom text
property instead of :org-clock-minutes.
* org.texi (Special properties, Column attributes)
(Agenda column view): Document the new special property
CLOCKSUM_T.
Thanks to Brian Wood who asked a question wrt this.
-rw-r--r-- | doc/org.texi | 19 | ||||
-rw-r--r-- | lisp/org-clock.el | 22 | ||||
-rw-r--r-- | lisp/org-colview.el | 25 | ||||
-rw-r--r-- | lisp/org.el | 12 |
4 files changed, 56 insertions, 22 deletions
diff --git a/doc/org.texi b/doc/org.texi index 1e07958..44aa362 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -4999,6 +4999,7 @@ used as keys in the properties drawer: @cindex property, special, TIMESTAMP @cindex property, special, TIMESTAMP_IA @cindex property, special, CLOCKSUM +@cindex property, special, CLOCKSUM_T @cindex property, special, BLOCKED @c guessing that ITEM is needed in this area; also, should this list be sorted? @cindex property, special, ITEM @@ -5018,6 +5019,9 @@ TIMESTAMP @r{The first keyword-less timestamp in the entry.} TIMESTAMP_IA @r{The first inactive timestamp in the entry.} CLOCKSUM @r{The sum of CLOCK intervals in the subtree. @code{org-clock-sum}} @r{must be run first to compute the values in the current buffer.} +CLOCKSUM_T @r{The sum of CLOCK intervals in the subtree for today.} + @r{@code{org-clock-sum-today}} must be run first to compute the} + @r{values in the current buffer.} BLOCKED @r{"t" if task is currently blocked by children or siblings} ITEM @r{The headline of the entry.} FILE @r{The filename the entry is located in.} @@ -5235,7 +5239,7 @@ values. @example :COLUMNS: %25ITEM %9Approved(Approved?)@{X@} %Owner %11Status \@footnote{Please note that the COLUMNS definition must be on a single line---it is wrapped here only because of formatting constraints.} - %10Time_Estimate@{:@} %CLOCKSUM + %10Time_Estimate@{:@} %CLOCKSUM %CLOCKSUM_T :Owner_ALL: Tammy Mark Karl Lisa Don :Status_ALL: "In progress" "Not started yet" "Finished" "" :Approved_ALL: "[ ]" "[X]" @@ -5254,8 +5258,9 @@ modified title (@samp{Approved?}, with a question mark). Summaries will be created for the @samp{Time_Estimate} column by adding time duration expressions like HH:MM, and for the @samp{Approved} column, by providing an @samp{[X]} status if all children have been checked. The -@samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals -in the subtree. +@samp{CLOCKSUM} and @samp{CLOCKSUM_T} columns are special, they lists the +sums of CLOCK intervals in the subtree, either for all clocks or just for +today. @node Using column view, Capturing column view, Defining columns, Column view @subsection Using column view @@ -8940,6 +8945,14 @@ a column listing the planned total effort for a task---one of the major applications for column view in the agenda. If you want information about clocked time in the displayed period use clock table mode (press @kbd{R} in the agenda). + +@item +@cindex property, special, CLOCKSUM_T +When the column view in the agenda shows the @code{CLOCKSUM_T}, that is +always today's clocked time for this item. So even in the weekly agenda, +the clocksum listed in column view only originates from today. This lets +you compare the time you spent on a task for today, with the time already +spent (via @code{CLOCKSUM}) and with the planned total effort for it. @end enumerate diff --git a/lisp/org-clock.el b/lisp/org-clock.el index f04c578..b4a752e 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1618,13 +1618,20 @@ With prefix arg SELECT, offer recently clocked tasks for selection." "Holds the file total time in minutes, after a call to `org-clock-sum'.") (make-variable-buffer-local 'org-clock-file-total-minutes) -(defun org-clock-sum (&optional tstart tend headline-filter) +(defun org-clock-sum-today (&optional headline-filter) + "Sum the times for each subtree for today." + (interactive) + (let ((range (org-clock-special-range 'today))) + (org-clock-sum (car range) (cadr range) nil :org-clock-minutes-today))) + +(defun org-clock-sum (&optional tstart tend headline-filter propname) "Sum the times for each subtree. Puts the resulting times in minutes as a text property on each headline. -TSTART and TEND can mark a time range to be considered. HEADLINE-FILTER is a -zero-arg function that, if specified, is called for each headline in the time -range with point at the headline. Headlines for which HEADLINE-FILTER returns -nil are excluded from the clock summation." +TSTART and TEND can mark a time range to be considered. +HEADLINE-FILTER is a zero-arg function that, if specified, is called for +each headline in the time range with point at the headline. Headlines for +which HEADLINE-FILTER returns nil are excluded from the clock summation. +PROPNAME lets you set a custom text property instead of :org-clock-minutes." (interactive) (let* ((bmp (buffer-modified-p)) (re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*" @@ -1641,7 +1648,7 @@ nil are excluded from the clock summation." (if (consp tstart) (setq tstart (org-float-time tstart))) (if (consp tend) (setq tend (org-float-time tend))) (remove-text-properties (point-min) (point-max) - '(:org-clock-minutes t + `(,(or propname :org-clock-minutes) t :org-clock-force-headline-inclusion t)) (save-excursion (goto-char (point-max)) @@ -1690,7 +1697,8 @@ nil are excluded from the clock summation." (aset ltimes l (+ (aref ltimes l) t1)))) (setq time (aref ltimes level)) (goto-char (match-beginning 0)) - (put-text-property (point) (point-at-eol) :org-clock-minutes time) + (put-text-property (point) (point-at-eol) + (or propname :org-clock-minutes) time) (if headline-filter (save-excursion (save-match-data diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 0307402..dd1a013 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -700,6 +700,11 @@ around it." (save-restriction (narrow-to-region beg end) (org-clock-sum)))) + (when (assoc "CLOCKSUM_T" org-columns-current-fmt-compiled) + (save-excursion + (save-restriction + (narrow-to-region beg end) + (org-clock-sum-today)))) (while (re-search-forward org-outline-regexp-bol end t) (if (and org-columns-skip-archived-trees (looking-at (concat ".*:" org-archive-tag ":"))) @@ -1406,8 +1411,8 @@ and tailing newline characters." "Summarize the summarizable columns in column view in the agenda. This will add overlays to the date lines, to show the summary for each day." (let* ((fmt (mapcar (lambda (x) - (if (equal (car x) "CLOCKSUM") - (list "CLOCKSUM" (nth 1 x) (nth 2 x) ":" 'add_times + (if (string-match "CLOCKSUM.*" (car x)) + (list (match-string 0) (nth 1 x) (nth 2 x) ":" 'add_times nil '+ nil) x)) org-columns-current-fmt-compiled)) @@ -1494,13 +1499,15 @@ This will add overlays to the date lines, to show the summary for each day." (goto-char (point-min)) (org-columns-get-format-and-top-level) (while (setq fm (pop fmt)) - (if (equal (car fm) "CLOCKSUM") - (org-clock-sum) - (when (and (nth 4 fm) - (setq a (assoc (car fm) - org-columns-current-fmt-compiled)) - (equal (nth 4 a) (nth 4 fm))) - (org-columns-compute (car fm))))))))))) + (cond ((equal (car fm) "CLOCKSUM") + (org-clock-sum)) + ((equal (car fm) "CLOCKSUM_T") + (org-clock-sum-today)) + ((and (nth 4 fm) + (setq a (assoc (car fm) + org-columns-current-fmt-compiled)) + (equal (nth 4 a) (nth 4 fm))) + (org-columns-compute (car fm))))))))))) (defun org-format-time-period (interval) "Convert time in fractional days to days/hours/minutes/seconds." diff --git a/lisp/org.el b/lisp/org.el index 0470451..b60bba2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14174,7 +14174,7 @@ a *different* entry, you cannot use these techniques." (defconst org-special-properties '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "CLOSED" "PRIORITY" - "TIMESTAMP" "TIMESTAMP_IA" "BLOCKED" "FILE" "CLOCKSUM") + "TIMESTAMP" "TIMESTAMP_IA" "BLOCKED" "FILE" "CLOCKSUM" "CLOCKSUM_T") "The special properties valid in Org-mode. These are properties that are not defined in the property drawer, @@ -14351,14 +14351,15 @@ things up because then unnecessary parsing is avoided." (let ((clockstr (substring org-clock-string 0 -1)) (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED")) (case-fold-search nil) - beg end range props sum-props key key1 value string clocksum) + beg end range props sum-props key key1 value string clocksum clocksumt) (save-excursion (when (condition-case nil (and (derived-mode-p 'org-mode) (org-back-to-heading t)) (error nil)) (setq beg (point)) (setq sum-props (get-text-property (point) 'org-summaries)) - (setq clocksum (get-text-property (point) :org-clock-minutes)) + (setq clocksum (get-text-property (point) :org-clock-minutes) + clocksumt (get-text-property (point) :org-clock-minutes-today)) (outline-next-heading) (setq end (point)) (when (memq which '(all special)) @@ -14437,6 +14438,11 @@ things up because then unnecessary parsing is avoided." (org-columns-number-to-string (/ (float clocksum) 60.) 'add_times)) props)) + (if clocksumt + (push (cons "CLOCKSUM_T" + (org-columns-number-to-string (/ (float clocksumt) 60.) + 'add_times)) + props)) (unless (assoc "CATEGORY" props) (push (cons "CATEGORY" (org-get-category)) props)) (append sum-props (nreverse props))))))) |