Compare commits

..

No commits in common. "866f652c4b9f26bc53e709f0bfdd185021ef3125" and "bef3a482f39179c1360f43deccac19a171de2ff2" have entirely different histories.

2 changed files with 17 additions and 53 deletions

19
init.el
View File

@ -730,8 +730,6 @@
db/org-clock-in-home-task db/org-clock-in-home-task
db/org-clock-in-work-task db/org-clock-in-work-task
db/show-current-org-task db/show-current-org-task
db/org-remaining-effort-of-current-item
db/org-cmp-remaining-effort
org-dblock-write:db/org-workload-report org-dblock-write:db/org-workload-report
endless/org-ispell endless/org-ispell
db/org-agenda-list-deadlines db/org-agenda-list-deadlines
@ -1102,11 +1100,10 @@
:init (setq org-agenda-include-diary t :init (setq org-agenda-include-diary t
org-agenda-span 1 org-agenda-span 1
org-agenda-insert-diary-strategy 'top-level org-agenda-insert-diary-strategy 'top-level
org-agenda-sorting-strategy '((agenda time-up priority-down user-defined-up category-keep) org-agenda-sorting-strategy '((agenda time-up priority-down effort-up category-keep)
(todo priority-down user-defined-up category-keep) (todo priority-down effort-up category-keep)
(tags priority-down user-defined-up category-keep) (tags priority-down effort-up category-keep)
(search priority-down user-defined-up category-keep)) (search priority-down effort-up category-keep))
org-agenda-cmp-user-defined #'db/org-cmp-remaining-effort
org-agenda-window-setup 'current-window org-agenda-window-setup 'current-window
org-agenda-restore-windows-after-quit t org-agenda-restore-windows-after-quit t
org-agenda-compact-blocks nil org-agenda-compact-blocks nil
@ -1159,10 +1156,10 @@
"") "")
org-agenda-prefix-format org-agenda-prefix-format
'((agenda . "%11s%?-12t%-4(db/org-remaining-effort-of-current-item) ") '((agenda . "%11s%?-12t%-4e ")
(todo . "%-8c%-4(db/org-remaining-effort-of-current-item) ") (todo . "%-8c%-4e ")
(tags . "%-8c%-4(db/org-remaining-effort-of-current-item) ") (tags . "%-8c%-4e ")
(search . "%-8c%-4(db/org-remaining-effort-of-current-item) ")) (search . "%-8c%-4e "))
org-agenda-custom-commands org-agenda-custom-commands
`(("A" "Main Agenda" `(("A" "Main Agenda"

View File

@ -204,9 +204,7 @@ shown because they are due)."
'("scheduled" "past-scheduled" "timestamp" "deadline" "block")) '("scheduled" "past-scheduled" "timestamp" "deadline" "block"))
(let ((item-id (org-with-point-at (org-get-at-bol 'org-hd-marker) (org-id-get-create)))) (let ((item-id (org-with-point-at (org-get-at-bol 'org-hd-marker) (org-id-get-create))))
(unless (member item-id already-seen) (unless (member item-id already-seen)
(push (org-with-point-at (org-get-at-bol 'org-hd-marker) (push (org-entry-get (org-get-at-bol 'org-hd-marker) "Effort") total)
(db/org-remaining-effort-of-current-item))
total)
(push item-id already-seen)))) (push item-id already-seen))))
(forward-line)))) (forward-line))))
(org-duration-from-minutes (org-duration-from-minutes
@ -427,52 +425,21 @@ is clocked in."
The remaining effort is computed as the planned effort minus the The remaining effort is computed as the planned effort minus the
already clocked time. If this result is negative, return zero. already clocked time. If this result is negative, return zero.
If no effort is specified, return an empty string." If no effort is specified, return nil."
(if (derived-mode-p 'org-agenda-mode) (if (derived-mode-p 'org-agenda-mode)
(if-let ((hd-marker (org-get-at-bol 'org-hd-marker))) ;; XXX: is this the right way to do it?
;; `org-hd-marker' is set, there is some Org item that corresponds to (org-agenda-with-point-at-orig-entry
;; this line. Get the remaining effort from there. nil (db/org-remaining-effort-of-current-item))
(org-with-point-at hd-marker
(db/org-remaining-effort-of-current-item))
;; We are at some special item in the Org agenda (e.g. some diary
;; entry), just show nothing.
"")
(unless (derived-mode-p 'org-mode) (unless (derived-mode-p 'org-mode)
(user-error "Not in Org mode buffer, aborting")) (user-error "Not in Org mode buffer, aborting"))
(if-let ((effort (org-entry-get (point) "Effort"))) (when-let ((effort (org-entry-get (point) "Effort")))
(org-duration-from-minutes (org-duration-from-minutes
(max 0 (- (org-duration-to-minutes effort) (max 0 (- (org-duration-to-minutes effort)
(db/org-clocked-time-for-current-item)))) (db/org-clocked-time-for-current-item)))))))
"")))
(defun db/org-cmp-remaining-effort (a b)
"Compare the remaining efforts of Org items A and B.
A and B are strings only, but their corresponding Org items are
accessible via the `org-hd-marker' text property."
(let* ((def (if org-agenda-sort-noeffort-is-high 32767 -1))
(ma (or (get-text-property 1 'org-marker a)
(get-text-property 1 'org-hd-marker a)))
(mb (or (get-text-property 1 'org-marker b)
(get-text-property 1 'org-hd-marker b)))
(ea (or (and (markerp ma)
(marker-buffer ma)
(org-with-point-at ma
(org-duration-to-minutes ; this is inefficient
(db/org-remaining-effort-of-current-item))))
def))
(eb (or (and (markerp mb)
(marker-buffer mb)
(org-with-point-at mb
(org-duration-to-minutes
(db/org-remaining-effort-of-current-item))))
def)))
(cond ((> ea eb) +1)
((< ea eb) -1))))
;;; Task Management ;;; Task Management