From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: [BUG] org-clock-display is partial (only some entries are counted) Date: Thu, 25 Jun 2015 16:01:59 +0200 Message-ID: <86egkzj38o.fsf@example.com> References: <86pp98sxzq.fsf@example.com> <87h9ukutpy.fsf@nicolasgoaziou.fr> <86y4nvqumm.fsf@example.com> <877fvfp8zq.fsf@nicolasgoaziou.fr> <86a90bntnf.fsf@example.com> <87pp943m17.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <87pp943m17.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org> (Nicolas Goaziou's message of "Fri, 20 Feb 2015 11:38:44 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: Org Mode List Hello Nicolas, Nicolas Goaziou writes: > Sebastien Vauban 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. Applied the patch: --8<---------------cut here---------------start------------->8--- patching file lisp/org-clock.el Hunk #1 succeeded at 441 (offset 1 line). Hunk #2 succeeded at 2091 (offset 3 lines). Hunk #3 succeeded at 2200 (offset 3 lines). Hunk #4 succeeded at 2216 (offset 3 lines). --8<---------------cut here---------------end--------------->8--- Tested on one of my real files, with: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 org-clock-display-default-range is a variable defined in `org-c= lock.el'. =E2=94=82 Its value is untilnow =E2=94=82 Original value was thisyear =E2=94=82=20 =E2=94=82 Documentation: =E2=94=82 Default range when displaying clocks with `org-clock-display'. =E2=94=82=20 =E2=94=82 You can customize this variable. =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 Got this: --8<---------------cut here---------------start------------->8--- Debugger entered--Lisp error: (error "Specified time is not representable") encode-time(0 0 0 1 1 1) (setq ts (encode-time s m h d month y) te (encode-time (or s1 s) (or m1 m= ) (or h1 h) (or d1 d) (or month1 month) (or y1 y))) (let* ((tm (decode-time (or time (current-time)))) (s 0) (m (nth 1 tm)) (= h (nth 2 tm)) (d (nth 3 tm)) (month (nth 4 tm)) (y (nth 5 tm)) (dow (nth 6 = tm)) (ws (or wstart 1)) (ms (or mstart 1)) (skey (symbol-name key)) (shift = 0) (q (cond ((>=3D (nth 4 tm) 10) 4) ((>=3D (nth 4 tm) 7) 3) ((>=3D (nth 4 = tm) 4) 2) ((>=3D (nth 4 tm) 1) 1))) s1 m1 h1 d1 month1 y1 diff ts te fm txt= w date interval tmp shiftedy shiftedm shiftedq) (cond ((string-match "^[0-= 9]+$" skey) (setq y (string-to-number skey) m 1 d 1 key (quote year))) ((st= ring-match "^\\([0-9]+\\)-\\([0-9]\\{1,2\\}\\)$" skey) (setq y (string-to-n= umber (match-string 1 skey)) month (string-to-number (match-string 2 skey))= d 1 key (quote month))) ((string-match "^\\([0-9]+\\)-[wW]\\([0-9]\\{1,2\\= }\\)$" skey) (require (quote cal-iso)) (setq y (string-to-number (match-str= ing 1 skey)) w (string-to-number (match-string 2 skey))) (setq date (calend= ar-gregorian-from-absolute (calendar-iso-to-absolute (list w 1 y)))) (setq = d (nth 1 date) month (car date) y (nth 2 date) dow 1 key (quote week))) ((s= tring-match "^\\([0-9]+\\)-[qQ]\\([1-4]\\)$" skey) (require (quote cal-iso)= ) (setq y (string-to-number (match-string 1 skey))) (setq q (string-to-numb= er (match-string 2 skey))) (setq date (calendar-gregorian-from-absolute (ca= lendar-iso-to-absolute (org-quarter-to-date q y)))) (setq d (nth 1 date) mo= nth (car date) y (nth 2 date) dow 1 key (quote quarter))) ((string-match "^= \\([0-9]+\\)-\\([0-9]\\{1,2\\}\\)-\\([0-9]\\{1,2\\}\\)$" skey) (setq y (str= ing-to-number (match-string 1 skey)) month (string-to-number (match-string = 2 skey)) d (string-to-number (match-string 3 skey)) key (quote day))) ((str= ing-match "\\([-+][0-9]+\\)$" skey) (setq shift (string-to-number (match-st= ring 1 skey)) key (intern (substring skey 0 (match-beginning 1)))) (if (and= (memq key (quote (quarter thisq))) (> shift 0)) (error "Looking forward wi= th quarters isn't implemented")))) (if (=3D shift 0) (progn (cond ((eq key = (quote yesterday)) (setq key (quote today) shift -1)) ((eq key (quote lastw= eek)) (setq key (quote week) shift -1)) ((eq key (quote lastmonth)) (setq k= ey (quote month) shift -1)) ((eq key (quote lastyear)) (setq key (quote yea= r) shift -1)) ((eq key (quote lastq)) (setq key (quote quarter) shift -1)))= )) (cond ((memq key (quote (day today))) (setq d (+ d shift) h 0 m 0 h1 24 = m1 0)) ((memq key (quote (week thisweek))) (setq diff (+ (* -7 shift) (if (= =3D dow 0) (- 7 ws) (- dow ws))) m 0 h 0 d (- d diff) d1 (+ 7 d))) ((memq k= ey (quote (month thismonth))) (setq d (or ms 1) h 0 m 0 d1 (or ms 1) month = (+ month shift) month1 (1+ month) h1 0 m1 0)) ((memq key (quote (quarter th= isq))) (cond ((< (+ (- q 1) shift) 0) (setq interval (* -1 (+ ... shift))) = (setq tmp (org-floor* interval 4)) (if (=3D 0 (nth 1 tmp)) (setq shiftedy (= - y ...) shiftedm 1 shiftedq 1) (setq shiftedy (- y ...) shiftedm (- 13 ...= ) shiftedq (- 5 ...))) (setq d 1 h 0 m 0 d1 1 month shiftedm month1 (+ 3 sh= iftedm) h1 0 m1 0 y shiftedy)) ((> (+ q shift) 0) (setq shiftedq (+ q shift= )) (setq shiftedy y) (setq d 1 h 0 m 0 d1 1 month (+ 1 (* 3 ...)) month1 (+= 4 (* 3 ...)) h1 0 m1 0)))) ((memq key (quote (year thisyear))) (setq m 0 h= 0 d 1 month 1 y (+ y shift) y1 (1+ y))) ((eq key (quote untilnow)) (setq y= 1 y month1 m d1 d m 0 h 0 d 1 month 1 y 1)) ((eq key (quote interactive)) n= il) (t (user-error "No such time block %s" key))) (setq ts (encode-time s m= h d month y) te (encode-time (or s1 s) (or m1 m) (or h1 h) (or d1 d) (or m= onth1 month) (or y1 y))) (setq fm (cdr org-time-stamp-formats)) (cond ((mem= q key (quote (day today))) (setq txt (format-time-string "%A, %B %d, %Y" ts= ))) ((memq key (quote (week thisweek))) (setq txt (format-time-string "week= %G-W%V" ts))) ((memq key (quote (month thismonth))) (setq txt (format-time= -string "%B %Y" ts))) ((memq key (quote (year thisyear))) (setq txt (format= -time-string "the year %Y" ts))) ((eq key (quote untilnow)) (setq txt "now"= )) ((memq key (quote (quarter thisq))) (setq txt (concat (org-count-quarter= shiftedq) " quarter of " (number-to-string shiftedy))))) (if as-strings (l= ist (format-time-string fm ts) (format-time-string fm te) txt) (if (eq key = (quote interactive)) (list (org-read-date nil t nil "Range start? ") (org-r= ead-date nil t nil "Range end? ") "(Range interactively set)") (list ts te = txt)))) org-clock-special-range(untilnow) (and (symbolp range) (org-clock-special-range range)) (or (and (symbolp range) (org-clock-special-range range)) (org-clock-spec= ial-range (intern (completing-read "Range: " (quote ("today" "yesterday" "t= hisweek" "lastweek" "thismonth" "lastmonth" "thisyear" "lastyear" "interact= ive")) nil t)))) (let ((r (or (and (symbolp range) (org-clock-special-range range)) (org-c= lock-special-range (intern (completing-read "Range: " (quote ...) nil t))))= )) (org-clock-sum (car r) (cadr r) headline-filter (or propname :org-clock-= minutes-custom))) org-clock-sum-custom(nil untilnow :org-clock-minutes-default) (cond ((not arg) (org-clock-sum-custom nil org-clock-display-default-rang= e prop)) (todayp (org-clock-sum-today)) (customp (org-clock-sum-custom nil = arg)) (t (org-clock-sum))) (let* ((todayp (equal arg (quote (4)))) (customp (member arg (quote ((16)= today yesterday thisweek lastweek thismonth lastmonth thisyear lastyear in= teractive)))) (prop (cond ((not arg) :org-clock-minutes-default) (todayp :o= rg-clock-minutes-today) (customp :org-clock-minutes-custom) (t :org-clock-m= inutes))) time h m p) (cond ((not arg) (org-clock-sum-custom nil org-clock-= display-default-range prop)) (todayp (org-clock-sum-today)) (customp (org-c= lock-sum-custom nil arg)) (t (org-clock-sum))) (if (eq arg (quote (64))) ni= l (save-excursion (goto-char (point-min)) (while (or (and (equal (setq p ..= .) (point-min)) (get-text-property p prop)) (setq p (next-single-property-c= hange (point) prop))) (goto-char p) (if (setq time (get-text-property p pro= p)) (progn (org-clock-put-overlay time)))) (setq h (/ org-clock-file-total-= minutes 60) m (- org-clock-file-total-minutes (* 60 h))) (if org-remove-hig= hlights-with-change (progn (org-add-hook (quote before-change-functions) (q= uote org-clock-remove-overlays) nil (quote local)))))) (message (concat (fo= rmat "Total file time%s: " (cond (todayp " for today") (customp " (custom)"= ) (t ""))) (org-minutes-to-clocksum-string org-clock-file-total-minutes) " = (%d hours and %d minutes)") h m)) org-clock-display(nil) call-interactively(org-clock-display nil nil) #[1025 "\306\211?\205\f \211\306=049\203!=04\307N\203!=0B\203!\310\303!\2= 02\235=04\311!\262\211\211\242\312=3D\262\203<\313=06=07\"\211\262\204\"\31= 4!\203l=04\203e\315=03E\fB=0D\247\203e=0D\316V\203e=0D\f\233\211:\203d\211\= 306\241\210\210\315=03\"\202\233\317=06=06=06#=069\203\233=06\320N\203\233= =06\321N\204\233\322=07\321\323#\210\324\325\326 \211\320N\327#\"\210\262\2= 07" [debug-on-next-call prefix-arg current-prefix-arg disabled-command-func= tion command-history history-length nil disabled run-hooks indirect-functio= n autoload autoload-do-load arrayp execute-kbd-macro 0 call-interactively b= yte-obsolete-info command-execute-obsolete-warned put t message "%s" macroe= xp--obsolete-warning "command"] 13 1990350](org-clock-display nil nil nil) funcall(#[1025 "\306\211?\205\f \211\306=049\203!=04\307N\203!=0B\203!\31= 0\303!\202\235=04\311!\262\211\211\242\312=3D\262\203<\313=06=07\"\211\262\= 204\"\314!\203l=04\203e\315=03E\fB=0D\247\203e=0D\316V\203e=0D\f\233\211:\2= 03d\211\306\241\210\210\315=03\"\202\233\317=06=06=06#=069\203\233=06\320N\= 203\233=06\321N\204\233\322=07\321\323#\210\324\325\326 \211\320N\327#\"\21= 0\262\207" [debug-on-next-call prefix-arg current-prefix-arg disabled-comma= nd-function command-history history-length nil disabled run-hooks indirect-= function autoload autoload-do-load arrayp execute-kbd-macro 0 call-interact= ively byte-obsolete-info command-execute-obsolete-warned put t message "%s"= macroexp--obsolete-warning "command"] 13 1990350] org-clock-display nil ni= l nil) (with-no-warnings (funcall ad--addoit-function cmd record-flag keys speci= al)) (setq ad-return-value (with-no-warnings (funcall ad--addoit-function cmd = record-flag keys special))) (let (ad-return-value) (setq ad-return-value (with-no-warnings (funcall a= d--addoit-function cmd record-flag keys special))) (when (fancy-narrow-acti= ve-p) (fancy-narrow--motion-function)) ad-return-value) ad-Advice-command-execute(#[1025 "\306\211?\205\f \211\306=049\203!=04\30= 7N\203!=0B\203!\310\303!\202\235=04\311!\262\211\211\242\312=3D\262\203<\31= 3=06=07\"\211\262\204\"\314!\203l=04\203e\315=03E\fB=0D\247\203e=0D\316V\20= 3e=0D\f\233\211:\203d\211\306\241\210\210\315=03\"\202\233\317=06=06=06#=06= 9\203\233=06\320N\203\233=06\321N\204\233\322=07\321\323#\210\324\325\326 \= 211\320N\327#\"\210\262\207" [debug-on-next-call prefix-arg current-prefix-= arg disabled-command-function command-history history-length nil disabled r= un-hooks indirect-function autoload autoload-do-load arrayp execute-kbd-mac= ro 0 call-interactively byte-obsolete-info command-execute-obsolete-warned = put t message "%s" macroexp--obsolete-warning "command"] 13 1990350] org-cl= ock-display) apply(ad-Advice-command-execute #[1025 "\306\211?\205\f \211\306=049\203!= =04\307N\203!=0B\203!\310\303!\202\235=04\311!\262\211\211\242\312=3D\262\2= 03<\313=06=07\"\211\262\204\"\314!\203l=04\203e\315=03E\fB=0D\247\203e=0D\3= 16V\203e=0D\f\233\211:\203d\211\306\241\210\210\315=03\"\202\233\317=06=06= =06#=069\203\233=06\320N\203\233=06\321N\204\233\322=07\321\323#\210\324\32= 5\326 \211\320N\327#\"\210\262\207" [debug-on-next-call prefix-arg current-= prefix-arg disabled-command-function command-history history-length nil dis= abled run-hooks indirect-function autoload autoload-do-load arrayp execute-= kbd-macro 0 call-interactively byte-obsolete-info command-execute-obsolete-= warned put t message "%s" macroexp--obsolete-warning "command"] 13 1990350]= org-clock-display) command-execute(org-clock-display) --8<---------------cut here---------------end--------------->8--- while the default version `thisyear' did work, before applying the patch. BTW, `untilnow' is not proposed when TAB'ing on `C-u C-u C-c C-x C-d'. Best regards, Seb --=20 Sebastien Vauban