all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix org-agenda-skip-scheduled-if-deadline-is-shown bug
@ 2023-12-30 20:45 Morgan Smith
  2023-12-31 14:32 ` Ihor Radchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Morgan Smith @ 2023-12-30 20:45 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Morgan Smith

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



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

end of thread, other threads:[~2024-02-07 16:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-30 20:45 [PATCH] Fix org-agenda-skip-scheduled-if-deadline-is-shown bug Morgan Smith
2023-12-31 14:32 ` 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.