emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Morgan Smith <Morgan.J.Smith@outlook.com>
To: emacs-orgmode@gnu.org
Cc: Morgan Smith <Morgan.J.Smith@outlook.com>
Subject: [PATCH] Fix org-agenda-skip-scheduled-if-deadline-is-shown bug
Date: Sat, 30 Dec 2023 15:45:47 -0500	[thread overview]
Message-ID: <CH3PR84MB3424DDE4B98A0ACA7EE15EB1C59CA@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM> (raw)

lisp/org-agenda.el (org-agenda-get-scheduled): Consolidate deadline
fetching code.  Don't check if deadline is shown when
'org-agenda-skip-scheduled-if-deadline-is-shown' has a value of
'repeated-after-deadline'.

Currently when 'org-agenda-skip-scheduled-if-deadline-is-shown' has a
value of 'repeated-after-deadline' then there is no effect.  This is
because when 'org-agenda-get-scheduled' is run on later dates, the
previous deadlines are not put in 'deadline-pos'.
---
 lisp/org-agenda.el | 49 +++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index a1b2f3dc4..df1e8cb7d 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6606,25 +6606,26 @@ scheduled items with an hour specification like [h]h:mm."
 	          (futureschedp (> schedule today))
 	          (habitp (and (fboundp 'org-is-habit-p)
                                (string= "habit" (org-element-property :STYLE el))))
+                  (deadline (and (or org-agenda-skip-scheduled-delay-if-deadline
+                                     org-agenda-skip-scheduled-if-deadline-is-shown)
+                                 (when-let ((timestamp (org-element-property :deadline el)))
+                                   (time-to-days
+                                    (org-timestamp-to-time
+                                     timestamp)))))
 	          (suppress-delay
-		   (let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
-                                        (org-element-property
-                                         :raw-value
-                                         (org-element-property :deadline el)))))
-		     (cond
-		      ((not deadline) nil)
-		      ;; The current item has a deadline date, so
-		      ;; evaluate its delay time.
-		      ((integerp org-agenda-skip-scheduled-delay-if-deadline)
-		       ;; Use global delay time.
-		       (- org-agenda-skip-scheduled-delay-if-deadline))
-		      ((eq org-agenda-skip-scheduled-delay-if-deadline
-			   'post-deadline)
-		       ;; Set delay to no later than DEADLINE.
-		       (min (- schedule
-			       (org-agenda--timestamp-to-absolute deadline))
-			    org-scheduled-delay-days))
-		      (t 0))))
+                   (cond
+                    ((not (and deadline org-agenda-skip-scheduled-delay-if-deadline)) nil)
+                    ;; The current item has a deadline date, so
+                    ;; evaluate its delay time.
+                    ((integerp org-agenda-skip-scheduled-delay-if-deadline)
+                     ;; Use global delay time.
+                     (- org-agenda-skip-scheduled-delay-if-deadline))
+                    ((eq org-agenda-skip-scheduled-delay-if-deadline
+                         'post-deadline)
+                     ;; Set delay to no later than DEADLINE.
+                     (min (- schedule deadline)
+                          org-scheduled-delay-days))
+                    (t 0)))
 	          (ddays
 		   (cond
 		    ;; Nullify delay when a repeater triggered already
@@ -6661,16 +6662,14 @@ scheduled items with an hour specification like [h]h:mm."
 	     ;; doesn't apply to habits.
 	     (when (pcase org-agenda-skip-scheduled-if-deadline-is-shown
 		     ((guard
-		       (or (not (memq (line-beginning-position 0) deadline-pos))
+		       (or (not deadline)
 			   habitp))
 		      nil)
 		     (`repeated-after-deadline
-		      (let ((deadline (time-to-days
-                                       (when (org-element-property :deadline el)
-                                         (org-time-string-to-time
-                                          (org-element-interpret-data
-                                           (org-element-property :deadline el)))))))
-		        (and (<= schedule deadline) (> current deadline))))
+                      (and (<= schedule deadline) (> current deadline)))
+                     ((guard
+                       (not (memq (line-beginning-position 0) deadline-pos)))
+                      nil)
 		     (`not-today pastschedp)
 		     (`t t)
 		     (_ nil))
-- 
2.41.0



             reply	other threads:[~2023-12-30 20:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-30 20:45 Morgan Smith [this message]
2023-12-31 14:32 ` [PATCH] Fix org-agenda-skip-scheduled-if-deadline-is-shown bug Ihor Radchenko
2024-01-02 20:25   ` Morgan Smith
2024-01-03 15:29     ` Ihor Radchenko
2024-01-03 17:06       ` Morgan Smith
2024-01-04 14:04         ` Ihor Radchenko
2024-01-16 16:45           ` Morgan Smith
2024-01-16 18:52             ` Ihor Radchenko
2024-01-16 20:37               ` Morgan Smith
2024-01-17 13:10                 ` Ihor Radchenko
2024-02-07 12:27           ` Ihor Radchenko
2024-02-07 16:15             ` Bastien Guerry
2024-02-07 16:25               ` 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=CH3PR84MB3424DDE4B98A0ACA7EE15EB1C59CA@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM \
    --to=morgan.j.smith@outlook.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).