Fix nil display in agenda when remaining effort is not set

Just return the empty string instead.
This commit is contained in:
Daniel - 2023-04-01 17:01:00 +02:00
parent 0a14f01729
commit 866f652c4b
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 10 additions and 11 deletions

View File

@ -427,7 +427,7 @@ 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 nil." If no effort is specified, return an empty string."
(if (derived-mode-p 'org-agenda-mode) (if (derived-mode-p 'org-agenda-mode)
@ -443,10 +443,11 @@ If no effort is specified, return nil."
(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"))
(when-let ((effort (org-entry-get (point) "Effort"))) (if-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) (defun db/org-cmp-remaining-effort (a b)
"Compare the remaining efforts of Org items A and B. "Compare the remaining efforts of Org items A and B.
@ -461,16 +462,14 @@ accessible via the `org-hd-marker' text property."
(ea (or (and (markerp ma) (ea (or (and (markerp ma)
(marker-buffer ma) (marker-buffer ma)
(org-with-point-at ma (org-with-point-at ma
(--if-let (db/org-remaining-effort-of-current-item) (org-duration-to-minutes ; this is inefficient
(org-duration-to-minutes it) (db/org-remaining-effort-of-current-item))))
0)))
def)) def))
(eb (or (and (markerp mb) (eb (or (and (markerp mb)
(marker-buffer mb) (marker-buffer mb)
(org-with-point-at mb (org-with-point-at mb
(--if-let (db/org-remaining-effort-of-current-item) (org-duration-to-minutes
(org-duration-to-minutes it) (db/org-remaining-effort-of-current-item))))
0)))
def))) def)))
(cond ((> ea eb) +1) (cond ((> ea eb) +1)
((< ea eb) -1)))) ((< ea eb) -1))))