emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [BUG] org-clock-display is partial (only some entries are counted)
Date: Fri, 20 Feb 2015 11:38:44 +0100	[thread overview]
Message-ID: <87pp943m17.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <86a90bntnf.fsf@example.com> (Sebastien Vauban's message of "Wed, 18 Feb 2015 16:09:24 +0100")

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

Sebastien Vauban <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
writes:

> I still consider the default behavior as dangerous -- because the novice
> is not aware (except if obvious) that some clock times may be dropped in
> the computation, and I find that scary --, but thanks anyway for the
> workaround.

Would you mind testing the following patch, then? `untilnow' is just
a suggestion.

Regards,


[-- Attachment #2: 0001-org-clock-Add-untilnow-time-block.patch --]
[-- Type: text/x-diff, Size: 4540 bytes --]

From eec96edbc27a56159642f939a9ccd0e56e348a58 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Date: Fri, 20 Feb 2015 11:35:16 +0100
Subject: [PATCH] org-clock: Add `untilnow' time block
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-clock.el (org-clock-special-range): Handle `untilnow'
  range.
(org-clock-display-default-range): Add `untilnow' as valid range.

* doc/org.texi (The clock table): Document `untilnow'

Suggested-by: Sébastien Vauban
---
 doc/org.texi      |  1 +
 lisp/org-clock.el | 33 +++++++++++++++++++++------------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index bec46a9..ba553e2 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6572,6 +6572,7 @@ be selected:
              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
+             untilnow
              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
 :tstart      @r{A time string specifying when to start considering times.}
              @r{Relative times like @code{"<-2w>"} can also be used.  See}
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 07f02b0..f6cc766 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -440,6 +440,7 @@ This applies when using `org-clock-goto'."
 		 (const lastmonth)
 		 (const thisyear)
 		 (const lastyear)
+		 (const untilnow)
 		 (const :tag "Select range interactively" interactive)))
 
 (defvar org-clock-in-prepare-hook nil
@@ -2087,18 +2088,24 @@ buffer and update it."
 
 (defun org-clock-special-range (key &optional time as-strings wstart mstart)
   "Return two times bordering a special time range.
-Key is a symbol specifying the range and can be one of `today', `yesterday',
-`thisweek', `lastweek', `thismonth', `lastmonth', `thisyear', `lastyear'.
-By default, a week starts Monday 0:00 and ends Sunday 24:00.
-The range is determined relative to TIME, which defaults to current time.
-The return value is a cons cell with two internal times like the ones
-returned by `current time' or `encode-time'.
-If AS-STRINGS is non-nil, the returned times will be formatted strings.
-If WSTART is non-nil, use this number to specify the starting day of a
-week (monday is 1).
-If MSTART is non-nil, use this number to specify the starting day of a
-month (1 is the first day of the month).
-If you can combine both, the month starting day will have priority."
+
+KEY is a symbol specifying the range and can be one of `today',
+`yesterday', `thisweek', `lastweek', `thismonth', `lastmonth',
+`thisyear', `lastyear' or `untilnow'.
+
+By default, a week starts Monday 0:00 and ends Sunday 24:00.  The
+range is determined relative to TIME, which defaults to current
+time.
+
+The return value is a cons cell with two internal times like the
+ones returned by `current time' or `encode-time'.  If AS-STRINGS
+is non-nil, the returned times will be formatted strings.
+
+If WSTART is non-nil, use this number to specify the starting day
+of a week (monday is 1).  If MSTART is non-nil, use this number
+to specify the starting day of a month (1 is the first day of the
+month).  If you can combine both, the month starting day will
+have priority."
   (if (integerp key) (setq key (intern (number-to-string key))))
   (let* ((tm (decode-time (or time (current-time))))
 	 (s 0) (m (nth 1 tm)) (h (nth 2 tm))
@@ -2190,6 +2197,7 @@ If you can combine both, the month starting day will have priority."
 	      month1 (+ 4 (* 3 (- (+ q shift) 1))) h1 0 m1 0))))
      ((memq key '(year thisyear))
       (setq m 0 h 0 d 1 month 1 y (+ y shift) y1 (1+ y)))
+     ((eq key 'untilnow) (setq y1 y month1 m d1 d m 0 h 0 d 1 month 1 y 1))
      ((eq key 'interactive) nil)
      (t (user-error "No such time block %s" key)))
     (setq ts (encode-time s m h d month y)
@@ -2205,6 +2213,7 @@ If you can combine both, the month starting day will have priority."
       (setq txt (format-time-string "%B %Y" ts)))
      ((memq key '(year thisyear))
       (setq txt (format-time-string "the year %Y" ts)))
+     ((eq key 'untilnow) (setq txt "now"))
      ((memq key '(quarter thisq))
       (setq txt (concat (org-count-quarter shiftedq)
 			" quarter of " (number-to-string shiftedy)))))
-- 
2.3.0


  reply	other threads:[~2015-02-20 10:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-17  9:12 [BUG] org-clock-display is partial (only some entries are counted) Sebastien Vauban
2015-02-17 21:13 ` Nicolas Goaziou
     [not found]   ` <87h9ukutpy.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org>
2015-02-18 12:20     ` Sebastien Vauban
2015-02-18 14:52       ` Nicolas Goaziou
2015-02-18 15:09         ` Sebastien Vauban
2015-02-20 10:38           ` Nicolas Goaziou [this message]
     [not found]             ` <87pp943m17.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org>
2015-06-25 14:01               ` Sebastien Vauban
2015-06-25 16:27                 ` Nicolas Goaziou
     [not found]                   ` <87381fycrh.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org>
2015-07-03 10:13                     ` Sebastien Vauban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pp943m17.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).