emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anand Deopurkar <anandrdeopurkar@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum
Date: Tue, 24 Sep 2024 09:23:46 +1000	[thread overview]
Message-ID: <87y13ij6nx.fsf@gmail.com> (raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1: 0001-lisp-org-colview.el-Bug-fix-for-add-appointments-to-.patch --]
[-- Type: text/x-patch, Size: 3843 bytes --]

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


[-- Attachment #1.2: Type: text/plain, Size: 153 bytes --]


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 231 bytes --]

             reply	other threads:[~2024-09-23 23:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23 23:23 Anand Deopurkar [this message]
2024-09-30  0:25 ` [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum Anand Deopurkar
2024-10-12  7:39   ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y13ij6nx.fsf@gmail.com \
    --to=anandrdeopurkar@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).