emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
@ 2023-09-19  8:09 Carlo Tambuatco
  2023-09-19  9:20 ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Carlo Tambuatco @ 2023-09-19  8:09 UTC (permalink / raw)
  To: Org-Mode Mailing List

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

When I create an agenda item that is scheduled for say:
* TODO Item
  SCHEDULED: <2023-09-19 Tue>

then I set a deadline for that item
* TODO Item
   SCHEDULED: <2023-09-19 Tue> DEADLINE: <2023-10-03 Tue>

notice the deadline for the item is two weeks from the scheduled date,

I get this error:

Debugger entered--Lisp error: (wrong-type-argument stringp (timestamp
(:type active :raw-value "<2023-10-03 Tue>" :year-start 2023 :month-start
10 :day-start 3 :hour-start nil :minute-start nil :year-end 2023 :month-end
10 :day-end 3 :hour-end nil :minute-end nil :begin 115 :end 132 :post-blank
1)))

string-match("\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\(
+..." (timestamp (:type active :raw-value "<2023-10-03 Tue>" :year-start
2023 :month-start 10 :day-start 3 :hour-start nil :minute-start nil
:year-end 2023 :month-end 10 :day-end 3 :hour-end nil :minute-end nil
:begin 115 :end 132 :post-blank 1)))
  org-parse-time-string((timestamp (:type active :raw-value "<2023-10-03
Tue>" :year-start 2023 :month-start 10 :day-start 3 :hour-start nil
:minute-start nil :year-end 2023 :month-end 10 :day-end 3 :hour-end nil
:minute-end nil :begin 115 :end 132 :post-blank 1)))
  org-time-string-to-time((timestamp (:type active :raw-value "<2023-10-03
Tue>" :year-start 2023 :month-start 10 :day-start 3 :hour-start nil
:minute-start nil :year-end 2023 :month-end 10 :day-end 3 :hour-end nil
:minute-end nil :begin 115 :end 132 :post-blank 1)))
  #f(compiled-function (el) #<bytecode 0x1678a316b7f7957e>)((headline
(:raw-value "Today's Dentist" :begin 80 :end 162 :pre-blank 0
:contents-begin 105 :contents-end 160 :robust-begin nil :robust-end nil
:level 2 :priority nil :tags nil :todo-keyword #("TODO" 0 4 (wrap-prefix
#("*** " 0 4 (face org-indent)) line-prefix #("*" 0 1 (face org-indent))
face ((:foreground "#FFAAAA") org-level-2) fontified t)) :todo-type todo
:post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil
:post-affiliated 80 :deadline (timestamp (:type active :raw-value
"<2023-10-03 Tue>" :year-start 2023 :month-start 10 :day-start 3
:hour-start nil :minute-start nil :year-end 2023 :month-end 10 :day-end 3
:hour-end nil :minute-end nil :begin 115 :end 132 :post-blank 1))
:scheduled (timestamp (:type active :raw-value "<2023-09-19 Tue>"
:year-start 2023 :month-start 9 :day-start 19 :hour-start nil :minute-start
nil :year-end 2023 :month-end 9 :day-end 19 :hour-end nil :minute-end nil
:begin 143 :end 159 :post-blank 0)) :title (#("Today's Dentist" 0 15
(:parent (headline #3)))) :parent (headline (:raw-value "Appointments"
:begin 1 :end 162 :pre-blank 1 :contents-begin 80 :contents-end 160
:robust-begin 82 :robust-end 158 :level 1 :priority nil :tags
(#("@appointment" 0 12 (fontified t face ... mouse-face highlight keymap
... line-prefix "" wrap-prefix ...))) :todo-keyword nil :todo-type nil
:post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil
:post-affiliated 1 :title (#("Appointments" 0 12 (:parent ...))) :parent
(org-data (:begin 1 :contents-begin 1 :contents-end 160 :end 162
:robust-begin 3 :robust-end 158 :post-blank 2 :post-affiliated 1 :path
"/Users/carloftambuatco/Documents/Org/Personal/Appo..." :mode org-data
:CATEGORY "Appointments" :parent nil :cached t :org-element--cache-sync-key
nil)) :cached t :org-element--cache-sync-key nil)) :cached t
:org-element--cache-sync-key nil)))
  org-element-cache-map(#f(compiled-function (el) #<bytecode
0x1678a316b7f7957e>) :next-re "\\<SCHEDULED: *<\\([^>]+\\)>" :fail-re
"\\<SCHEDULED: *<\\([^>]+\\)>" :narrow t)
  org-agenda-get-scheduled((#("  Appointments:In  14 d.:  TODO Today'..." 0
27 (done-face org-agenda-done undone-face org-upcoming-distant-deadline
face org-upcoming-distant-deadline date (9 19 2023) type
"upcoming-deadline" todo-state #("TODO" 0 4 (wrap-prefix ... line-prefix
... face ... fontified t)) priority 4986 ts-date 738796 effort-minutes nil
effort nil warntime nil org-hd-marker #<marker (moves after insertion) at
80 in Appointments.org> org-marker #<marker (moves after insertion) at 115
in Appointments.org> help-echo "mouse-2 or RET jump to org file ~/Docu..."
org-complex-heading-regexp "^\\(\\*+\\)\\(?:
+\\(CANCELLED\\|DONE\\|FAIL\\..." org-todo-regexp
"\\(CANCELLED\\|DONE\\|FAIL\\|IN_PROGRESS\\|..." org-not-done-regexp
"\\(IN_PROGRESS\\|T\\(?:EST\\(?:ING\\)?\\|ODO..." mouse-face highlight
dotime nil ...) 27 62 (done-face org-agenda-done undone-face
org-upcoming-distant-deadline face org-upcoming-distant-deadline date (9 19
2023) type "upcoming-deadline" todo-state #("TODO" 0 4 (wrap-prefix ...
line-prefix ... face ... fontified t)) priority 4986 ts-date 738796
warntime nil org-hd-marker #<marker (moves after insertion) at 80 in
Appointments.org> org-marker #<marker (moves after insertion) at 115 in
Appointments.org> help-echo "mouse-2 or RET jump to org file ~/Docu..."
org-complex-heading-regexp "^\\(\\*+\\)\\(?:
+\\(CANCELLED\\|DONE\\|FAIL\\..." org-todo-regexp
"\\(CANCELLED\\|DONE\\|FAIL\\|IN_PROGRESS\\|..." org-not-done-regexp
"\\(IN_PROGRESS\\|T\\(?:EST\\(?:ING\\)?\\|ODO..." mouse-face highlight
dotime nil format ((... ... ... ... ...) (format " %s %s%s%s" ... ... ...
...)) extra "In  14 d.: " ...) 62 74 (done-face org-agenda-done undone-face
org-upcoming-distant-deadline date (9 19 2023) type "upcoming-deadline"
todo-state #("TODO" 0 4 (wrap-prefix ... line-prefix ... face ... fontified
t)) priority 4986 ts-date 738796 effort-minutes nil effort nil warntime nil
org-hd-marker #<marker (moves after insertion) at 80 in Appointments.org>
org-marker #<marker (moves after insertion) at 115 in Appointments.org>
help-echo "mouse-2 or RET jump to org file ~/Docu..."
org-complex-heading-regexp "^\\(\\*+\\)\\(?:
+\\(CANCELLED\\|DONE\\|FAIL\\..." org-todo-regexp
"\\(CANCELLED\\|DONE\\|FAIL\\|IN_PROGRESS\\|..." org-not-done-regexp
"\\(IN_PROGRESS\\|T\\(?:EST\\(?:ING\\)?\\|ODO..." dotime nil format ((...
... ... ... ...) (format " %s %s%s%s" ... ... ... ...)) extra "In  14 d.: "
...) 74 76 (done-face org-agenda-done undone-face
org-upcoming-distant-deadline face org-upcoming-distant-deadline date (9 19
2023) type "upcoming-deadline" todo-state #("TODO" 0 4 (wrap-prefix ...
line-prefix ... face ... fontified t)) priority 4986 ts-date 738796
effort-minutes nil effort nil warntime nil org-hd-marker #<marker (moves
after insertion) at 80 in Appointments.org> org-marker #<marker (moves
after insertion) at 115 in Appointments.org> help-echo "mouse-2 or RET jump
to org file ~/Docu..." org-complex-heading-regexp "^\\(\\*+\\)\\(?:
+\\(CANCELLED\\|DONE\\|FAIL\\..." org-todo-regexp
"\\(CANCELLED\\|DONE\\|FAIL\\|IN_PROGRESS\\|..." org-not-done-regexp
"\\(IN_PROGRESS\\|T\\(?:EST\\(?:ING\\)?\\|ODO..." mouse-face highlight
dotime nil ...))))

org-agenda-get-day-entries("/Users/carloftambuatco/Documents/Org/Personal/Appo..."
(9 19 2023) :deadline :scheduled :timestamp :sexp)
  apply(org-agenda-get-day-entries
"/Users/carloftambuatco/Documents/Org/Personal/Appo..." (9 19 2023)
(:deadline :scheduled :timestamp :sexp))
  org-agenda-list(nil)
  funcall-interactively(org-agenda-list nil)
  call-interactively(org-agenda-list nil nil)
  command-execute(org-agenda-list)

Then when I set the deadline to more than 14 days from the scheduled date:

* TODO Item
   SCHEDULED: <2023-09-19 Tue> DEADLINE: <2023-10-04 Wed>

Agenda works as normal.
When org agenda is in deadline display mode, I notice it
displays deadlines that are within 2 weeks of the current date.
This seems to be some kind of hard coded error.

[-- Attachment #2: Type: text/html, Size: 8572 bytes --]

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

* Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
  2023-09-19  8:09 Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time Carlo Tambuatco
@ 2023-09-19  9:20 ` Ihor Radchenko
  2023-09-19  9:46   ` Carlo Tambuatco
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2023-09-19  9:20 UTC (permalink / raw)
  To: Carlo Tambuatco; +Cc: Org-Mode Mailing List

Carlo Tambuatco <oraclmaster@gmail.com> writes:

> then I set a deadline for that item
> * TODO Item
>    SCHEDULED: <2023-09-19 Tue> DEADLINE: <2023-10-03 Tue>
>
> notice the deadline for the item is two weeks from the scheduled date,
>
> I get this error:
>
> Debugger entered--Lisp error: (wrong-type-argument stringp (timestamp
> (:type active :raw-value "<2023-10-03 Tue>" :year-start 2023 :month-start
> 10 :day-start 3 :hour-start nil :minute-start nil :year-end 2023 :month-end
> 10 :day-end 3 :hour-end nil :minute-end nil :begin 115 :end 132 :post-blank
> 1)))

Thanks for reporting!
I think I fixed the problem on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c61ec6255

May you please confirm?

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

* Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
  2023-09-19  9:20 ` Ihor Radchenko
@ 2023-09-19  9:46   ` Carlo Tambuatco
  2023-09-19  9:52     ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Carlo Tambuatco @ 2023-09-19  9:46 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org-Mode Mailing List

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

I'm unfamiliar with how to apply patches to my org install. What do I do?

On Tue, Sep 19, 2023 at 5:19 AM Ihor Radchenko <yantar92@posteo.net> wrote:

> Carlo Tambuatco <oraclmaster@gmail.com> writes:
>
> > then I set a deadline for that item
> > * TODO Item
> >    SCHEDULED: <2023-09-19 Tue> DEADLINE: <2023-10-03 Tue>
> >
> > notice the deadline for the item is two weeks from the scheduled date,
> >
> > I get this error:
> >
> > Debugger entered--Lisp error: (wrong-type-argument stringp (timestamp
> > (:type active :raw-value "<2023-10-03 Tue>" :year-start 2023 :month-start
> > 10 :day-start 3 :hour-start nil :minute-start nil :year-end 2023
> :month-end
> > 10 :day-end 3 :hour-end nil :minute-end nil :begin 115 :end 132
> :post-blank
> > 1)))
>
> Thanks for reporting!
> I think I fixed the problem on bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c61ec6255
>
> May you please confirm?
>
> --
> 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>
>

[-- Attachment #2: Type: text/html, Size: 2030 bytes --]

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

* Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
  2023-09-19  9:46   ` Carlo Tambuatco
@ 2023-09-19  9:52     ` Ihor Radchenko
  2023-09-19 10:03       ` Carlo Tambuatco
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2023-09-19  9:52 UTC (permalink / raw)
  To: Carlo Tambuatco; +Cc: Org-Mode Mailing List

Carlo Tambuatco <oraclmaster@gmail.com> writes:

> I'm unfamiliar with how to apply patches to my org install. What do I do?

May you then first tell me the output of M-x org-version?

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

* Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
  2023-09-19  9:52     ` Ihor Radchenko
@ 2023-09-19 10:03       ` Carlo Tambuatco
  2023-09-19 10:10         ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Carlo Tambuatco @ 2023-09-19 10:03 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org-Mode Mailing List

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

org-version 9.6.9

On Tue, Sep 19, 2023 at 5:51 AM Ihor Radchenko <yantar92@posteo.net> wrote:

> Carlo Tambuatco <oraclmaster@gmail.com> writes:
>
> > I'm unfamiliar with how to apply patches to my org install. What do I do?
>
> May you then first tell me the output of M-x org-version?
>
> --
> 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>
>

[-- Attachment #2: Type: text/html, Size: 1159 bytes --]

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

* Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
  2023-09-19 10:03       ` Carlo Tambuatco
@ 2023-09-19 10:10         ` Ihor Radchenko
  2023-09-19 10:17           ` Carlo Tambuatco
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2023-09-19 10:10 UTC (permalink / raw)
  To: Carlo Tambuatco; +Cc: Org-Mode Mailing List

Carlo Tambuatco <oraclmaster@gmail.com> writes:

> org-version 9.6.9

Then, (1) open agenda as usual, get the error; (2) re-define
`org-agenda-get-scheduled' by evaluating the following snippet (C-M-x
with point inside defun in scratch buffer); (3) open agenda again - you
should not get the error.

(defun org-agenda-get-scheduled (&optional deadlines with-hour)
  "Return the scheduled information for agenda display.
Optional argument DEADLINES is a list of deadline items to be
displayed in agenda view.  When WITH-HOUR is non-nil, only return
scheduled items with an hour specification like [h]h:mm."
  (with-no-warnings (defvar date))
  (let* ((props (list 'org-not-done-regexp org-not-done-regexp
		      'org-todo-regexp org-todo-regexp
		      'org-complex-heading-regexp org-complex-heading-regexp
		      'done-face 'org-agenda-done
		      'mouse-face 'highlight
		      'help-echo
		      (format "mouse-2 or RET jump to Org file %s"
			      (abbreviate-file-name buffer-file-name))))
	 (regexp (if with-hour
		     org-scheduled-time-hour-regexp
		   org-scheduled-time-regexp))
	 (today (org-today))
	 (todayp (org-agenda-today-p date)) ; DATE bound by calendar.
	 (current (calendar-absolute-from-gregorian date))
	 (deadline-pos
	  (mapcar (lambda (d)
		    (let ((m (get-text-property 0 'org-hd-marker d)))
		      (and m (marker-position m))))
		  deadlines))
	 scheduled-items)
    (goto-char (point-min))
    (if (org-element--cache-active-p)
        (org-element-cache-map
         (lambda (el)
           (when (and (org-element-property :scheduled el)
                      (or (not with-hour)
                          (org-element-property
                           :hour-start
                           (org-element-property :scheduled el))
                          (org-element-property
                           :hour-end
                           (org-element-property :scheduled el))))
             (goto-char (org-element-property :contents-begin el))
             (catch :skip
               (org-agenda-skip el)
               (let* ((s (substring (org-element-property
                                     :raw-value
                                     (org-element-property :scheduled el))
                                    1 -1))
                      (pos (save-excursion
                             (goto-char (org-element-property :contents-begin el))
                             ;; We intentionally leave NOERROR
                             ;; argument in `re-search-forward' nil.  If
                             ;; the search fails here, something went
                             ;; wrong and we are looking at
                             ;; non-matching headline.
                             (re-search-forward regexp (line-end-position))
                             (1- (match-beginning 1))))
                      (todo-state (org-element-property :todo-keyword el))
	              (donep (eq 'done (org-element-property :todo-type el)))
	              (sexp? (eq 'diary
                                 (org-element-property
                                  :type (org-element-property :scheduled el))))
	              ;; SCHEDULE is the scheduled date for the entry.  It is
	              ;; either the bare date or the last repeat, according
	              ;; to `org-agenda-prefer-last-repeat'.
	              (schedule
		       (cond
		        (sexp? (org-agenda--timestamp-to-absolute s current))
		        ((or (eq org-agenda-prefer-last-repeat t)
		             (member todo-state org-agenda-prefer-last-repeat))
		         (org-agenda--timestamp-to-absolute
		          s today 'past (current-buffer) pos))
		        (t (org-agenda--timestamp-to-absolute s))))
	              ;; REPEAT is the future repeat closest from CURRENT,
	              ;; according to `org-agenda-show-future-repeats'. If
	              ;; the latter is nil, or if the time stamp has no
	              ;; repeat part, default to SCHEDULE.
	              (repeat
		       (cond
		        (sexp? schedule)
		        ((<= current today) schedule)
		        ((not org-agenda-show-future-repeats) schedule)
		        (t
		         (let ((base (if (eq org-agenda-show-future-repeats 'next)
				         (1+ today)
				       current)))
		           (org-agenda--timestamp-to-absolute
		            s base 'future (current-buffer) pos)))))
	              (diff (- current schedule))
	              (warntime (get-text-property (point) 'org-appt-warntime))
	              (pastschedp (< schedule today))
	              (futureschedp (> schedule today))
	              (habitp (and (fboundp 'org-is-habit-p)
                                   (string= "habit" (org-element-property :STYLE el))))
	              (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))))
	              (ddays
		       (cond
		        ;; Nullify delay when a repeater triggered already
		        ;; and the delay is of the form --Xd.
		        ((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)))))
	         ;; 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
	         ;; been displayed for more than `org-scheduled-past-days'.
	         (unless (and todayp
		              habitp
		              (bound-and-true-p org-habit-show-all-today))
	           (when (or (and (> ddays 0) (< diff ddays))
		             (> diff (or (and habitp org-habit-scheduled-past-days)
				         org-scheduled-past-days))
		             (> schedule current)
		             (and (/= current schedule)
			          (/= current today)
			          (/= current repeat)))
	             (throw :skip nil)))
	         ;; Possibly skip done tasks.
	         (when (and donep
		            (or org-agenda-skip-scheduled-if-done
			        (/= schedule current)))
	           (throw :skip nil))
	         ;; Skip entry if it already appears as a deadline, per
	         ;; `org-agenda-skip-scheduled-if-deadline-is-shown'.  This
	         ;; 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))
			       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))))
		         (`not-today pastschedp)
		         (`t t)
		         (_ nil))
	           (throw :skip nil))
	         ;; Skip habits if `org-habit-show-habits' is nil, or if we
	         ;; only show them for today.  Also skip done habits.
	         (when (and habitp
		            (or donep
			        (not (bound-and-true-p org-habit-show-habits))
			        (and (not todayp)
			             (bound-and-true-p
			              org-habit-show-habits-only-for-today))))
	           (throw :skip nil))
	         (save-excursion
                   (goto-char (org-element-property :begin el))
	           (let* ((category (org-get-category))
                          (effort (save-match-data
                                    (or (get-text-property (point) 'effort)
                                        (org-element-property (intern (concat ":" (upcase org-effort-property))) el))))
                          (effort-minutes (when effort (save-match-data (org-duration-to-minutes effort))))
		          (inherited-tags
		           (or (eq org-agenda-show-inherited-tags 'always)
			       (and (listp org-agenda-show-inherited-tags)
			            (memq 'agenda org-agenda-show-inherited-tags))
			       (and (eq org-agenda-show-inherited-tags t)
			            (or (eq org-agenda-use-tag-inheritance t)
				        (memq 'agenda
				              org-agenda-use-tag-inheritance)))))
		          (tags (org-get-tags el (not inherited-tags)))
		          (level (make-string (org-element-property :level el)
				              ?\s))
		          (head (save-excursion
                                  (goto-char (org-element-property :begin el))
                                  (re-search-forward org-outline-regexp-bol)
                                  (buffer-substring (point) (line-end-position))))
		          (time
		           (cond
		            ;; No time of day designation if it is only a
		            ;; reminder, except for habits, which always show
		            ;; the time of day.  Habits are an exception
		            ;; because if there is a time of day, that is
		            ;; interpreted to mean they should usually happen
		            ;; then, even if doing the habit was missed.
		            ((and
		              (not habitp)
		              (/= current schedule)
		              (/= current repeat))
		             nil)
		            ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
		             (concat (substring s (match-beginning 1)) " "))
		            (t 'time)))
		          (item
		           (org-agenda-format-item
		            (pcase-let ((`(,first ,past) org-agenda-scheduled-leaders))
		              ;; Show a reminder of a past scheduled today.
		              (if (and todayp pastschedp)
			          (format past diff)
			        first))
		            (org-add-props head nil
                              'effort effort
                              'effort-minutes effort-minutes)
                            level category tags time nil habitp))
		          (face (cond ((and (not habitp) pastschedp)
				       'org-scheduled-previously)
			              ((and habitp futureschedp)
				       'org-agenda-done)
			              (todayp 'org-scheduled-today)
			              (t 'org-scheduled)))
		          (habitp (and habitp (org-habit-parse-todo (org-element-property :begin el)))))
	             (org-add-props item props
		       'undone-face face
		       'face (if donep 'org-agenda-done face)
		       'org-marker (org-agenda-new-marker pos)
		       'org-hd-marker (org-agenda-new-marker (line-beginning-position))
		       'type (if pastschedp "past-scheduled" "scheduled")
		       'date (if pastschedp schedule date)
		       'ts-date schedule
		       'warntime warntime
		       'level level
                       'effort effort 'effort-minutes effort-minutes
		       'priority (if habitp (org-habit-get-priority habitp)
			           (+ 99 diff (org-get-priority item)))
		       'org-habit-p habitp
		       'todo-state todo-state)
	             (push item scheduled-items)))))))
         :next-re regexp
         :fail-re regexp
         :narrow t)
      (while (re-search-forward regexp nil t)
        (catch :skip
	  (unless (save-match-data (org-at-planning-p)) (throw :skip nil))
	  (org-agenda-skip)
	  (let* ((s (match-string 1))
	         (pos (1- (match-beginning 1)))
	         (todo-state (save-match-data (org-get-todo-state)))
	         (donep (member todo-state org-done-keywords))
	         (sexp? (string-prefix-p "%%" s))
	         ;; SCHEDULE is the scheduled date for the entry.  It is
	         ;; either the bare date or the last repeat, according
	         ;; to `org-agenda-prefer-last-repeat'.
	         (schedule
		  (cond
		   (sexp? (org-agenda--timestamp-to-absolute s current))
		   ((or (eq org-agenda-prefer-last-repeat t)
		        (member todo-state org-agenda-prefer-last-repeat))
		    (org-agenda--timestamp-to-absolute
		     s today 'past (current-buffer) pos))
		   (t (org-agenda--timestamp-to-absolute s))))
	         ;; REPEAT is the future repeat closest from CURRENT,
	         ;; according to `org-agenda-show-future-repeats'. If
	         ;; the latter is nil, or if the time stamp has no
	         ;; repeat part, default to SCHEDULE.
	         (repeat
		  (cond
		   (sexp? schedule)
		   ((<= current today) schedule)
		   ((not org-agenda-show-future-repeats) schedule)
		   (t
		    (let ((base (if (eq org-agenda-show-future-repeats 'next)
				    (1+ today)
				  current)))
		      (org-agenda--timestamp-to-absolute
		       s base 'future (current-buffer) pos)))))
	         (diff (- current schedule))
	         (warntime (get-text-property (point) 'org-appt-warntime))
	         (pastschedp (< schedule today))
	         (futureschedp (> schedule today))
	         (habitp (and (fboundp 'org-is-habit-p) (org-is-habit-p)))
	         (suppress-delay
		  (let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
				       (org-entry-get nil "DEADLINE"))))
		    (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))))
	         (ddays
		  (cond
		   ;; Nullify delay when a repeater triggered already
		   ;; and the delay is of the form --Xd.
		   ((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)))))
	    ;; 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
	    ;; been displayed for more than `org-scheduled-past-days'.
	    (unless (and todayp
		         habitp
		         (bound-and-true-p org-habit-show-all-today))
	      (when (or (and (> ddays 0) (< diff ddays))
		        (> diff (or (and habitp org-habit-scheduled-past-days)
				    org-scheduled-past-days))
		        (> schedule current)
		        (and (/= current schedule)
			     (/= current today)
			     (/= current repeat)))
	        (throw :skip nil)))
	    ;; Possibly skip done tasks.
	    (when (and donep
		       (or org-agenda-skip-scheduled-if-done
			   (/= schedule current)))
	      (throw :skip nil))
	    ;; Skip entry if it already appears as a deadline, per
	    ;; `org-agenda-skip-scheduled-if-deadline-is-shown'.  This
	    ;; 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))
			  habitp))
		     nil)
		    (`repeated-after-deadline
		     (let ((deadline (time-to-days
				      (org-get-deadline-time (point)))))
		       (and (<= schedule deadline) (> current deadline))))
		    (`not-today pastschedp)
		    (`t t)
		    (_ nil))
	      (throw :skip nil))
	    ;; Skip habits if `org-habit-show-habits' is nil, or if we
	    ;; only show them for today.  Also skip done habits.
	    (when (and habitp
		       (or donep
			   (not (bound-and-true-p org-habit-show-habits))
			   (and (not todayp)
			        (bound-and-true-p
			         org-habit-show-habits-only-for-today))))
	      (throw :skip nil))
	    (save-excursion
	      (re-search-backward "^\\*+[ \t]+" nil t)
	      (goto-char (match-end 0))
	      (let* ((category (org-get-category))
                     (effort (save-match-data (or (get-text-property (point) 'effort)
                                                  (org-entry-get (point) org-effort-property))))
                     (effort-minutes (when effort (save-match-data (org-duration-to-minutes effort))))
		     (inherited-tags
		      (or (eq org-agenda-show-inherited-tags 'always)
			  (and (listp org-agenda-show-inherited-tags)
			       (memq 'agenda org-agenda-show-inherited-tags))
			  (and (eq org-agenda-show-inherited-tags t)
			       (or (eq org-agenda-use-tag-inheritance t)
				   (memq 'agenda
				         org-agenda-use-tag-inheritance)))))
		     (tags (org-get-tags nil (not inherited-tags)))
		     (level (make-string (org-reduced-level (org-outline-level))
				         ?\s))
		     (head (buffer-substring (point) (line-end-position)))
		     (time
		      (cond
		       ;; No time of day designation if it is only a
		       ;; reminder, except for habits, which always show
		       ;; the time of day.  Habits are an exception
		       ;; because if there is a time of day, that is
		       ;; interpreted to mean they should usually happen
		       ;; then, even if doing the habit was missed.
		       ((and
		         (not habitp)
		         (/= current schedule)
		         (/= current repeat))
		        nil)
		       ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
		        (concat (substring s (match-beginning 1)) " "))
		       (t 'time)))
		     (item
		      (org-agenda-format-item
		       (pcase-let ((`(,first ,past) org-agenda-scheduled-leaders))
		         ;; Show a reminder of a past scheduled today.
		         (if (and todayp pastschedp)
			     (format past diff)
			   first))
		       (org-add-props head nil
                         'effort effort
                         'effort-minutes effort-minutes)
                       level category tags time nil habitp))
		     (face (cond ((and (not habitp) pastschedp)
				  'org-scheduled-previously)
			         ((and habitp futureschedp)
				  'org-agenda-done)
			         (todayp 'org-scheduled-today)
			         (t 'org-scheduled)))
		     (habitp (and habitp (org-habit-parse-todo))))
	        (org-add-props item props
		  'undone-face face
		  'face (if donep 'org-agenda-done face)
		  'org-marker (org-agenda-new-marker pos)
		  'org-hd-marker (org-agenda-new-marker (line-beginning-position))
		  'type (if pastschedp "past-scheduled" "scheduled")
		  'date (if pastschedp schedule date)
		  'ts-date schedule
		  'warntime warntime
		  'level level
                  'effort effort 'effort-minutes effort-minutes
		  'priority (if habitp (org-habit-get-priority habitp)
			      (+ 99 diff (org-get-priority item)))
		  'org-habit-p habitp
		  'todo-state todo-state)
	        (push item scheduled-items)))))))
    (nreverse scheduled-items)))

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

* Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
  2023-09-19 10:10         ` Ihor Radchenko
@ 2023-09-19 10:17           ` Carlo Tambuatco
  2023-09-19 10:52             ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Carlo Tambuatco @ 2023-09-19 10:17 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org-Mode Mailing List

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

Okay. It does indeed work. When will it be available in general release?

On Tue, Sep 19, 2023 at 6:09 AM Ihor Radchenko <yantar92@posteo.net> wrote:

> Carlo Tambuatco <oraclmaster@gmail.com> writes:
>
> > org-version 9.6.9
>
> Then, (1) open agenda as usual, get the error; (2) re-define
> `org-agenda-get-scheduled' by evaluating the following snippet (C-M-x
> with point inside defun in scratch buffer); (3) open agenda again - you
> should not get the error.
>
> (defun org-agenda-get-scheduled (&optional deadlines with-hour)
>   "Return the scheduled information for agenda display.
> Optional argument DEADLINES is a list of deadline items to be
> displayed in agenda view.  When WITH-HOUR is non-nil, only return
> scheduled items with an hour specification like [h]h:mm."
>   (with-no-warnings (defvar date))
>   (let* ((props (list 'org-not-done-regexp org-not-done-regexp
>                       'org-todo-regexp org-todo-regexp
>                       'org-complex-heading-regexp
> org-complex-heading-regexp
>                       'done-face 'org-agenda-done
>                       'mouse-face 'highlight
>                       'help-echo
>                       (format "mouse-2 or RET jump to Org file %s"
>                               (abbreviate-file-name buffer-file-name))))
>          (regexp (if with-hour
>                      org-scheduled-time-hour-regexp
>                    org-scheduled-time-regexp))
>          (today (org-today))
>          (todayp (org-agenda-today-p date)) ; DATE bound by calendar.
>          (current (calendar-absolute-from-gregorian date))
>          (deadline-pos
>           (mapcar (lambda (d)
>                     (let ((m (get-text-property 0 'org-hd-marker d)))
>                       (and m (marker-position m))))
>                   deadlines))
>          scheduled-items)
>     (goto-char (point-min))
>     (if (org-element--cache-active-p)
>         (org-element-cache-map
>          (lambda (el)
>            (when (and (org-element-property :scheduled el)
>                       (or (not with-hour)
>                           (org-element-property
>                            :hour-start
>                            (org-element-property :scheduled el))
>                           (org-element-property
>                            :hour-end
>                            (org-element-property :scheduled el))))
>              (goto-char (org-element-property :contents-begin el))
>              (catch :skip
>                (org-agenda-skip el)
>                (let* ((s (substring (org-element-property
>                                      :raw-value
>                                      (org-element-property :scheduled el))
>                                     1 -1))
>                       (pos (save-excursion
>                              (goto-char (org-element-property
> :contents-begin el))
>                              ;; We intentionally leave NOERROR
>                              ;; argument in `re-search-forward' nil.  If
>                              ;; the search fails here, something went
>                              ;; wrong and we are looking at
>                              ;; non-matching headline.
>                              (re-search-forward regexp (line-end-position))
>                              (1- (match-beginning 1))))
>                       (todo-state (org-element-property :todo-keyword el))
>                       (donep (eq 'done (org-element-property :todo-type
> el)))
>                       (sexp? (eq 'diary
>                                  (org-element-property
>                                   :type (org-element-property :scheduled
> el))))
>                       ;; SCHEDULE is the scheduled date for the entry.  It
> is
>                       ;; either the bare date or the last repeat, according
>                       ;; to `org-agenda-prefer-last-repeat'.
>                       (schedule
>                        (cond
>                         (sexp? (org-agenda--timestamp-to-absolute s
> current))
>                         ((or (eq org-agenda-prefer-last-repeat t)
>                              (member todo-state
> org-agenda-prefer-last-repeat))
>                          (org-agenda--timestamp-to-absolute
>                           s today 'past (current-buffer) pos))
>                         (t (org-agenda--timestamp-to-absolute s))))
>                       ;; REPEAT is the future repeat closest from CURRENT,
>                       ;; according to `org-agenda-show-future-repeats'. If
>                       ;; the latter is nil, or if the time stamp has no
>                       ;; repeat part, default to SCHEDULE.
>                       (repeat
>                        (cond
>                         (sexp? schedule)
>                         ((<= current today) schedule)
>                         ((not org-agenda-show-future-repeats) schedule)
>                         (t
>                          (let ((base (if (eq
> org-agenda-show-future-repeats 'next)
>                                          (1+ today)
>                                        current)))
>                            (org-agenda--timestamp-to-absolute
>                             s base 'future (current-buffer) pos)))))
>                       (diff (- current schedule))
>                       (warntime (get-text-property (point)
> 'org-appt-warntime))
>                       (pastschedp (< schedule today))
>                       (futureschedp (> schedule today))
>                       (habitp (and (fboundp 'org-is-habit-p)
>                                    (string= "habit" (org-element-property
> :STYLE el))))
>                       (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))))
>                       (ddays
>                        (cond
>                         ;; Nullify delay when a repeater triggered already
>                         ;; and the delay is of the form --Xd.
>                         ((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)))))
>                  ;; 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
>                  ;; been displayed for more than `org-scheduled-past-days'.
>                  (unless (and todayp
>                               habitp
>                               (bound-and-true-p org-habit-show-all-today))
>                    (when (or (and (> ddays 0) (< diff ddays))
>                              (> diff (or (and habitp
> org-habit-scheduled-past-days)
>                                          org-scheduled-past-days))
>                              (> schedule current)
>                              (and (/= current schedule)
>                                   (/= current today)
>                                   (/= current repeat)))
>                      (throw :skip nil)))
>                  ;; Possibly skip done tasks.
>                  (when (and donep
>                             (or org-agenda-skip-scheduled-if-done
>                                 (/= schedule current)))
>                    (throw :skip nil))
>                  ;; Skip entry if it already appears as a deadline, per
>                  ;; `org-agenda-skip-scheduled-if-deadline-is-shown'.  This
>                  ;; 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))
>                                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))))
>                          (`not-today pastschedp)
>                          (`t t)
>                          (_ nil))
>                    (throw :skip nil))
>                  ;; Skip habits if `org-habit-show-habits' is nil, or if we
>                  ;; only show them for today.  Also skip done habits.
>                  (when (and habitp
>                             (or donep
>                                 (not (bound-and-true-p
> org-habit-show-habits))
>                                 (and (not todayp)
>                                      (bound-and-true-p
>
> org-habit-show-habits-only-for-today))))
>                    (throw :skip nil))
>                  (save-excursion
>                    (goto-char (org-element-property :begin el))
>                    (let* ((category (org-get-category))
>                           (effort (save-match-data
>                                     (or (get-text-property (point) 'effort)
>                                         (org-element-property (intern
> (concat ":" (upcase org-effort-property))) el))))
>                           (effort-minutes (when effort (save-match-data
> (org-duration-to-minutes effort))))
>                           (inherited-tags
>                            (or (eq org-agenda-show-inherited-tags 'always)
>                                (and (listp org-agenda-show-inherited-tags)
>                                     (memq 'agenda
> org-agenda-show-inherited-tags))
>                                (and (eq org-agenda-show-inherited-tags t)
>                                     (or (eq org-agenda-use-tag-inheritance
> t)
>                                         (memq 'agenda
>
> org-agenda-use-tag-inheritance)))))
>                           (tags (org-get-tags el (not inherited-tags)))
>                           (level (make-string (org-element-property :level
> el)
>                                               ?\s))
>                           (head (save-excursion
>                                   (goto-char (org-element-property :begin
> el))
>                                   (re-search-forward
> org-outline-regexp-bol)
>                                   (buffer-substring (point)
> (line-end-position))))
>                           (time
>                            (cond
>                             ;; No time of day designation if it is only a
>                             ;; reminder, except for habits, which always
> show
>                             ;; the time of day.  Habits are an exception
>                             ;; because if there is a time of day, that is
>                             ;; interpreted to mean they should usually
> happen
>                             ;; then, even if doing the habit was missed.
>                             ((and
>                               (not habitp)
>                               (/= current schedule)
>                               (/= current repeat))
>                              nil)
>                             ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)"
> s)
>                              (concat (substring s (match-beginning 1)) "
> "))
>                             (t 'time)))
>                           (item
>                            (org-agenda-format-item
>                             (pcase-let ((`(,first ,past)
> org-agenda-scheduled-leaders))
>                               ;; Show a reminder of a past scheduled today.
>                               (if (and todayp pastschedp)
>                                   (format past diff)
>                                 first))
>                             (org-add-props head nil
>                               'effort effort
>                               'effort-minutes effort-minutes)
>                             level category tags time nil habitp))
>                           (face (cond ((and (not habitp) pastschedp)
>                                        'org-scheduled-previously)
>                                       ((and habitp futureschedp)
>                                        'org-agenda-done)
>                                       (todayp 'org-scheduled-today)
>                                       (t 'org-scheduled)))
>                           (habitp (and habitp (org-habit-parse-todo
> (org-element-property :begin el)))))
>                      (org-add-props item props
>                        'undone-face face
>                        'face (if donep 'org-agenda-done face)
>                        'org-marker (org-agenda-new-marker pos)
>                        'org-hd-marker (org-agenda-new-marker
> (line-beginning-position))
>                        'type (if pastschedp "past-scheduled" "scheduled")
>                        'date (if pastschedp schedule date)
>                        'ts-date schedule
>                        'warntime warntime
>                        'level level
>                        'effort effort 'effort-minutes effort-minutes
>                        'priority (if habitp (org-habit-get-priority habitp)
>                                    (+ 99 diff (org-get-priority item)))
>                        'org-habit-p habitp
>                        'todo-state todo-state)
>                      (push item scheduled-items)))))))
>          :next-re regexp
>          :fail-re regexp
>          :narrow t)
>       (while (re-search-forward regexp nil t)
>         (catch :skip
>           (unless (save-match-data (org-at-planning-p)) (throw :skip nil))
>           (org-agenda-skip)
>           (let* ((s (match-string 1))
>                  (pos (1- (match-beginning 1)))
>                  (todo-state (save-match-data (org-get-todo-state)))
>                  (donep (member todo-state org-done-keywords))
>                  (sexp? (string-prefix-p "%%" s))
>                  ;; SCHEDULE is the scheduled date for the entry.  It is
>                  ;; either the bare date or the last repeat, according
>                  ;; to `org-agenda-prefer-last-repeat'.
>                  (schedule
>                   (cond
>                    (sexp? (org-agenda--timestamp-to-absolute s current))
>                    ((or (eq org-agenda-prefer-last-repeat t)
>                         (member todo-state org-agenda-prefer-last-repeat))
>                     (org-agenda--timestamp-to-absolute
>                      s today 'past (current-buffer) pos))
>                    (t (org-agenda--timestamp-to-absolute s))))
>                  ;; REPEAT is the future repeat closest from CURRENT,
>                  ;; according to `org-agenda-show-future-repeats'. If
>                  ;; the latter is nil, or if the time stamp has no
>                  ;; repeat part, default to SCHEDULE.
>                  (repeat
>                   (cond
>                    (sexp? schedule)
>                    ((<= current today) schedule)
>                    ((not org-agenda-show-future-repeats) schedule)
>                    (t
>                     (let ((base (if (eq org-agenda-show-future-repeats
> 'next)
>                                     (1+ today)
>                                   current)))
>                       (org-agenda--timestamp-to-absolute
>                        s base 'future (current-buffer) pos)))))
>                  (diff (- current schedule))
>                  (warntime (get-text-property (point) 'org-appt-warntime))
>                  (pastschedp (< schedule today))
>                  (futureschedp (> schedule today))
>                  (habitp (and (fboundp 'org-is-habit-p) (org-is-habit-p)))
>                  (suppress-delay
>                   (let ((deadline (and
> org-agenda-skip-scheduled-delay-if-deadline
>                                        (org-entry-get nil "DEADLINE"))))
>                     (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))))
>                  (ddays
>                   (cond
>                    ;; Nullify delay when a repeater triggered already
>                    ;; and the delay is of the form --Xd.
>                    ((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)))))
>             ;; 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
>             ;; been displayed for more than `org-scheduled-past-days'.
>             (unless (and todayp
>                          habitp
>                          (bound-and-true-p org-habit-show-all-today))
>               (when (or (and (> ddays 0) (< diff ddays))
>                         (> diff (or (and habitp
> org-habit-scheduled-past-days)
>                                     org-scheduled-past-days))
>                         (> schedule current)
>                         (and (/= current schedule)
>                              (/= current today)
>                              (/= current repeat)))
>                 (throw :skip nil)))
>             ;; Possibly skip done tasks.
>             (when (and donep
>                        (or org-agenda-skip-scheduled-if-done
>                            (/= schedule current)))
>               (throw :skip nil))
>             ;; Skip entry if it already appears as a deadline, per
>             ;; `org-agenda-skip-scheduled-if-deadline-is-shown'.  This
>             ;; 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))
>                           habitp))
>                      nil)
>                     (`repeated-after-deadline
>                      (let ((deadline (time-to-days
>                                       (org-get-deadline-time (point)))))
>                        (and (<= schedule deadline) (> current deadline))))
>                     (`not-today pastschedp)
>                     (`t t)
>                     (_ nil))
>               (throw :skip nil))
>             ;; Skip habits if `org-habit-show-habits' is nil, or if we
>             ;; only show them for today.  Also skip done habits.
>             (when (and habitp
>                        (or donep
>                            (not (bound-and-true-p org-habit-show-habits))
>                            (and (not todayp)
>                                 (bound-and-true-p
>                                  org-habit-show-habits-only-for-today))))
>               (throw :skip nil))
>             (save-excursion
>               (re-search-backward "^\\*+[ \t]+" nil t)
>               (goto-char (match-end 0))
>               (let* ((category (org-get-category))
>                      (effort (save-match-data (or (get-text-property
> (point) 'effort)
>                                                   (org-entry-get (point)
> org-effort-property))))
>                      (effort-minutes (when effort (save-match-data
> (org-duration-to-minutes effort))))
>                      (inherited-tags
>                       (or (eq org-agenda-show-inherited-tags 'always)
>                           (and (listp org-agenda-show-inherited-tags)
>                                (memq 'agenda
> org-agenda-show-inherited-tags))
>                           (and (eq org-agenda-show-inherited-tags t)
>                                (or (eq org-agenda-use-tag-inheritance t)
>                                    (memq 'agenda
>
>  org-agenda-use-tag-inheritance)))))
>                      (tags (org-get-tags nil (not inherited-tags)))
>                      (level (make-string (org-reduced-level
> (org-outline-level))
>                                          ?\s))
>                      (head (buffer-substring (point) (line-end-position)))
>                      (time
>                       (cond
>                        ;; No time of day designation if it is only a
>                        ;; reminder, except for habits, which always show
>                        ;; the time of day.  Habits are an exception
>                        ;; because if there is a time of day, that is
>                        ;; interpreted to mean they should usually happen
>                        ;; then, even if doing the habit was missed.
>                        ((and
>                          (not habitp)
>                          (/= current schedule)
>                          (/= current repeat))
>                         nil)
>                        ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
>                         (concat (substring s (match-beginning 1)) " "))
>                        (t 'time)))
>                      (item
>                       (org-agenda-format-item
>                        (pcase-let ((`(,first ,past)
> org-agenda-scheduled-leaders))
>                          ;; Show a reminder of a past scheduled today.
>                          (if (and todayp pastschedp)
>                              (format past diff)
>                            first))
>                        (org-add-props head nil
>                          'effort effort
>                          'effort-minutes effort-minutes)
>                        level category tags time nil habitp))
>                      (face (cond ((and (not habitp) pastschedp)
>                                   'org-scheduled-previously)
>                                  ((and habitp futureschedp)
>                                   'org-agenda-done)
>                                  (todayp 'org-scheduled-today)
>                                  (t 'org-scheduled)))
>                      (habitp (and habitp (org-habit-parse-todo))))
>                 (org-add-props item props
>                   'undone-face face
>                   'face (if donep 'org-agenda-done face)
>                   'org-marker (org-agenda-new-marker pos)
>                   'org-hd-marker (org-agenda-new-marker
> (line-beginning-position))
>                   'type (if pastschedp "past-scheduled" "scheduled")
>                   'date (if pastschedp schedule date)
>                   'ts-date schedule
>                   'warntime warntime
>                   'level level
>                   'effort effort 'effort-minutes effort-minutes
>                   'priority (if habitp (org-habit-get-priority habitp)
>                               (+ 99 diff (org-get-priority item)))
>                   'org-habit-p habitp
>                   'todo-state todo-state)
>                 (push item scheduled-items)))))))
>     (nreverse scheduled-items)))
>
> --
> 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>
>

[-- Attachment #2: Type: text/html, Size: 33245 bytes --]

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

* Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.
  2023-09-19 10:17           ` Carlo Tambuatco
@ 2023-09-19 10:52             ` Ihor Radchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2023-09-19 10:52 UTC (permalink / raw)
  To: Carlo Tambuatco; +Cc: Org-Mode Mailing List

Carlo Tambuatco <oraclmaster@gmail.com> writes:

> Okay. It does indeed work.

Closing.
Fixed.

> ... When will it be available in general release?

In the next bugfix release (few weeks-ish from now).

For manual pre-release installation, check out options described in
https://orgmode.org/manual/Installation.html or
https://protesilaos.com/codelog/2022-05-13-emacs-elpa-devel/

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

end of thread, other threads:[~2023-09-19 10:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19  8:09 Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time Carlo Tambuatco
2023-09-19  9:20 ` Ihor Radchenko
2023-09-19  9:46   ` Carlo Tambuatco
2023-09-19  9:52     ` Ihor Radchenko
2023-09-19 10:03       ` Carlo Tambuatco
2023-09-19 10:10         ` Ihor Radchenko
2023-09-19 10:17           ` Carlo Tambuatco
2023-09-19 10:52             ` 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).