emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Hard-coded and inconsistent todo states in org-agenda.el [9.7-pre (release_9.6.12-934-g4d72f3 @ /home/rst/Devel/org-mode/lisp/)]
@ 2023-12-10 17:10 Raffael Stocker
  2023-12-11 14:20 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Raffael Stocker @ 2023-12-10 17:10 UTC (permalink / raw)
  To: emacs-orgmode


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

Hi,

org-agenda.el contains the following hard-coded states in ‘org-agenda-to-appt’:

(when (and ok tod (not (string-match "\\`DONE\\|CANCELLED" evt)))...)

I find this confusing as the Org mode manual usually uses “CANCELED”,
with one ‘L’ instead of two.  I believe this should be corrected.  Of
course, ideally the function would take the terminal states from
‘org-todo-keywords’ instead.

Regards,

Raffael

Emacs  : GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8)
Package: Org mode version 9.7-pre (release_9.6.12-934-g4d72f3 @ /home/rst/Devel/org-mode/lisp/)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] Hard-coded and inconsistent todo states in org-agenda.el [9.7-pre (release_9.6.12-934-g4d72f3 @ /home/rst/Devel/org-mode/lisp/)]
  2023-12-10 17:10 [BUG] Hard-coded and inconsistent todo states in org-agenda.el [9.7-pre (release_9.6.12-934-g4d72f3 @ /home/rst/Devel/org-mode/lisp/)] Raffael Stocker
@ 2023-12-11 14:20 ` Ihor Radchenko
  2023-12-11 21:06   ` Raffael Stocker
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-12-11 14:20 UTC (permalink / raw)
  To: Raffael Stocker; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 285 bytes --]

Raffael Stocker <r.stocker@mnet-mail.de> writes:

> Hi,
>
> org-agenda.el contains the following hard-coded states in ‘org-agenda-to-appt’:
>
> (when (and ok tod (not (string-match "\\`DONE\\|CANCELLED" evt)))...)

Thanks for reporting!
May you try the attached patch?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda-to-appt-Do-not-hard-code-not-done-todo-ke.patch --]
[-- Type: text/x-patch, Size: 2073 bytes --]

From 6ffa23a01acad2d5cd37bafa11a57cf7a0c13cec Mon Sep 17 00:00:00 2001
Message-ID: <6ffa23a01acad2d5cd37bafa11a57cf7a0c13cec.1702304402.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Mon, 11 Dec 2023 15:17:41 +0100
Subject: [PATCH] org-agenda-to-appt: Do not hard-code not-done todo keywords

* lisp/org-agenda.el (org-agenda-to-appt): Use org-todo-regexp and
org-not-done-regexp to determine whether an even is already done.

Reported-by: Raffael Stocker <r.stocker@mnet-mail.de>
Link: https://orgmode.org/list/yplmsf4ac6va.fsf@mnet-mail.de
---
 lisp/org-agenda.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index ac8adda7a..6a9b1cc5a 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -11141,10 +11141,16 @@ (defun org-agenda-to-appt (&optional refresh filter &rest args)
                                       (string-match cat-filter cat))
                                  (and (stringp evt-filter)
                                       (string-match evt-filter evt)))))))
-              (wrn (get-text-property 1 'warntime x)))
+              (wrn (get-text-property 1 'warntime x))
+              (todo-regexp (get-text-property 1 'org-todo-regexp x))
+              (not-done-regexp (get-text-property 1 'org-not-done-regexp x)))
          ;; FIXME: Shall we remove text-properties for the appt text?
          ;; (setq evt (set-text-properties 0 (length evt) nil evt))
-         (when (and ok tod (not (string-match "\\`DONE\\|CANCELLED" evt)))
+         (when (and ok tod
+                    ;; Exclude done items unconditionally.
+                    (or (not (and todo-regexp (string-match-p todo-regexp evt))) ; no todo keyword
+                        (and not-done-regexp (string-match-p not-done-regexp evt)) ; or not done
+                        ))
            (setq tod (concat "00" (number-to-string tod)))
            (setq tod (when (string-match
                             "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)\\'" tod)
-- 
2.42.0


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
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 related	[flat|nested] 4+ messages in thread

* Re: [BUG] Hard-coded and inconsistent todo states in org-agenda.el [9.7-pre (release_9.6.12-934-g4d72f3 @ /home/rst/Devel/org-mode/lisp/)]
  2023-12-11 14:20 ` Ihor Radchenko
@ 2023-12-11 21:06   ` Raffael Stocker
  2023-12-12 11:56     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Raffael Stocker @ 2023-12-11 21:06 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


Ihor Radchenko <yantar92@posteo.net> writes:

> May you try the attached patch?

I tried it with a selection of different states (final and not) and it
worked in every case.  Thanks!

Regards,

Raffael


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] Hard-coded and inconsistent todo states in org-agenda.el [9.7-pre (release_9.6.12-934-g4d72f3 @ /home/rst/Devel/org-mode/lisp/)]
  2023-12-11 21:06   ` Raffael Stocker
@ 2023-12-12 11:56     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-12-12 11:56 UTC (permalink / raw)
  To: Raffael Stocker; +Cc: emacs-orgmode

Raffael Stocker <r.stocker@mnet-mail.de> writes:

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> May you try the attached patch?
>
> I tried it with a selection of different states (final and not) and it
> worked in every case.  Thanks!

Thanks for testing!
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7505055f5

-- 
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] 4+ messages in thread

end of thread, other threads:[~2023-12-12 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-10 17:10 [BUG] Hard-coded and inconsistent todo states in org-agenda.el [9.7-pre (release_9.6.12-934-g4d72f3 @ /home/rst/Devel/org-mode/lisp/)] Raffael Stocker
2023-12-11 14:20 ` Ihor Radchenko
2023-12-11 21:06   ` Raffael Stocker
2023-12-12 11:56     ` 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).