* [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum
@ 2024-09-23 23:23 Anand Deopurkar
2024-09-30 0:25 ` Anand Deopurkar
0 siblings, 1 reply; 3+ messages in thread
From: Anand Deopurkar @ 2024-09-23 23:23 UTC (permalink / raw)
To: emacs-orgmode
[-- 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 --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum
2024-09-23 23:23 [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum Anand Deopurkar
@ 2024-09-30 0:25 ` Anand Deopurkar
2024-10-12 7:39 ` Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: Anand Deopurkar @ 2024-09-30 0:25 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 127 bytes --]
The previous patch contained unmatched parentheses. Sincere apologies. I am attaching a corrected patch.
Best,
Anand
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-lisp-org-colview.el-Bug-fix-for-add-appointments-to-.patch --]
[-- Type: text/x-patch, Size: 3844 bytes --]
From 7dd9ee45b1ed02de7921efa5c6c2a1c993a1c6ac Mon Sep 17 00:00:00 2001
From: Anand Deopurkar <anandrdeopurkar@gmail.com>
Date: Mon, 30 Sep 2024 10:13:59 +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..f58dc1674 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 231 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum
2024-09-30 0:25 ` Anand Deopurkar
@ 2024-10-12 7:39 ` Ihor Radchenko
0 siblings, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2024-10-12 7:39 UTC (permalink / raw)
To: Anand Deopurkar; +Cc: emacs-orgmode
Anand Deopurkar <anandrdeopurkar@gmail.com> writes:
> 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
Thanks!
Applied, onto main, with minor edits to the code and the commit message.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e2823be9da
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-12 7:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23 23:23 [PATCH] lisp/org-colview.el: Fix for adding appointments to effort sum Anand Deopurkar
2024-09-30 0:25 ` Anand Deopurkar
2024-10-12 7:39 ` Ihor Radchenko
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).