emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum


From: Anand Deopurkar
Subject: [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum
Date: Tue, 24 Sep 2024 09:23:46 +1000

From 0b6fbd5bc1326163e16351cee6ee267777e7ecf8 Mon Sep 17 00:00:00 2001
From: Anand Deopurkar <anandrdeopurkar@gmail.com>
Date: Mon, 23 Sep 2024 22:58:48 +1000
Subject: [PATCH] lisp/org-colview.el: Bug fix for
 add-appointments-to-effort-sum

* org-colview.el (org-columns--collect-values): Accept an additional
optional argument AGENDA-MARKER
(org-agenda-columns): Pass the position of the current agenda line to
org-columns--collect-values through AGENDA-MARKER.  Use it to read the
'duration' property

Fixes the bug below.

Reported-by: Stanislav Vlasov
Link:
https://lists.gnu.org/archive/html/emacs-orgmode/2020-08/msg00090.html

also see the fix
Reported-by: Mamoru Miura
Link: https://lists.gnu.org/archive/html/emacs-orgmode/2022-07/msg00558.html

Previously, org-agenda-columns called org-columns--collect-values from
the buffer from which the agenda line originates. As a result,
org-columns--collect-values did not have access to the agenda line.
Mamoru Miura's solution recomputes the agenda-line.  My current patch
adds an optional argument to org-columns--collect-values which can be
used to pass the position of the agenda line.

TINYCHANGE
---
 lisp/org-colview.el | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index a9eb2e0b6..486badf1e 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -279,7 +279,7 @@ value for ITEM property."
        (`(,_ ,_ ,_ ,_ ,printf) (format printf (string-to-number value)))
        (_ (error "Invalid column specification format: %S" spec)))))
 
-(defun org-columns--collect-values (&optional compiled-fmt)
+(defun org-columns--collect-values (&optional compiled-fmt agenda-marker)
   "Collect values for columns on the current line.
 
 Return a list of triplets (SPEC VALUE DISPLAYED) suitable for
@@ -287,7 +287,11 @@ Return a list of triplets (SPEC VALUE DISPLAYED) suitable 
for
 
 This function assumes `org-columns-current-fmt-compiled' is
 initialized is set in the current buffer.  However, it is
-possible to override it with optional argument COMPILED-FMT."
+possible to override it with optional argument COMPILED-FMT.
+
+The optional argument AGENDA-MARKER is used when called from the
+agenda to pass a marker to the agenda line.
+"
   (let ((summaries (get-text-property (point) 'org-summaries)))
     (mapcar
      (lambda (spec)
@@ -300,9 +304,13 @@ possible to override it with optional argument 
COMPILED-FMT."
                             ;; to use appointment duration.
                             org-agenda-columns-add-appointments-to-effort-sum
                             (string= p (upcase org-effort-property))
-                            (get-text-property (point) 'duration)
+                            (get-text-property (marker-position agenda-marker)
+                                                'duration
+                                                (marker-buffer agenda-marker))
                             (propertize (org-duration-from-minutes
-                                         (get-text-property (point) 'duration))
+                                          (get-text-property (marker-position 
agenda-marker)
+                                                'duration
+                                                (marker-buffer agenda-marker)))
                                         'face 'org-warning))
                        "")))
            ;; A non-nil COMPILED-FMT means we're calling from Org
@@ -1758,8 +1766,9 @@ definition."
                          ;; agenda buffer.  Since current buffer is
                          ;; changing, we need to force the original
                          ;; compiled-fmt there.
-                         (org-with-point-at m
-                           (org-columns--collect-values compiled-fmt)))
+                          (let ((agenda-marker (point-marker)))
+                           (org-with-point-at m
+                             (org-columns--collect-values compiled-fmt 
agenda-marker)))
                    cache)))
          (forward-line))
        (when cache
-- 
2.46.0

-- 
Anand Deopurkar
Mathematical Sciences Institute
The Australian National University
Ngunnawal and Ngambri Country
Canberra ACT 2601 Australia

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]