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 



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

2023-09-19 Thread Carlo Tambuatco
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) #)((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 "#FF") 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) #) :next-re "\\]+\\)>" :fail-re
"\\]+\\)>" :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 # org-marker # 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 # org-marker # 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