[O] [PATCH 1/4] org: move `org-duration-string-to-minutes' to a better place
--- lisp/org.el | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 74d1c4c..f6c513e 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -18303,6 +18303,26 @@ If no number is found, the return value is 0." (string-to-number (match-string 1 s))) (t 0))) +(defun org-duration-string-to-minutes (s &optional output-to-string) + "Convert a duration string S to minutes. + +A bare number is interpreted as minutes, modifiers can be set by +customizing `org-effort-durations' (which see). + +Entries containing a colon are interpreted as H:MM by +`org-hh:mm-string-to-minutes'." + (let ((result 0) + (re (concat "\\([0-9.]+\\) *\\(" + (regexp-opt (mapcar 'car org-effort-durations)) + "\\)"))) +(while (string-match re s) + (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) + (string-to-number (match-string 1 s + (setq s (replace-match "" nil t s))) +(setq result (floor result)) +(incf result (org-hh:mm-string-to-minutes s)) +(if output-to-string (number-to-string result) result))) + (defcustom org-image-actual-width t "Should we use the actual width of images when inlining them? @@ -18361,26 +18381,6 @@ The value is a list, with zero or more of the symbols `effort', `appt', :package-version '(Org . "8.3") :group 'org-agenda) -(defun org-duration-string-to-minutes (s &optional output-to-string) - "Convert a duration string S to minutes. - -A bare number is interpreted as minutes, modifiers can be set by -customizing `org-effort-durations' (which see). - -Entries containing a colon are interpreted as H:MM by -`org-hh:mm-string-to-minutes'." - (let ((result 0) - (re (concat "\\([0-9.]+\\) *\\(" - (regexp-opt (mapcar 'car org-effort-durations)) - "\\)"))) -(while (string-match re s) - (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) - (string-to-number (match-string 1 s - (setq s (replace-match "" nil t s))) -(setq result (floor result)) -(incf result (org-hh:mm-string-to-minutes s)) -(if output-to-string (number-to-string result) result))) - Files (defun org-save-all-org-buffers () -- 2.6.4
[O] [PATCH 3/4] simplify and document `org-effort-durations'-related code
* lisp/org.el (org-time-clocksum-use-effort-durations): Make obsolete. (org-effort-durations-default): (org-effort-durations-8h): (org-effort-durations-6h): New constants. (org-effort-durations): Redefine and document. (org-minutes-to-clocksum-string): Simplify. * lisp/org-agenda.el: (org-agenda-show-clocking-issues): (org-agenda-format-item): Use new constants. * lisp/org.el: * lisp/org-clock.el: * lisp/org-colview.el: Document everything related to (org-effort-durations) a bit better. --- lisp/org-agenda.el | 4 +- lisp/org-clock.el | 5 ++- lisp/org-colview.el | 1 + lisp/org.el | 118 4 files changed, 79 insertions(+), 49 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 99ccedd..d8f9a96 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5922,7 +5922,7 @@ please use `org-class' instead." "Add overlays, showing issues with clocking. See also the user option `org-agenda-clock-consistency-checks'." (interactive) - (let* ((org-time-clocksum-use-effort-durations nil) + (let* ((org-effort-durations org-effort-durations-default) (pl org-agenda-clock-consistency-checks) (re (concat "^[ \t]*" org-clock-string @@ -6550,7 +6550,7 @@ Any match of REMOVE-RE will be removed from TXT." (if s2 (setq s2 (org-get-time-of-day s2 'string t))) ;; Try to set s2 if s1 and `org-agenda-default-appointment-duration' are set - (let (org-time-clocksum-use-effort-durations) + (let (org-effort-durations org-effort-durations-default) (when (and s1 (not s2) org-agenda-default-appointment-duration) (setq s2 (org-minutes-to-clocksum-string diff --git a/lisp/org-clock.el b/lisp/org-clock.el index b7a70dc..df993b0 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -724,8 +724,8 @@ previous clocking intervals." VALUE can be a number of minutes, or a string with format hh:mm or mm. When the string starts with a + or a - sign, the current value of the effort property will be changed by that amount. If the effort value is expressed -as an `org-effort-durations' (e.g. \"3h\"), the modified value will be -converted to a hh:mm duration. +using modifiers (e.g. \"3h\", see `org-clocksum-string-to-minutes'), the +modified value will be converted to a hh:mm duration. This command will update the \"Effort\" property of the currently clocked item, and the value displayed in the mode line." @@ -2468,6 +2468,7 @@ from the dynamic block definition." (maxlevel (or (plist-get params :maxlevel) 3)) (emph (plist-get params :emphasize)) (level-p (plist-get params :level)) +;; FIXME: setting this will break `org-clock-time%' (org-time-clocksum-use-effort-durations (plist-get params :effort-durations)) (timestamp (plist-get params :timestamp)) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index a3ce406..f6ad85e 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1107,6 +1107,7 @@ display, or in the #+COLUMNS line of the current buffer." ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) (if (equal s "[X]") 1. 0.01)) ((memq fmt '(estimate)) (org-string-to-estimate s)) + ;; FIXME: this is ugly ((string-match (concat "\\([0-9.]+\\) *\\(" (regexp-opt (mapcar 'car org-effort-durations)) "\\)") s) diff --git a/lisp/org.el b/lisp/org.el index 24f81e4..e3f6bb6 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -3145,8 +3145,13 @@ commands, if custom time display is turned on at the time of export." (defcustom org-time-clocksum-format '(:days "%dd " :hours "%d" :require-hours t :minutes ":%02d" :require-minutes t) - "The format string used when creating CLOCKSUM lines. -This is also used when Org mode generates a time duration. + "The format string used when creating CLOCKSUM lines and time +durations (see `org-minutes-to-clocksum-string'). + +Note, that setting this to something that +`org-clocksum-string-to-minutes' can not parse and invert will +confuse time computations that go through text representation +phase (e.g. time percent computations in clock reports/tables). The value can be a single format string containing two %-sequences, which will be filled with the number of hours and @@ -3156,8 +3161,9 @@ Alternatively, the value can be a plist associating any of the keys :years, :months, :weeks, :days, :hours or :minutes with format strings. The time duration is formatted using only the time components that are needed and concatenating the results. -If a time unit in absent, it falls back to the next smallest -unit. +If a time unit (modifier) in absent, it falls back to the next +smallest modifier. The length of each modifier is defined by +`org-effort-durations'. The keys :require-years, :require-months, :req
[O] [PATCH 4/4] org-clock: make clock table respect `org-effort-durations'
* lisp/org-clock.el (org-clock-time%): Rewrite using (org-clocksum-string-to-minutes), document pitfalls. (org-clock-time%-with-effort): New function. (org-clocktable-write-default): Fix effort-duration parameter. * doc/org.texi (The clock table): Update documentation. --- doc/org.texi | 6 ++ lisp/org-clock.el | 49 - 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 92ec29a..c526057 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -6687,6 +6687,7 @@ but you can specify your own function using the @code{:formatter} parameter. @r{As a special case, @samp{:formula %} adds a column with % time.} @r{If you do not specify a formula here, any existing formula} @r{below the clock table will survive updates and be evaluated.} +:effort-durations @r{Name of a symbol to use as @code{org-effort-durations} when preparing the table.} :formatter @r{A function to format clock data and insert it into the buffer.} @end example To get a clock summary of the current level 1 tree, for the current @@ -6714,6 +6715,11 @@ A summary of the current subtree with % times would be #+BEGIN: clocktable :scope subtree :link t :formula % #+END: clocktable @end example +The same thing measured in 8-hour work days would be +@example +#+BEGIN: clocktable :scope subtree :link t :formula % :effort-durations org-effort-durations-8h +#+END: clocktable +@end example A horizontally compact representation of everything clocked during last week would be @example diff --git a/lisp/org-clock.el b/lisp/org-clock.el index df993b0..53292ae 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2468,9 +2468,10 @@ from the dynamic block definition." (maxlevel (or (plist-get params :maxlevel) 3)) (emph (plist-get params :emphasize)) (level-p (plist-get params :level)) -;; FIXME: setting this will break `org-clock-time%' -(org-time-clocksum-use-effort-durations - (plist-get params :effort-durations)) +(effort-durations (plist-get params :effort-durations)) +(org-effort-durations (if (null effort-durations) + org-effort-durations + (eval effort-durations))) (timestamp (plist-get params :timestamp)) (properties (plist-get params :properties)) (ntcol (max 1 (or (plist-get params :tcolumns) 100))) @@ -2641,8 +2642,11 @@ from the dynamic block definition." (if timestamp 1 0))) (insert (format - "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f" + "\n#+TBLFM: $%d='(%s @%d$%d $%d..$%d);%%.1f" pcol; the column where the % numbers should go + (if (null effort-durations) + "org-clock-time%" + (format "org-clock-time%%-with-effort %s" (symbol-name effort-durations))) (if (and narrow (not narrow-cut-p)) 3 2) ; row of the total time tcol; column of the total time tcol (1- pcol) ; range of columns where times can be found @@ -2858,25 +2862,28 @@ TIME: The sum of all time spend in this tree, in minutes. This time "Compute a time fraction in percent. TOTAL s a time string like 10:21 specifying the total times. STRINGS is a list of strings that should be checked for a time. +Strings are parsed using `org-clocksum-string-to-minutes'. The first string that does have a time will be used. -This function is made for clock tables." - (let ((re "\\([0-9]+\\):\\([0-9]+\\)") - tot s) -(save-match-data + +This function is made for clock tables. + +This function can be broken by setting `org-time-clocksum-format' +to something that `org-clocksum-string-to-minutes' can not +parse." + (save-match-data +(let ((tot (org-clocksum-string-to-minutes total)) + s cur) (catch 'exit - (if (not (string-match re total)) - (throw 'exit 0.) - (setq tot (+ (string-to-number (match-string 2 total)) - (* 60 (string-to-number (match-string 1 total) - (if (= tot 0.) (throw 'exit 0.))) - (while (setq s (pop strings)) - (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) - (throw 'exit -(/ (* 100.0 (+ (string-to-number (match-string 2 s)) - (* 60 (string-to-number - (match-string 1 s) - tot - 0 + (if (= tot 0.) (throw 'exit 0.)) + (dolist (s strings) + (setq cur (org-clocksum-string-to-minutes s)) + (when cur (throw 'exit (/ (* 100.0 cur) tot + nil + +(defun org-clock-time%-with-effort (effort-durations total &rest strings) + "A version of `org-clock-time%' that temporary sets `org-effort-durations'." +
[O] [PATCH 2/4] rename `org-duration-string-to-minutes' to `org-clocksum-string-to-minutes' everywhere
* lisp/org-agenda.el: * lisp/org-clock.el: * lisp/org-colview.el: * lisp/org.el: * contrib/lisp/org-depend.el: * contrib/lisp/ox-taskjuggler.el: Rename (org-duration-string-to-minutes) to (org-clocksum-string-to-minutes). --- contrib/lisp/org-depend.el | 2 +- contrib/lisp/ox-taskjuggler.el | 2 +- lisp/org-agenda.el | 2 +- lisp/org-clock.el | 10 +- lisp/org-colview.el| 2 +- lisp/org.el| 14 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/contrib/lisp/org-depend.el b/contrib/lisp/org-depend.el index 1cd4130..7b263bc 100644 --- a/contrib/lisp/org-depend.el +++ b/contrib/lisp/org-depend.el @@ -270,7 +270,7 @@ This does two different kinds of triggers: (effort (when (or effort-up effort-down) (let ((effort (get-text-property (point) 'org-effort))) (when effort - (org-duration-string-to-minutes effort)) + (org-clocksum-string-to-minutes effort)) (push (list (point) todo-kwd priority tags effort) items)) (unless (org-goto-sibling) diff --git a/contrib/lisp/ox-taskjuggler.el b/contrib/lisp/ox-taskjuggler.el index 2bd47e6..b425b1b 100644 --- a/contrib/lisp/ox-taskjuggler.el +++ b/contrib/lisp/ox-taskjuggler.el @@ -861,7 +861,7 @@ a unique id will be associated to it." (and complete (format " complete %s\n" complete)) (and effort (format " effort %s\n" - (let* ((minutes (org-duration-string-to-minutes effort)) + (let* ((minutes (org-clocksum-string-to-minutes effort)) (hours (/ minutes 60.0))) (format "%.1fh" hours (and priority (format " priority %s\n" priority)) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index d91b64d..99ccedd 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7661,7 +7661,7 @@ E looks like \"+<2:25\"." ((equal op ??) op) (t '=))) (list 'org-agenda-compare-effort (list 'quote op) - (org-duration-string-to-minutes e + (org-clocksum-string-to-minutes e (defun org-agenda-compare-effort (op value) "Compare the effort of the current line with VALUE, using OP. diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 823a386..b7a70dc 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -663,7 +663,7 @@ If not, show simply the clocked time like 01:50." (let ((clocked-time (org-clock-get-clocked-time))) (if org-clock-effort (let* ((effort-in-minutes - (org-duration-string-to-minutes org-clock-effort)) + (org-clocksum-string-to-minutes org-clock-effort)) (work-done-str (org-propertize (org-minutes-to-clocksum-string clocked-time) @@ -744,10 +744,10 @@ clocked item, and the value displayed in the mode line." ;; A string. See if it is a delta (setq sign (string-to-char value)) (if (member sign '(?- ?+)) - (setq current (org-duration-string-to-minutes current) + (setq current (org-clocksum-string-to-minutes current) value (substring value 1)) (setq current 0)) - (setq value (org-duration-string-to-minutes value)) + (setq value (org-clocksum-string-to-minutes value)) (if (equal ?- sign) (setq value (- current value)) (if (equal ?+ sign) (setq value (+ current value) @@ -765,7 +765,7 @@ clocked item, and the value displayed in the mode line." "Show notification if we spent more time than we estimated before. Notification is shown only once." (when (org-clocking-p) -(let ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort)) +(let ((effort-in-minutes (org-clocksum-string-to-minutes org-clock-effort)) (clocked-time (org-clock-get-clocked-time))) (if (setq org-clock-task-overrun (if (or (null effort-in-minutes) (zerop effort-in-minutes)) @@ -1187,7 +1187,7 @@ make this the default behavior.)" (setq org-clock-notification-was-shown nil) (org-refresh-properties org-effort-property '((effort . identity) -(effort-minutes . org-duration-string-to-minutes))) +(effort-minutes . org-clocksum-string-to-minutes))) (catch 'abort (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index e157031..a3ce406 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1110,7 +1110,7 @@ display, or in the #+COLUMNS line of the current buffer." ((string-
[O] [PATCH v3 part3 0/4] fixing org-clock-time%
This is a org-clock-time% piece of "[PATCH v2 0/9] mail, clock and calc changes" updated with Aaron Ecay's suggestions. The thing here is that I pretty much rewrote those changes because they didn't work well with `org-effort-durations' (which was the case even before I started, but it became apparent after I fixed `org-clock-time%' to actually work). So, I ended up rewriting `org-effort-durations'-related code, which then allowed me to fix clock reports properly. A piece of documentation in org.texi shows the new prowess. This is the last patch series for now, I'm unhappy with ob-calc piece of "[PATCH v2 0/9] mail, clock and calc changes", I'll send it when its better. Cheers, Jan Jan Malakhovski (4): org: move `org-duration-string-to-minutes' to a better place rename `org-duration-string-to-minutes' to `org-clocksum-string-to-minutes' everywhere simplify and document `org-effort-durations'-related code org-clock: make clock table respect `org-effort-durations' contrib/lisp/org-depend.el | 2 +- contrib/lisp/ox-taskjuggler.el | 2 +- doc/org.texi | 6 ++ lisp/org-agenda.el | 6 +- lisp/org-clock.el | 62 --- lisp/org-colview.el| 3 +- lisp/org.el| 166 - 7 files changed, 147 insertions(+), 100 deletions(-) -- 2.6.4
[O] [PATCH v3 part2 0/2] date-timestamp* calculations
This is a date-timestamp* piece of "[PATCH v2 0/9] mail, clock and calc changes" updated with Aaron Ecay's suggestions. Jan Malakhovski (2): factor out date-timestamp* calculations to org-store-link-props org-notmuch: add date support to org-notmuch-store-link contrib/lisp/org-mew.el | 11 +-- contrib/lisp/org-notmuch.el | 7 --- contrib/lisp/org-vm.el | 11 +-- contrib/lisp/org-wl.el | 10 +- doc/org.texi| 4 ++-- lisp/org-gnus.el| 15 +-- lisp/org-mhe.el | 10 +- lisp/org-rmail.el | 11 +-- lisp/org.el | 12 ++-- 9 files changed, 22 insertions(+), 69 deletions(-) -- 2.6.4
[O] [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link
* contrib/lisp/org-notmuch.el (org-notmuch-store-link): Add date support. * doc/org.texi: Fix `org-capture-templates' documentation. --- contrib/lisp/org-notmuch.el | 7 --- doc/org.texi| 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/lisp/org-notmuch.el b/contrib/lisp/org-notmuch.el index 712ec5a..265742e 100644 --- a/contrib/lisp/org-notmuch.el +++ b/contrib/lisp/org-notmuch.el @@ -71,15 +71,16 @@ Should accept a notmuch search string as the sole argument." (defun org-notmuch-store-link () "Store a link to a notmuch search or message." (when (eq major-mode 'notmuch-show-mode) -(let* ((message-id (notmuch-show-get-prop :id)) +(let* ((message-id (notmuch-show-get-message-id t)) (subject (notmuch-show-get-subject)) (to (notmuch-show-get-to)) (from (notmuch-show-get-from)) + (date (org-trim (notmuch-show-get-date))) desc link) - (org-store-link-props :type "notmuch" :from from :to to + (org-store-link-props :type "notmuch" :from from :to to :date date :subject subject :message-id message-id) (setq desc (org-email-link-description)) - (setq link (concat "notmuch:" "id:" message-id)) + (setq link (concat "notmuch:id:" message-id)) (org-add-link-props :link link :description desc) link))) diff --git a/doc/org.texi b/doc/org.texi index c3c5b4d..92ec29a 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -7304,7 +7304,7 @@ Link type| Available keywords bbdb | %:name %:company irc | %:server %:port %:nick vm, vm-imap, wl, mh, mew, rmail, | %:type %:subject %:message-id -gnus | %:from %:fromname %:fromaddress +gnus, notmuch| %:from %:fromname %:fromaddress | %:to %:toname %:toaddress | %:date @r{(message date header field)} | %:date-timestamp @r{(date as active timestamp)} -- 2.6.4
[O] [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props
* lisp/org.el (org-store-link-props): Rewrite function to get date-timestamp* calculations. * lisp/org-gnus.el: * lisp/org-mhe.el: * lisp/org-rmail.el: * contrib/lisp/org-mew.el: * contrib/lisp/org-vm.el: * contrib/lisp/org-wl.el: Remove date-timestamp* copy-paste. * doc/org.texi: Fix `org-capture-templates' documentation. --- contrib/lisp/org-mew.el | 11 +-- contrib/lisp/org-vm.el | 11 +-- contrib/lisp/org-wl.el | 10 +- doc/org.texi| 4 ++-- lisp/org-gnus.el| 15 +-- lisp/org-mhe.el | 10 +- lisp/org-rmail.el | 11 +-- lisp/org.el | 12 ++-- 8 files changed, 18 insertions(+), 66 deletions(-) diff --git a/contrib/lisp/org-mew.el b/contrib/lisp/org-mew.el index eb0afc0..35fdd8b 100644 --- a/contrib/lisp/org-mew.el +++ b/contrib/lisp/org-mew.el @@ -167,19 +167,10 @@ with \"t\" key." (from (mew-header-get-value "From:")) (to (mew-header-get-value "To:")) (date (mew-header-get-value "Date:")) - (date-ts (and date (format-time-string - (org-time-stamp-format t) - (date-to-time date - (date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date (subject (mew-header-get-value "Subject:")) desc link) - (org-store-link-props :type "mew" :from from :to to + (org-store-link-props :type "mew" :from from :to to :date date :subject subject :message-id message-id) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) (setq message-id (org-remove-angle-brackets message-id)) (setq desc (org-email-link-description)) (setq link (concat "mew:" folder-name "#" message-id)) diff --git a/contrib/lisp/org-vm.el b/contrib/lisp/org-vm.el index 5d30f64..da242cb 100644 --- a/contrib/lisp/org-vm.el +++ b/contrib/lisp/org-vm.el @@ -77,12 +77,6 @@ (message-id (vm-su-message-id message)) (link-type (if (vm-imap-folder-p) "vm-imap" "vm")) (date (vm-get-header-contents message "Date")) -(date-ts (and date (format-time-string -(org-time-stamp-format t) -(date-to-time date -(date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date folder desc link) (if (vm-imap-folder-p) (let ((spec (vm-imap-find-spec-for-buffer (current-buffer @@ -95,10 +89,7 @@ (setq folder (replace-match "" t t folder) (setq message-id (org-remove-angle-brackets message-id)) (org-store-link-props :type link-type :from from :to to :subject subject - :message-id message-id) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) + :message-id message-id :date date) (setq desc (org-email-link-description)) (setq link (concat (concat link-type ":") folder "#" message-id)) (org-add-link-props :link link :description desc) diff --git a/contrib/lisp/org-wl.el b/contrib/lisp/org-wl.el index 632c9e3..2cc333c 100644 --- a/contrib/lisp/org-wl.el +++ b/contrib/lisp/org-wl.el @@ -198,12 +198,6 @@ ENTITY is a message entity." (xref (org-wl-message-field 'xref wl-message-entity)) (subject (org-wl-message-field 'subject wl-message-entity)) (date (org-wl-message-field 'date wl-message-entity)) -(date-ts (and date (format-time-string -(org-time-stamp-format t) -(date-to-time date -(date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date desc link) ;; remove text properties of subject string to avoid possible bug @@ -243,9 +237,7 @@ ENTITY is a message entity." (setq desc (org-email-link-description)) (setq link (concat "wl:" folder-name "#" message-id-no-brackets)) (org-add-link-props :link link :description desc))) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) + (org-add-link-props :date date) (or link xref))) (defun org-wl-open-nntp (path) diff --git a/d
[O] [PATCH v3 part1 0/3] Fixes
Hello. This is a fixes-only piece of "[PATCH v2 0/9] mail, clock and calc changes" updated with Aaron Ecay's suggestions. Other pieces will follow shortly. I'm pretty sure FSF processed my copyright assignment. Cheers, Jan Jan Malakhovski (3): org-clock: fix a typo ob-calc: don't leave garbage on the stack org-contacts: fix org-contacts-matcher for BIRTHDAYs contrib/lisp/org-contacts.el | 14 -- lisp/ob-calc.el | 4 +++- lisp/org-clock.el| 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) -- 2.6.4
[O] [PATCH 3/3] org-contacts: fix org-contacts-matcher for BIRTHDAYs
* contrib/lisp/org-contacts.el (org-contacts-matcher): Fix expression to work for BIRTHDAY-only contacts. --- contrib/lisp/org-contacts.el | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el index ebc7bcd..96e163b 100644 --- a/contrib/lisp/org-contacts.el +++ b/contrib/lisp/org-contacts.el @@ -159,12 +159,14 @@ The following replacements are available: :group 'org-contacts) (defcustom org-contacts-matcher - (mapconcat 'identity (list org-contacts-email-property -org-contacts-alias-property -org-contacts-tel-property -org-contacts-address-property -org-contacts-birthday-property) -"<>\"\"|") + (mapconcat 'identity +(mapcar (lambda (x) (concat x "<>\"\"")) +(list org-contacts-email-property + org-contacts-alias-property + org-contacts-tel-property + org-contacts-address-property + org-contacts-birthday-property)) + "|") "Matching rule for finding heading that are contacts. This can be a tag name, or a property check." :type 'string -- 2.6.4
[O] [PATCH 1/3] org-clock: fix a typo
TINYCHANGE --- lisp/org-clock.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index eb7d9c3..823a386 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2762,7 +2762,7 @@ following structure: \(LEVEL HEADLINE TIMESTAMP TIME) LEVEL: The level of the headline, as an integer. This will be - the reduced leve, so 1,2,3,... even if only odd levels + the reduced level, so 1,2,3,... even if only odd levels are being used. HEADLINE: The text of the headline. Depending on PARAMS, this may already be formatted like a link. -- 2.6.4
[O] [PATCH 2/3] ob-calc: don't leave garbage on the stack
* lisp/ob-calc.el (org-babel-calc-eval-string): Clean up the stack after expression evaluation. --- lisp/ob-calc.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el index a8c50da..99d0a09 100644 --- a/lisp/ob-calc.el +++ b/lisp/ob-calc.el @@ -89,7 +89,9 @@ (split-string (org-babel-expand-body:calc body params) "[\n\r]" (save-excursion (with-current-buffer (get-buffer "*Calculator*") - (calc-eval (calc-top 1) + (prog1 +(calc-eval (calc-top 1)) +(calc-pop 1) (defun org-babel-calc-maybe-resolve-var (el) (if (consp el) -- 2.6.4
Re: [O] [PATCH 9/9] ob-calc: don't leave garbage on the stack
Aaron Ecay writes: > Ok. Then: > 1. The indentation is wrong, because (calc-pop 1) is the second argument >to calc-eval. > 2. The prog1 form is not needed, because it only wraps a single form >(the calc-eval call). > > This looks wrong to me, so please double-check. Ah, I misunderstood. You are correct about parens indeed. Fixed, ok. Why it wored as expected I have no idea.
Re: [O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
Aaron Ecay writes: > Checking the source, date-to-time can raise an error (invalid date). > format-time-string is a C function, so it’s less easy for me to > understand. But it looks like if it raises any errors, these are bugs > that we want to know about and not suppress. > > The ignore-error call was introduced to org-gnus in commit 0dfde2da. > Based on the commit message, it looks like the problem being solved was > invalid dates getting passed to date-to-time. > > So I think the ignore-error can just wrap the date-to-time call. Thanks. Ok.
Re: [O] [PATCH v2 0/9] mail, clock and calc changes
Hi. Aaron Ecay writes: > Thanks for the patches! They look good to me. I sent a few minor > comments about code style. I didn’t review the 8th patch (ob-calc: add > more API, documentation and examples so that it can be used in tables) > because I didn’t feel familiar enough with the calc API to be useful. Thanks for the comments! > Do you want somebody to apply the tinychange patches already? Or do you > want to wait until your assignment is processed and apply them yourself? > (IMO patch 4 could also be a TINYCHANGE, since it is only code movement > with no actual changes). I'm fine either way, including patch 4. If somebody merges those, I'll just resend the rest when I fix the pieces you pointed to. Cheers, Jan
Re: [O] [PATCH 9/9] ob-calc: don't leave garbage on the stack
Aaron Ecay writes: > Are you missing a close paren at the end of the above line? It evaluates and works ok, so I think it's ok. > Also, shouldn’t calc-eval take a string as an argument, not a lisp > form? (I’m asking based on the docstring, I don’t know the calc API at > all). 1) It was like this before. 2) It works. 3) calc-eval calls calc-do-calc-eval on this argument and the code there does a dispatch on expression, so I think it's safe to assume it's not actually a string (calc is a mess, yep).
Re: [O] [PATCH 5/9] rename `org-duration-string-to-minutes' to `org-clocksum-string-to-minutes' everywhere
Aaron Ecay writes: > You can use ‘define-obsolete-function-alias’. Ok.
Re: [O] [PATCH 3/9] org-clock: fix `org-clock-time%'
Aaron Ecay writes: > This could be converted to dolist while you’re here (I realize you > didn’t touch this line). Ok. >> - (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) >> - (throw 'exit >> - (/ (* 100.0 (+ (string-to-number (match-string 2 s)) >> -(* 60 (string-to-number >> - (match-string 1 s) >> -tot >> -0 >> + (setq cur (org-clocksum-string-to-minutes s)) >> + (if (not (equal cur nil)) (throw 'exit (/ (* 100.0 cur) tot Ok.
Re: [O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
Aaron Ecay writes: > Can you introduce a let binding so that (date-to-time x) is only called > once? Ok. > Also, what is ignore-errors protecting? The call to date-to-time, or > format-time-string? I think the scope of ignore-errors should be as > narrow as it can be. I have no idea. I moved these lines from org-gnus, equivalent lines in org-*other-mail-reader*s don't use ignore-errors at all. I don't use gnus so went for the safest change.
[O] [PATCH 9/9] ob-calc: don't leave garbage on the stack
* lisp/ob-calc.el (org-babel-calc-eval-string): Clean up the stack after expression evaluation. --- lisp/ob-calc.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el index e8b43e7..2656f27 100644 --- a/lisp/ob-calc.el +++ b/lisp/ob-calc.el @@ -196,7 +196,9 @@ See `org-babel-calc-eval' for more info." (mapc #'org-babel-calc-eval-line (split-string text "[\n\r]")) (save-excursion (with-current-buffer (get-buffer "*Calculator*") - (calc-eval (calc-top 1) + (prog1 +(calc-eval (calc-top 1) +(calc-pop 1)) (defun org-babel-calc-eval-line (line) (let ((line (org-babel-trim line))) -- 2.6.2
[O] [PATCH 8/9] ob-calc: add more API, documentation and examples so that it can be used in tables
* lisp/ob-calc.el (org-babel-calc-eval): (org-babel-calc-set-env): (org-babel-calc-reset-env): (org-babel-calc-store-env): (org-babel-calc-eval-string): (org-babel-calc-eval-line): New funcion. (org-babel-execute:calc): Rewrite to use new functions. This also makes ob-calc useful for computing complicated stuff in org-tables. See `org-babel-calc-eval` docstring for more info. --- lisp/ob-calc.el | 232 1 file changed, 183 insertions(+), 49 deletions(-) diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el index a8c50da..e8b43e7 100644 --- a/lisp/ob-calc.el +++ b/lisp/ob-calc.el @@ -1,4 +1,4 @@ -;;; ob-calc.el --- Babel Functions for Calc -*- lexical-binding: t; -*- +;;; ob-calc.el --- Babel Functions for Calc ;; Copyright (C) 2010-2015 Free Software Foundation, Inc. @@ -23,7 +23,8 @@ ;;; Commentary: -;; Org-Babel support for evaluating calc code +;; Org-Babel and Org-Table support for evaluating calc code. +;; See `org-babel-calc-eval' for documentation. ;;; Code: (require 'ob) @@ -42,67 +43,200 @@ (defun org-babel-expand-body:calc (body _params) "Expand BODY according to PARAMS, return the expanded body." body) -(defvar org--var-syms) ; Dynamically scoped from org-babel-execute:calc - (defun org-babel-execute:calc (body params) "Execute a block of calc code with Babel." + (org-babel-calc-eval (org-babel-expand-body:calc body params) + (org-babel--get-vars params))) + +(defvar org--ob-calc-env-symbol nil) ; For org-babel-calc-eval +(defvar org--ob-calc-var-names nil) + +(defun org-babel-calc-eval (text &optional environment env-symbol setup env-setup) + "Evaluate TEXT as set of calc expressions (one per line) and return the top of the stack. + +Optional argument ENVIRONMENT is a user-defined variables +environment which is an alist of (SYMBOL . VALUE). + +Optional argument ENV-SYMBOL is a symbol of a user-defined +variables environment which is an alist of (SYMBOL . VALUE). + +Setting your environment using either of ENVIRONMENT or +ENV-SYMBOL has the same effect. The difference is that this +function caches the value of ENV-SYMBOL internally between +succesive evaluations with ENV-SYMBOL arguments of equal symbol +names and reevaluates the value of ENV-SYMBOL only when the +symbol name of ENV-SYMBOL changes. + +Additionally, setting ENV-SYMBOL to nil will forget any +internal environment before applying ENVIRONMENT, i.e. with +ENV-SYMBOL set to nil this function is pure. + +You can also use `org-babel-calc-set-env', +`org-babel-calc-reset-env' and `org-babel-calc-store-env' to set, +reset and update the internal environment between evaluations. + +Optional argument SETUP allows additional calc setup on every +evaluation. + +Optional argument ENV-SETUP allows additional calc setup on every +ENV-SYMBOL change. + +This function is useful if you want to evaluate complicated +formulas in a table, e.g. after evaluating + + (setq an-env '((foo . \"2 day\") + (bar . \"6 hr\"))) + +you can use this in the following table + + | Expr | Result | + |---+--| + | foo + bar | 2 day + 6 hr | + | foo - bar | 2 day - 6 hr | + |---+--| + #+TBLFM: $2='(org-babel-calc-eval $1 an-env) + +which would become slow to recompute with a lot of rows, but then +you can change the TBLFM line to + + #+TBLFM: $2='(org-babel-calc-eval $1 nil 'an-env) + +and it would become fast again. + +SETUP argument can be used like this: + + | Expr | Result | + |---+--| + | foo + bar | 2.25 day | + | foo - bar | 1.75 day | + |---+--| + #+TBLFM: $2='(org-babel-calc-eval $1 nil 'an-env nil (lambda () (calc-units-simplify-mode t))) + +In case that is not fast or complicated enough, you can combine +this with `org-babel-calc-store-env' to produce some clever stuff +like, e.g. computing environment on the fly (an-env variable is +not actually used here, it is being generated just in case you +want to use it elsewhere): + + (setq an-env nil) + (defun compute-and-remember (name expr) +(let* ((v (org-babel-calc-eval expr nil 'an-env nil (lambda () (calc-units-simplify-mode t + (c `(,(intern name) . ,v))) +(org-babel-calc-store-env (list c)) +(push c an-env) +v)) + +and then + + | Name | Expr | Value| + |--++--| + | foo | 2 day | 2 day| + | bar | foo + 6 hr | 2.25 day | + |--++--| + #+TBLFM: $3='(compute-and-remember $1 $2) + +Note that you can set ENV-SYMBOL to 'nil to get ENV-SETUP +without. + +The subsequent results might become somewhat surprising in case +ENVIRONMENT overrides variables set with ENV-SYMBOL." + (org-babel-calc-init) + (cond +((equal env-symbol nil) (org-babel-calc-reset-env)) +((not (equal (symbol-name env-symbol) org--ob-calc-env-symbol)) + (org-babel-calc-set-env env-symbol)
[O] [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props
* lisp/org.el (org-store-link-props): Rewrite function to get date-timestamp* calculations. * lisp/org-gnus.el: * lisp/org-mhe.el: * lisp/org-rmail.el: * contrib/lisp/org-mew.el: * contrib/lisp/org-vm.el: * contrib/lisp/org-wl.el: Remove date-timestamp* copy-paste. * doc/org.texi: Fix `org-capture-templates' documentation. --- contrib/lisp/org-mew.el | 11 +-- contrib/lisp/org-vm.el | 11 +-- contrib/lisp/org-wl.el | 10 +- doc/org.texi| 4 ++-- lisp/org-gnus.el| 15 +-- lisp/org-mhe.el | 10 +- lisp/org-rmail.el | 11 +-- lisp/org.el | 15 +-- 8 files changed, 21 insertions(+), 66 deletions(-) diff --git a/contrib/lisp/org-mew.el b/contrib/lisp/org-mew.el index eb0afc0..35fdd8b 100644 --- a/contrib/lisp/org-mew.el +++ b/contrib/lisp/org-mew.el @@ -167,19 +167,10 @@ with \"t\" key." (from (mew-header-get-value "From:")) (to (mew-header-get-value "To:")) (date (mew-header-get-value "Date:")) - (date-ts (and date (format-time-string - (org-time-stamp-format t) - (date-to-time date - (date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date (subject (mew-header-get-value "Subject:")) desc link) - (org-store-link-props :type "mew" :from from :to to + (org-store-link-props :type "mew" :from from :to to :date date :subject subject :message-id message-id) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) (setq message-id (org-remove-angle-brackets message-id)) (setq desc (org-email-link-description)) (setq link (concat "mew:" folder-name "#" message-id)) diff --git a/contrib/lisp/org-vm.el b/contrib/lisp/org-vm.el index 5d30f64..da242cb 100644 --- a/contrib/lisp/org-vm.el +++ b/contrib/lisp/org-vm.el @@ -77,12 +77,6 @@ (message-id (vm-su-message-id message)) (link-type (if (vm-imap-folder-p) "vm-imap" "vm")) (date (vm-get-header-contents message "Date")) -(date-ts (and date (format-time-string -(org-time-stamp-format t) -(date-to-time date -(date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date folder desc link) (if (vm-imap-folder-p) (let ((spec (vm-imap-find-spec-for-buffer (current-buffer @@ -95,10 +89,7 @@ (setq folder (replace-match "" t t folder) (setq message-id (org-remove-angle-brackets message-id)) (org-store-link-props :type link-type :from from :to to :subject subject - :message-id message-id) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) + :message-id message-id :date date) (setq desc (org-email-link-description)) (setq link (concat (concat link-type ":") folder "#" message-id)) (org-add-link-props :link link :description desc) diff --git a/contrib/lisp/org-wl.el b/contrib/lisp/org-wl.el index 632c9e3..2cc333c 100644 --- a/contrib/lisp/org-wl.el +++ b/contrib/lisp/org-wl.el @@ -198,12 +198,6 @@ ENTITY is a message entity." (xref (org-wl-message-field 'xref wl-message-entity)) (subject (org-wl-message-field 'subject wl-message-entity)) (date (org-wl-message-field 'date wl-message-entity)) -(date-ts (and date (format-time-string -(org-time-stamp-format t) -(date-to-time date -(date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date desc link) ;; remove text properties of subject string to avoid possible bug @@ -243,9 +237,7 @@ ENTITY is a message entity." (setq desc (org-email-link-description)) (setq link (concat "wl:" folder-name "#" message-id-no-brackets)) (org-add-link-props :link link :description desc))) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) + (org-add-link-props :date date) (or link xref))) (defun org-wl-open-nntp (path) diff --git
[O] [PATCH 4/9] org: move `org-duration-string-to-minutes' to a better place
--- lisp/org.el | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 6218a3a..a0fe644 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -18328,6 +18328,26 @@ If no number is found, the return value is 0." (string-to-number (match-string 1 s))) (t 0))) +(defun org-duration-string-to-minutes (s &optional output-to-string) + "Convert a duration string S to minutes. + +A bare number is interpreted as minutes, modifiers can be set by +customizing `org-effort-durations' (which see). + +Entries containing a colon are interpreted as H:MM by +`org-hh:mm-string-to-minutes'." + (let ((result 0) + (re (concat "\\([0-9.]+\\) *\\(" + (regexp-opt (mapcar 'car org-effort-durations)) + "\\)"))) +(while (string-match re s) + (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) + (string-to-number (match-string 1 s + (setq s (replace-match "" nil t s))) +(setq result (floor result)) +(incf result (org-hh:mm-string-to-minutes s)) +(if output-to-string (number-to-string result) result))) + (defcustom org-image-actual-width t "Should we use the actual width of images when inlining them? @@ -18386,26 +18406,6 @@ The value is a list, with zero or more of the symbols `effort', `appt', :package-version '(Org . "8.3") :group 'org-agenda) -(defun org-duration-string-to-minutes (s &optional output-to-string) - "Convert a duration string S to minutes. - -A bare number is interpreted as minutes, modifiers can be set by -customizing `org-effort-durations' (which see). - -Entries containing a colon are interpreted as H:MM by -`org-hh:mm-string-to-minutes'." - (let ((result 0) - (re (concat "\\([0-9.]+\\) *\\(" - (regexp-opt (mapcar 'car org-effort-durations)) - "\\)"))) -(while (string-match re s) - (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) - (string-to-number (match-string 1 s - (setq s (replace-match "" nil t s))) -(setq result (floor result)) -(incf result (org-hh:mm-string-to-minutes s)) -(if output-to-string (number-to-string result) result))) - Files (defun org-save-all-org-buffers () -- 2.6.2
[O] [PATCH v2 0/9] mail, clock and calc changes
Hello. While my assignment is snail-mail delivered to and processed by FSF I'd like to request comments on the following set of patches, which contains all the patches I sent to this list before and some new ones. I'm mainly worried by ChangeLog format and possibly unorthodox elisp in ob-calc. The first two are TINYCHANGE. Cheers, Jan Jan Malakhovski (9): org-clock: fix a typo org-colview: add a FIXME org-clock: fix `org-clock-time%' org: move `org-duration-string-to-minutes' to a better place rename `org-duration-string-to-minutes' to `org-clocksum-string-to-minutes' everywhere factor out date-timestamp* calculations to org-store-link-props org-notmuch: add date support to org-notmuch-store-link ob-calc: add more API, documentation and examples so that it can be used in tables ob-calc: don't leave garbage on the stack contrib/lisp/org-depend.el | 2 +- contrib/lisp/org-mew.el| 11 +- contrib/lisp/org-notmuch.el| 7 +- contrib/lisp/org-vm.el | 11 +- contrib/lisp/org-wl.el | 10 +- contrib/lisp/ox-taskjuggler.el | 2 +- doc/org.texi | 4 +- lisp/ob-calc.el| 236 - lisp/org-agenda.el | 2 +- lisp/org-clock.el | 41 +++ lisp/org-colview.el| 5 +- lisp/org-gnus.el | 15 +-- lisp/org-mhe.el| 10 +- lisp/org-rmail.el | 11 +- lisp/org.el| 67 +++- 15 files changed, 263 insertions(+), 171 deletions(-) -- 2.6.2
[O] [PATCH 1/9] org-clock: fix a typo
TINYCHANGE --- lisp/org-clock.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 09f8391..ad423f1 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2774,7 +2774,7 @@ following structure: (LEVEL HEADLINE TIMESTAMP TIME) LEVEL: The level of the headline, as an integer. This will be - the reduced leve, so 1,2,3,... even if only odd levels + the reduced level, so 1,2,3,... even if only odd levels are being used. HEADLINE: The text of the headline. Depending on PARAMS, this may already be formatted like a link. -- 2.6.2
[O] [PATCH 5/9] rename `org-duration-string-to-minutes' to `org-clocksum-string-to-minutes' everywhere
* lisp/org-agenda.el: * lisp/org-clock.el: * lisp/org-colview.el: * lisp/org.el: * contrib/lisp/org-depend.el: * contrib/lisp/ox-taskjuggler.el: Rename (org-duration-string-to-minutes) to (org-clocksum-string-to-minutes). --- contrib/lisp/org-depend.el | 2 +- contrib/lisp/ox-taskjuggler.el | 2 +- lisp/org-agenda.el | 2 +- lisp/org-clock.el | 14 +++--- lisp/org-colview.el| 2 +- lisp/org.el| 14 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/contrib/lisp/org-depend.el b/contrib/lisp/org-depend.el index 1cd4130..7b263bc 100644 --- a/contrib/lisp/org-depend.el +++ b/contrib/lisp/org-depend.el @@ -270,7 +270,7 @@ This does two different kinds of triggers: (effort (when (or effort-up effort-down) (let ((effort (get-text-property (point) 'org-effort))) (when effort - (org-duration-string-to-minutes effort)) + (org-clocksum-string-to-minutes effort)) (push (list (point) todo-kwd priority tags effort) items)) (unless (org-goto-sibling) diff --git a/contrib/lisp/ox-taskjuggler.el b/contrib/lisp/ox-taskjuggler.el index 2bd47e6..b425b1b 100644 --- a/contrib/lisp/ox-taskjuggler.el +++ b/contrib/lisp/ox-taskjuggler.el @@ -861,7 +861,7 @@ a unique id will be associated to it." (and complete (format " complete %s\n" complete)) (and effort (format " effort %s\n" - (let* ((minutes (org-duration-string-to-minutes effort)) + (let* ((minutes (org-clocksum-string-to-minutes effort)) (hours (/ minutes 60.0))) (format "%.1fh" hours (and priority (format " priority %s\n" priority)) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 6313f52..ab4595b 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7665,7 +7665,7 @@ E looks like \"+<2:25\"." ((equal op ??) op) (t '=))) (list 'org-agenda-compare-effort (list 'quote op) - (org-duration-string-to-minutes e + (org-clocksum-string-to-minutes e (defun org-agenda-compare-effort (op value) "Compare the effort of the current line with VALUE, using OP. diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 4563a8a..ab65d3b 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -668,7 +668,7 @@ If not, show simply the clocked time like 01:50." (let ((clocked-time (org-clock-get-clocked-time))) (if org-clock-effort (let* ((effort-in-minutes - (org-duration-string-to-minutes org-clock-effort)) + (org-clocksum-string-to-minutes org-clock-effort)) (work-done-str (org-propertize (org-minutes-to-clocksum-string clocked-time) @@ -749,10 +749,10 @@ clocked item, and the value displayed in the mode line." ;; A string. See if it is a delta (setq sign (string-to-char value)) (if (member sign '(?- ?+)) - (setq current (org-duration-string-to-minutes current) + (setq current (org-clocksum-string-to-minutes current) value (substring value 1)) (setq current 0)) - (setq value (org-duration-string-to-minutes value)) + (setq value (org-clocksum-string-to-minutes value)) (if (equal ?- sign) (setq value (- current value)) (if (equal ?+ sign) (setq value (+ current value) @@ -770,7 +770,7 @@ clocked item, and the value displayed in the mode line." "Show notification if we spent more time than we estimated before. Notification is shown only once." (when (org-clocking-p) -(let ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort)) +(let ((effort-in-minutes (org-clocksum-string-to-minutes org-clock-effort)) (clocked-time (org-clock-get-clocked-time))) (if (setq org-clock-task-overrun (if (or (null effort-in-minutes) (zerop effort-in-minutes)) @@ -1193,7 +1193,7 @@ make this the default behavior.)" (setq org-clock-notification-was-shown nil) (org-refresh-properties org-effort-property '((effort . identity) -(effort-minutes . org-duration-string-to-minutes))) +(effort-minutes . org-clocksum-string-to-minutes))) (catch 'abort (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) @@ -2869,13 +2869,13 @@ TIME: The sum of all time spend in this tree, in minutes. This time "Compute a time fraction in percent. TOTAL s a total time string. STRINGS is a list of strings that should be checked for a ti
[O] [PATCH 3/9] org-clock: fix `org-clock-time%'
* lisp/org-clock.el (org-clock-time%): Respect org-effort-durations. This also fixes a bug with time percents looking pretty much random and adding to a number that is less than 100% when a clock report has long intervals (e.g. days). --- lisp/org-clock.el | 29 +++-- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index ad423f1..4563a8a 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2867,27 +2867,20 @@ TIME: The sum of all time spend in this tree, in minutes. This time (defun org-clock-time% (total &rest strings) "Compute a time fraction in percent. -TOTAL s a time string like 10:21 specifying the total times. +TOTAL s a total time string. STRINGS is a list of strings that should be checked for a time. -The first string that does have a time will be used. -This function is made for clock tables." - (let ((re "\\([0-9]+\\):\\([0-9]+\\)") - tot s) -(save-match-data +Strings are parsed using `org-duration-string-to-minutes`. +The first string that does have a time will be used. This +function is made for clock tables." + (save-match-data +(let (tot s cur) (catch 'exit - (if (not (string-match re total)) - (throw 'exit 0.) - (setq tot (+ (string-to-number (match-string 2 total)) - (* 60 (string-to-number (match-string 1 total) - (if (= tot 0.) (throw 'exit 0.))) + (setq tot (org-duration-string-to-minutes total)) + (if (= tot 0.) (throw 'exit 0.)) (while (setq s (pop strings)) - (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) - (throw 'exit -(/ (* 100.0 (+ (string-to-number (match-string 2 s)) - (* 60 (string-to-number - (match-string 1 s) - tot - 0 + (setq cur (org-clocksum-string-to-minutes s)) + (if (not (equal cur nil)) (throw 'exit (/ (* 100.0 cur) tot + nil ;; Saving and loading the clock -- 2.6.2
[O] [PATCH 2/9] org-colview: add a FIXME
TINYCHANGE --- lisp/org-colview.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index b698801..d27abc3 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1113,6 +1113,9 @@ display, or in the #+COLUMNS line of the current buffer." ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) (if (equal s "[X]") 1. 0.01)) ((memq fmt '(estimate)) (org-string-to-estimate s)) + ;; FIXME: does this duplicate org-clocksum-string-to-minutes in a most peculiar way? + ;; I can guess that long time ago this used org-hh:mm-string-to-minutes + ;; and all this ugliness derives from that ((string-match (concat "\\([0-9.]+\\) *\\(" (regexp-opt (mapcar 'car org-effort-durations)) "\\)") s) -- 2.6.2
[O] [PATCH 7/9] org-notmuch: add date support to org-notmuch-store-link
* contrib/lisp/org-notmuch.el (org-notmuch-store-link): Add date support. * doc/org.texi: Fix `org-capture-templates' documentation. --- contrib/lisp/org-notmuch.el | 7 --- doc/org.texi| 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/lisp/org-notmuch.el b/contrib/lisp/org-notmuch.el index 712ec5a..265742e 100644 --- a/contrib/lisp/org-notmuch.el +++ b/contrib/lisp/org-notmuch.el @@ -71,15 +71,16 @@ Should accept a notmuch search string as the sole argument." (defun org-notmuch-store-link () "Store a link to a notmuch search or message." (when (eq major-mode 'notmuch-show-mode) -(let* ((message-id (notmuch-show-get-prop :id)) +(let* ((message-id (notmuch-show-get-message-id t)) (subject (notmuch-show-get-subject)) (to (notmuch-show-get-to)) (from (notmuch-show-get-from)) + (date (org-trim (notmuch-show-get-date))) desc link) - (org-store-link-props :type "notmuch" :from from :to to + (org-store-link-props :type "notmuch" :from from :to to :date date :subject subject :message-id message-id) (setq desc (org-email-link-description)) - (setq link (concat "notmuch:" "id:" message-id)) + (setq link (concat "notmuch:id:" message-id)) (org-add-link-props :link link :description desc) link))) diff --git a/doc/org.texi b/doc/org.texi index 2bf2b24..106bdac 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -7315,7 +7315,7 @@ Link type| Available keywords bbdb | %:name %:company irc | %:server %:port %:nick vm, vm-imap, wl, mh, mew, rmail, | %:type %:subject %:message-id -gnus | %:from %:fromname %:fromaddress +gnus, notmuch| %:from %:fromname %:fromaddress | %:to %:toname %:toaddress | %:date @r{(message date header field)} | %:date-timestamp @r{(date as active timestamp)} -- 2.6.2
Re: [O] Bug: Regressions from 8.2.10 (8.2.10-35-g19a7d6-elpaplus) to master/maint
Matt Lundin writes: > Jan Malakhovski writes: > >> I'm pretty sure that there are other org-mode users that are weeping >> silently since that change. Suppose you have more than a screen of clock >> lines in LOGBOOK under a heading (I have headings that have thousands). >> (org-agenda-goto) before 9f5e698679aecbed872a2030e4157e5e2b1d87e0 is >> very helpful when moving CLOCK lines between headings (think "refile >> CLOCK line") or editing overlaps or gaps: you or click on the >> heading and here you are at the CLOCK, but after >> 9f5e698679aecbed872a2030e4157e5e2b1d87e0 you have to *retype* the date >> and time into search, which is annoying to say the least. > > Try typing RET in the agenda. That calls org-agenda-switch-to, which > brings you to the relevant clock information in the agenda.(However, if > the information is tucked away in a LOGBOOK, it remains somewhat > inconveniently hidden from view). Judging by the names and default key bindings alone I'd prefer org-agenda-switch-to to do the new org-agenda-goto thing, and org-agenda-goto have the previous behavior. This kinda makes more sense to me, see below. In any case, current org-agenda-switch-to behavior is no replacement for old org-agenda-goto: 1) I'm not aware of a key sequence to do org-reveal for drawers (in org-agenda-goto it's a nontrivial piece of code). 2) Even if there is such a sequence, the drawer should be open by default. >> I'm willing to listen, but I seriously doubt there's such a compelling >> argument defending the change. Even when out of `org-agenda-list` in >> plain `org-agenda`, jumping to SCHEDULED or DEADLINE lines is nicer than >> to the heading itself. > > I disagree that jumping to the SCHEDULED or DEADLINE lines from a normal > agenda is always nicer than jumping to the headline. I can easily change > planning info from within the agenda. But I cannot change the text of > the headline itself -- that is usually why I jump from the agenda. If > nothing else, we should have both options, which we seem to currently > have with the difference between TAB (org-agenda-goto) and RET > (org-agenda-switch-to). However, I am not sure how intentional this is, > as I can find nothing highlighting this difference in the documentation. Okay, that is a pretty valid use case, but even then, (below starts here) org file syntax requires SCHEDULED and DEADLINE to be just under the heading, which means that you can navigate to the heading pretty easily, where as with CLOCK lines you can not. Which is why, I think, both org-agenda-goto and org-agenda-goto-mouse should have the old behavior, but, in principle, I can imagine and doing different things in plain org-agenda and org-agenda-list. So, to sum up, I see three possible solutions: 1) org-agenda-goto and org-agenda-goto-mouse jump to a line with the timestamp (old org-agenda-goto behavior), org-agenda-switch-to jumps to the heading (current org-agenda-goto behavior). (I vote for this). 2) org-agenda-switch-to gets the org-agenda-goto behavior. (I can live with it, but I think it is less pretty.) 3) org-agenda-goto and *-mouse (or just their key bindings) do different things in plain agenda and in agenda-list. (Seems complicated.) Cheers, Jan
Re: [O] Bug: Regressions from 8.2.10 (8.2.10-35-g19a7d6-elpaplus) to master/maint
Jan Malakhovski writes: > Nicolas Goaziou writes: > >> Could you provide an ECM with appropriate CLOCK lines? > > Attached. Okay, so I bisected and found that the offender is 9f5e698679aecbed872a2030e4157e5e2b1d87e0. Since then these lines have changed, so the following diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index bdb69c5..38baac2 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -8411,10 +8411,10 @@ When called with a prefix argument, include all archive files as well." (org-flag-heading nil))) ; show the next heading (when (outline-invisible-p) (outline-show-entry)) ; display invisible text - (recenter (/ (window-height) 2)) - (org-back-to-heading t) - (if (re-search-forward org-complex-heading-regexp nil t) - (goto-char (match-beginning 4 + (recenter (/ (window-height) 2))) +; (org-back-to-heading t) +; (if (re-search-forward org-complex-heading-regexp nil t) +;(goto-char (match-beginning 4 (run-hooks 'org-agenda-after-show-hook) (and highlight (org-highlight (point-at-bol) (point-at-eol) makes all of my problems this go away. If you read 9f5e698679aecbed872a2030e4157e5e2b1d87e0 you'll notice that it changed both the behavior and the doc-string (that is to say that you can't refer to doc-string as an argument against the previous behavior). I'm pretty sure that there are other org-mode users that are weeping silently since that change. Suppose you have more than a screen of clock lines in LOGBOOK under a heading (I have headings that have thousands). (org-agenda-goto) before 9f5e698679aecbed872a2030e4157e5e2b1d87e0 is very helpful when moving CLOCK lines between headings (think "refile CLOCK line") or editing overlaps or gaps: you or click on the heading and here you are at the CLOCK, but after 9f5e698679aecbed872a2030e4157e5e2b1d87e0 you have to *retype* the date and time into search, which is annoying to say the least. I'm willing to listen, but I seriously doubt there's such a compelling argument defending the change. Even when out of `org-agenda-list` in plain `org-agenda`, jumping to SCHEDULED or DEADLINE lines is nicer than to the heading itself. Cheers, Jan
Re: [O] Bug: Regressions from 8.2.10 (8.2.10-35-g19a7d6-elpaplus) to master/maint
Nicolas Goaziou writes: > Could you provide an ECM with appropriate CLOCK lines? Attached. * Other files: ** init.el: #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/repo/org-mode/lisp") (add-to-list 'load-path "~/repo/org-mode/contrib/lisp") (require 'org) (setq org-directory "~/org" org-agenda-files "~/agenda-files") #+END_SRC ** ~/agenda-files: #+BEGIN_SRC emacs-lisp ~/org/minimal.org #+END_SRC * Process: ** Press `M-x org-agenda-list` ** Press `v l` (or `v c`) ** Select any of the two entries (intervals) ** Press `` * Expected: cursor jump to the corresponding CLOCK:. * Got: cursor jump to "Test" line. Cheers, Jan * Test :LOGBOOK: CLOCK: [2015-10-25 Sun 17:00]--[2015-10-25 Sun 18:00] => 1:00 CLOCK: [2015-10-25 Sun 16:00]--[2015-10-25 Sun 17:00] => 1:00 :END:
Re: [O] Bug: Regressions from 8.2.10 (8.2.10-35-g19a7d6-elpaplus) to master/maint
Nicolas Goaziou writes: >> * Pressing on an entry in org-agenda-list moves the cursor to the >> corresponding node. >> >> Previously it moved the cursor to the corresponding CLOCK: line and I >> used that a lot. > > According to `org-agenda-goto''s docstring, this doesn't look like > a feature. Besides, there is a function to jump to the running clock > already: `org-clock-goto'. I mean this sequence: * Press `M-x org-agenda-list` * Press `v l` (or `v c`) * Select an entry (interval) * Press `` Previously it opened a window with the cursor on the CLOCK: line of the corresponding entry (interval), now it jumps to the header of the task this interval is an element of. I'm sure this is a misfeature because now it's pretty much impossible to quickly find CLOCK: entries that correspond to current org-agenda-list items. For me this is critical, because I clock everything, have megabytes of CLOCK: entries and edit them a lot. Cheers, Jan
[O] Bug: Regressions from 8.2.10 (8.2.10-35-g19a7d6-elpaplus) to master/maint
Hi. Emacs : GNU Emacs 24.5.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.28) of 2015-10-05 on localhost Current package: Org-mode version 8.3.2 (release_8.3.2-209-gba4d33 @ /home/oxij/repo/org-mode/lisp/) (actually, both master and maint) Previous package: Org-mode version 8.2.10 (8.2.10-35-g19a7d6-elpaplus @ /run/current-system/sw/share/emacs/site-lisp/elpa/org-plus-contrib-20150406/) Some regressions when moving from previous to current package: * C-c C-x C-i clocks in into a wrong node. Instead of clocking-in into the node under cursor it clock-ins into the next one. Can be replicated with the following init.el: #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "~/repo/org-mode/lisp") (add-to-list 'load-path "~/repo/org-mode/contrib/lisp") (require 'org) #+END_SRC and attached minimal.org. * Pressing on an entry in org-agenda-list moves the cursor to the corresponding node. Previously it moved the cursor to the corresponding CLOCK: line and I used that a lot. Cheers, Jan * Test ** Test test ** Test test * Test * Test
[O] [PATCH 1/2] factor out date-timestamp* calculations to org-store-link-props
--- contrib/lisp/org-mew.el | 11 +-- contrib/lisp/org-vm.el | 11 +-- contrib/lisp/org-wl.el | 10 +- doc/org.texi| 4 ++-- lisp/org-gnus.el| 15 +-- lisp/org-mhe.el | 10 +- lisp/org-rmail.el | 11 +-- lisp/org.el | 15 +-- 8 files changed, 21 insertions(+), 66 deletions(-) diff --git a/contrib/lisp/org-mew.el b/contrib/lisp/org-mew.el index eb0afc0..35fdd8b 100644 --- a/contrib/lisp/org-mew.el +++ b/contrib/lisp/org-mew.el @@ -167,19 +167,10 @@ with \"t\" key." (from (mew-header-get-value "From:")) (to (mew-header-get-value "To:")) (date (mew-header-get-value "Date:")) - (date-ts (and date (format-time-string - (org-time-stamp-format t) - (date-to-time date - (date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date (subject (mew-header-get-value "Subject:")) desc link) - (org-store-link-props :type "mew" :from from :to to + (org-store-link-props :type "mew" :from from :to to :date date :subject subject :message-id message-id) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) (setq message-id (org-remove-angle-brackets message-id)) (setq desc (org-email-link-description)) (setq link (concat "mew:" folder-name "#" message-id)) diff --git a/contrib/lisp/org-vm.el b/contrib/lisp/org-vm.el index 5d30f64..da242cb 100644 --- a/contrib/lisp/org-vm.el +++ b/contrib/lisp/org-vm.el @@ -77,12 +77,6 @@ (message-id (vm-su-message-id message)) (link-type (if (vm-imap-folder-p) "vm-imap" "vm")) (date (vm-get-header-contents message "Date")) -(date-ts (and date (format-time-string -(org-time-stamp-format t) -(date-to-time date -(date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date folder desc link) (if (vm-imap-folder-p) (let ((spec (vm-imap-find-spec-for-buffer (current-buffer @@ -95,10 +89,7 @@ (setq folder (replace-match "" t t folder) (setq message-id (org-remove-angle-brackets message-id)) (org-store-link-props :type link-type :from from :to to :subject subject - :message-id message-id) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) + :message-id message-id :date date) (setq desc (org-email-link-description)) (setq link (concat (concat link-type ":") folder "#" message-id)) (org-add-link-props :link link :description desc) diff --git a/contrib/lisp/org-wl.el b/contrib/lisp/org-wl.el index 632c9e3..2cc333c 100644 --- a/contrib/lisp/org-wl.el +++ b/contrib/lisp/org-wl.el @@ -198,12 +198,6 @@ ENTITY is a message entity." (xref (org-wl-message-field 'xref wl-message-entity)) (subject (org-wl-message-field 'subject wl-message-entity)) (date (org-wl-message-field 'date wl-message-entity)) -(date-ts (and date (format-time-string -(org-time-stamp-format t) -(date-to-time date -(date-ts-ia (and date (format-time-string - (org-time-stamp-format t t) - (date-to-time date desc link) ;; remove text properties of subject string to avoid possible bug @@ -243,9 +237,7 @@ ENTITY is a message entity." (setq desc (org-email-link-description)) (setq link (concat "wl:" folder-name "#" message-id-no-brackets)) (org-add-link-props :link link :description desc))) - (when date - (org-add-link-props :date date :date-timestamp date-ts - :date-timestamp-inactive date-ts-ia)) + (org-add-link-props :date date) (or link xref))) (defun org-wl-open-nntp (path) diff --git a/doc/org.texi b/doc/org.texi index c1fe56e..30cc0e4 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -7314,8 +7314,8 @@ Link type| Available keywords -+-- bbdb | %:name %:company irc
[O] [PATCH] remove some copy-paste and add date support to org-notmuch-store-link
Cheers, Jan Jan Malakhovski (2): factor out date-timestamp* calculations to org-store-link-props org-notmuch: add date support to org-notmuch-store-link contrib/lisp/org-mew.el | 11 +-- contrib/lisp/org-notmuch.el | 7 --- contrib/lisp/org-vm.el | 11 +-- contrib/lisp/org-wl.el | 10 +- doc/org.texi| 4 ++-- lisp/org-gnus.el| 15 +-- lisp/org-mhe.el | 10 +- lisp/org-rmail.el | 11 +-- lisp/org.el | 15 +-- 9 files changed, 25 insertions(+), 69 deletions(-) -- 2.5.3
[O] [PATCH 2/2] org-notmuch: add date support to org-notmuch-store-link
--- contrib/lisp/org-notmuch.el | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/org-notmuch.el b/contrib/lisp/org-notmuch.el index 712ec5a..265742e 100644 --- a/contrib/lisp/org-notmuch.el +++ b/contrib/lisp/org-notmuch.el @@ -71,15 +71,16 @@ Should accept a notmuch search string as the sole argument." (defun org-notmuch-store-link () "Store a link to a notmuch search or message." (when (eq major-mode 'notmuch-show-mode) -(let* ((message-id (notmuch-show-get-prop :id)) +(let* ((message-id (notmuch-show-get-message-id t)) (subject (notmuch-show-get-subject)) (to (notmuch-show-get-to)) (from (notmuch-show-get-from)) + (date (org-trim (notmuch-show-get-date))) desc link) - (org-store-link-props :type "notmuch" :from from :to to + (org-store-link-props :type "notmuch" :from from :to to :date date :subject subject :message-id message-id) (setq desc (org-email-link-description)) - (setq link (concat "notmuch:" "id:" message-id)) + (setq link (concat "notmuch:id:" message-id)) (org-add-link-props :link link :description desc) link))) -- 2.5.3
[O] [PATCH 4/4] org-colview: add a FIXME
--- lisp/org-colview.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 1113adc..4f09766 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1113,6 +1113,9 @@ display, or in the #+COLUMNS line of the current buffer." ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) (if (equal s "[X]") 1. 0.01)) ((memq fmt '(estimate)) (org-string-to-estimate s)) + ;; FIXME: does this duplicate org-clocksum-string-to-minutes in a most peculiar way? + ;; I can guess that long time ago this used org-hh:mm-string-to-minutes + ;; and all this ugliness derives from that ((string-match (concat "\\([0-9.]+\\) *\\(" (regexp-opt (mapcar 'car org-effort-durations)) "\\)") s) -- 2.5.3
[O] [PATCH 2/4] org: move org-duration-string-to-minutes to a better place
--- lisp/org.el | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 088913c..453ed37 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -18329,6 +18329,26 @@ If no number is found, the return value is 0." (string-to-number (match-string 1 s))) (t 0))) +(defun org-duration-string-to-minutes (s &optional output-to-string) + "Convert a duration string S to minutes. + +A bare number is interpreted as minutes, modifiers can be set by +customizing `org-effort-durations' (which see). + +Entries containing a colon are interpreted as H:MM by +`org-hh:mm-string-to-minutes'." + (let ((result 0) + (re (concat "\\([0-9.]+\\) *\\(" + (regexp-opt (mapcar 'car org-effort-durations)) + "\\)"))) +(while (string-match re s) + (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) + (string-to-number (match-string 1 s + (setq s (replace-match "" nil t s))) +(setq result (floor result)) +(incf result (org-hh:mm-string-to-minutes s)) +(if output-to-string (number-to-string result) result))) + (defcustom org-image-actual-width t "Should we use the actual width of images when inlining them? @@ -18387,26 +18407,6 @@ The value is a list, with zero or more of the symbols `effort', `appt', :package-version '(Org . "8.3") :group 'org-agenda) -(defun org-duration-string-to-minutes (s &optional output-to-string) - "Convert a duration string S to minutes. - -A bare number is interpreted as minutes, modifiers can be set by -customizing `org-effort-durations' (which see). - -Entries containing a colon are interpreted as H:MM by -`org-hh:mm-string-to-minutes'." - (let ((result 0) - (re (concat "\\([0-9.]+\\) *\\(" - (regexp-opt (mapcar 'car org-effort-durations)) - "\\)"))) -(while (string-match re s) - (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations)) - (string-to-number (match-string 1 s - (setq s (replace-match "" nil t s))) -(setq result (floor result)) -(incf result (org-hh:mm-string-to-minutes s)) -(if output-to-string (number-to-string result) result))) - Files (defun org-save-all-org-buffers () -- 2.5.3
[O] [PATCH 1/4] org-clock: make org-clock-time% respect org-effort-durations
This also fixes a bug with time percents looking pretty much random and adding to a number that is less than 100% when a clock report has long intervals (e.g. days). --- lisp/org-clock.el | 29 +++-- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 5d7c6b4..6cbd132 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2867,27 +2867,20 @@ TIME: The sum of all time spend in this tree, in minutes. This time (defun org-clock-time% (total &rest strings) "Compute a time fraction in percent. -TOTAL s a time string like 10:21 specifying the total times. +TOTAL s a total time string. STRINGS is a list of strings that should be checked for a time. -The first string that does have a time will be used. -This function is made for clock tables." - (let ((re "\\([0-9]+\\):\\([0-9]+\\)") - tot s) -(save-match-data +Strings are parsed using `org-duration-string-to-minutes`. +The first string that does have a time will be used. This +function is made for clock tables." + (save-match-data +(let (tot s cur) (catch 'exit - (if (not (string-match re total)) - (throw 'exit 0.) - (setq tot (+ (string-to-number (match-string 2 total)) - (* 60 (string-to-number (match-string 1 total) - (if (= tot 0.) (throw 'exit 0.))) + (setq tot (org-duration-string-to-minutes total)) + (if (= tot 0.) (throw 'exit 0.)) (while (setq s (pop strings)) - (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) - (throw 'exit -(/ (* 100.0 (+ (string-to-number (match-string 2 s)) - (* 60 (string-to-number - (match-string 1 s) - tot - 0 + (setq cur (org-clocksum-string-to-minutes s)) + (if (not (equal cur nil)) (throw 'exit (/ (* 100.0 cur) tot + nil ;; Saving and loading the clock -- 2.5.3
[O] [PATCH] make org-clock-time% respect org-effort-durations and related
Hi. The first patch here is a must, because it fixes a bug I stumble upoon daily. Middle two are just to make the names consistent. While doing all those changes I read quite a lot of code and the last patch adds a FIXME for a particularly ugly place I'm not sure how to fix (I think don't ever consciously use that code path and I'm not sure what it supposed to do). Cheers, Jan Jan Malakhovski (4): org-clock: make org-clock-time% respect org-effort-durations org: move org-duration-string-to-minutes to a better place rename org-duration-string-to-minutes to org-clocksum-string-to-minutes everywhere org-colview: add a FIXME contrib/lisp/org-depend.el | 2 +- contrib/lisp/ox-taskjuggler.el | 2 +- lisp/org-agenda.el | 2 +- lisp/org-clock.el | 39 +-- lisp/org-colview.el| 5 +++- lisp/org.el| 52 +++--- 6 files changed, 51 insertions(+), 51 deletions(-) -- 2.5.3
[O] [PATCH 3/4] rename org-duration-string-to-minutes to org-clocksum-string-to-minutes everywhere
--- contrib/lisp/org-depend.el | 2 +- contrib/lisp/ox-taskjuggler.el | 2 +- lisp/org-agenda.el | 2 +- lisp/org-clock.el | 14 +++--- lisp/org-colview.el| 2 +- lisp/org.el| 14 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/contrib/lisp/org-depend.el b/contrib/lisp/org-depend.el index 1cd4130..7b263bc 100644 --- a/contrib/lisp/org-depend.el +++ b/contrib/lisp/org-depend.el @@ -270,7 +270,7 @@ This does two different kinds of triggers: (effort (when (or effort-up effort-down) (let ((effort (get-text-property (point) 'org-effort))) (when effort - (org-duration-string-to-minutes effort)) + (org-clocksum-string-to-minutes effort)) (push (list (point) todo-kwd priority tags effort) items)) (unless (org-goto-sibling) diff --git a/contrib/lisp/ox-taskjuggler.el b/contrib/lisp/ox-taskjuggler.el index 2bd47e6..b425b1b 100644 --- a/contrib/lisp/ox-taskjuggler.el +++ b/contrib/lisp/ox-taskjuggler.el @@ -861,7 +861,7 @@ a unique id will be associated to it." (and complete (format " complete %s\n" complete)) (and effort (format " effort %s\n" - (let* ((minutes (org-duration-string-to-minutes effort)) + (let* ((minutes (org-clocksum-string-to-minutes effort)) (hours (/ minutes 60.0))) (format "%.1fh" hours (and priority (format " priority %s\n" priority)) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index e7a3776..bdb69c5 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7655,7 +7655,7 @@ E looks like \"+<2:25\"." ((equal op ??) op) (t '=))) (list 'org-agenda-compare-effort (list 'quote op) - (org-duration-string-to-minutes e + (org-clocksum-string-to-minutes e (defun org-agenda-compare-effort (op value) "Compare the effort of the current line with VALUE, using OP. diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 6cbd132..2f254e1 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -668,7 +668,7 @@ If not, show simply the clocked time like 01:50." (let ((clocked-time (org-clock-get-clocked-time))) (if org-clock-effort (let* ((effort-in-minutes - (org-duration-string-to-minutes org-clock-effort)) + (org-clocksum-string-to-minutes org-clock-effort)) (work-done-str (org-propertize (org-minutes-to-clocksum-string clocked-time) @@ -749,10 +749,10 @@ clocked item, and the value displayed in the mode line." ;; A string. See if it is a delta (setq sign (string-to-char value)) (if (member sign '(?- ?+)) - (setq current (org-duration-string-to-minutes current) + (setq current (org-clocksum-string-to-minutes current) value (substring value 1)) (setq current 0)) - (setq value (org-duration-string-to-minutes value)) + (setq value (org-clocksum-string-to-minutes value)) (if (equal ?- sign) (setq value (- current value)) (if (equal ?+ sign) (setq value (+ current value) @@ -770,7 +770,7 @@ clocked item, and the value displayed in the mode line." "Show notification if we spent more time than we estimated before. Notification is shown only once." (when (org-clocking-p) -(let ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort)) +(let ((effort-in-minutes (org-clocksum-string-to-minutes org-clock-effort)) (clocked-time (org-clock-get-clocked-time))) (if (setq org-clock-task-overrun (if (or (null effort-in-minutes) (zerop effort-in-minutes)) @@ -1193,7 +1193,7 @@ make this the default behavior.)" (setq org-clock-notification-was-shown nil) (org-refresh-properties org-effort-property '((effort . identity) -(effort-minutes . org-duration-string-to-minutes))) +(effort-minutes . org-clocksum-string-to-minutes))) (catch 'abort (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness) (org-clocking-p))) @@ -2869,13 +2869,13 @@ TIME: The sum of all time spend in this tree, in minutes. This time "Compute a time fraction in percent. TOTAL s a total time string. STRINGS is a list of strings that should be checked for a time. -Strings are parsed using `org-duration-string-to-minutes`. +Strings are parsed using `org-clocksum-string-to-minutes`. The first string that does have a time will be used. This function is made for clock tables." (