From: Tim Ruffing <crypto@timruffing.de>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-agenda: Make sure skipping warning/delay days never increases their number
Date: Tue, 13 Feb 2024 11:34:21 +0100 [thread overview]
Message-ID: <ba11484b45975fdd2cfb4167d1faf9b788f3e5cf.camel@timruffing.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 642 bytes --]
Hello,
The attached patch fixes the following bug:
* Have a scheduled item that has also has a deadline with a cusom
prewarning cookie, e.g. <... -3d>.
* Set `org-agenda-skip-deadline-prewarning-if-scheduled' to 7
Then in the agenda, the item is shown already 7 days before the
deadline (instead of 3). Judging from their name and documentation, the
"skip" variables `org-agenda-skip-deadline-prewarning-if-scheduled' and
`org-agenda-skip-scheduled-delay-if-deadline` should only ever skip
items in the agenda. In other words, they should only shorten the
prewarning or delay period, but never extend it.
Best,
Tim
[-- Attachment #2: 0001-org-agenda-Make-sure-skipping-warning-delay-days-nev.patch --]
[-- Type: text/x-patch, Size: 4490 bytes --]
From 5db0ac7115b86a12d1a2106eb54b07d339f69ed6 Mon Sep 17 00:00:00 2001
From: Tim Ruffing <crypto@timruffing.de>
Date: Tue, 13 Feb 2024 10:57:29 +0100
Subject: [PATCH] org-agenda: Make sure skipping warning/delay days never
increases their number
* lisp/org-agenda.el (org-agenda-get-deadlines, org-agenda-get-scheduled):
Use minimum of warning/delay days specified in timestamp cookie and the
limit specified by `org-agenda-skip-deadline-prewarning-if-scheduled' or
`org-agenda-skip-scheduled-delay-if-deadline`, respectively.
* lisp/org.el (org-get-wdays): Remove unused (and confusing) ZERO-DELAY
argument.
---
lisp/org-agenda.el | 15 ++++++---------
lisp/org.el | 7 ++-----
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 514359b62..53878e441 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6399,14 +6399,14 @@ specification like [h]h:mm."
(org-agenda--timestamp-to-absolute
s base 'future (current-buffer) pos)))))
(diff (- deadline current))
- (suppress-prewarning
+ (max-wdays
(let ((scheduled
(and org-agenda-skip-deadline-prewarning-if-scheduled
(org-element-property
:raw-value
(org-element-property :scheduled el)))))
(cond
- ((not scheduled) nil)
+ ((not scheduled) most-positive-fixnum)
;; The current item has a scheduled date, so
;; evaluate its prewarning lead time.
((integerp org-agenda-skip-deadline-prewarning-if-scheduled)
@@ -6420,7 +6420,7 @@ specification like [h]h:mm."
org-deadline-warning-days))
;; Set pre-warning to deadline.
(t 0))))
- (wdays (or suppress-prewarning (org-get-wdays s))))
+ (wdays (min max-wdays (org-get-wdays s))))
(cond
;; Only display deadlines at their base date, at future
;; repeat occurrences or in today agenda.
@@ -6610,13 +6610,13 @@ 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))))
- (suppress-delay
+ (max-ddays
(let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
(org-element-property
:raw-value
(org-element-property :deadline el)))))
(cond
- ((not deadline) nil)
+ ((not deadline) most-positive-fixnum)
;; The current item has a deadline date, so
;; evaluate its delay time.
((integerp org-agenda-skip-scheduled-delay-if-deadline)
@@ -6636,10 +6636,7 @@ scheduled items with an hour specification like [h]h:mm."
((and (string-match-p "--[0-9]+[hdwmy]" s)
(> schedule (org-agenda--timestamp-to-absolute s)))
0)
- (suppress-delay
- (let ((org-scheduled-delay-days suppress-delay))
- (org-get-wdays s t t)))
- (t (org-get-wdays s t)))))
+ (t (min max-ddays (org-get-wdays s t))))))
;; Display scheduled items at base date (SCHEDULE), today if
;; scheduled before the current date, and at any repeat past
;; today. However, skip delayed items and items that have
diff --git a/lisp/org.el b/lisp/org.el
index 7da23310d..75f062508 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14454,17 +14454,14 @@ If SECONDS is non-nil, return the difference in seconds."
(and (<= (org-timestamp-to-now timestamp-string) ndays)
(not (org-entry-is-done-p))))
-(defun org-get-wdays (ts &optional delay zero-delay)
+(defun org-get-wdays (ts &optional delay)
"Get the deadline lead time appropriate for timestring TS.
When DELAY is non-nil, get the delay time for scheduled items
-instead of the deadline lead time. When ZERO-DELAY is non-nil
-and `org-scheduled-delay-days' is 0, enforce 0 as the delay,
-don't try to find the delay cookie in the scheduled timestamp."
+instead of the deadline lead time."
(let ((tv (if delay org-scheduled-delay-days
org-deadline-warning-days)))
(cond
((or (and delay (< tv 0))
- (and delay zero-delay (<= tv 0))
(and (not delay) (<= tv 0)))
;; Enforce this value no matter what
(- tv))
--
2.43.1
next reply other threads:[~2024-02-13 10:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 10:34 Tim Ruffing [this message]
2024-02-13 14:24 ` [PATCH] org-agenda: Make sure skipping warning/delay days never increases their number Ihor Radchenko
2024-02-13 15:58 ` Tim Ruffing
2024-02-14 14:20 ` Ihor Radchenko
2024-02-26 14:07 ` Tim Ruffing
2024-02-27 12:49 ` Ihor Radchenko
2024-02-27 22:26 ` Tim Ruffing
2024-02-28 11:56 ` Ihor Radchenko
2024-02-28 12:33 ` Bastien Guerry
2024-02-28 13:18 ` 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=ba11484b45975fdd2cfb4167d1faf9b788f3e5cf.camel@timruffing.de \
--to=crypto@timruffing.de \
--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).