Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.

2023-09-19 Thread Ihor Radchenko
Carlo Tambuatco  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 .
Support Org development at ,
or support my work at 



Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.

2023-09-19 Thread Carlo Tambuatco
Okay. It does indeed work. When will it be available in general release?

On Tue, Sep 19, 2023 at 6:09 AM Ihor Radchenko  wrote:

> Carlo Tambuatco  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 ( 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 

Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.

2023-09-19 Thread Ihor Radchenko
Carlo Tambuatco  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 ( 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))
  

Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.

2023-09-19 Thread Carlo Tambuatco
org-version 9.6.9

On Tue, Sep 19, 2023 at 5:51 AM Ihor Radchenko  wrote:

> Carlo Tambuatco  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 .
> Support Org development at ,
> or support my work at 
>


Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.

2023-09-19 Thread Ihor Radchenko
Carlo Tambuatco  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 .
Support Org development at ,
or support my work at 



Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.

2023-09-19 Thread Carlo Tambuatco
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  wrote:

> Carlo Tambuatco  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 .
> Support Org development at ,
> or support my work at 
>


Re: Org agenda crashes when an agenda's deadline is within 14 days of its scheduled time.

2023-09-19 Thread Ihor Radchenko
Carlo Tambuatco  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 .
Support Org development at ,
or support my work at