lisp/org-agenda.el: Check agenda type earlier

lisp/org-agenda.el (org-agenda-goto-date): Check agenda type earlier.
Also remove redundant error.

When this function is run on a todo agenda the user is given the
undescriptive error "(wrong-type-argument listp "todo")" because we
attempt to parse the 'org-last-args text-property prematurely.  With
this change users will get the much better error "Not allowed in
'todo'-type agenda buffer or component".
This commit is contained in:
Morgan Smith 2023-12-23 14:58:53 -05:00 committed by Ihor Radchenko
parent 7440911e49
commit 11e16e5f9e
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 24 additions and 24 deletions

View File

@ -8604,31 +8604,31 @@ See also:
(list
(let ((org-read-date-prefer-future org-agenda-jump-prefer-future))
(org-read-date))))
(org-agenda-check-type t 'agenda)
(let* ((day (time-to-days (org-time-string-to-time date)))
(org-agenda-sticky-orig org-agenda-sticky)
(org-agenda-buffer-tmp-name (buffer-name))
(args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
(0-arg (or current-prefix-arg (car args)))
(2-arg (nth 2 args))
(with-hour-p (nth 4 org-agenda-redo-command))
(newcmd (list 'org-agenda-list 0-arg date
(org-agenda-span-to-ndays
2-arg (org-time-string-to-absolute date))
with-hour-p))
(newargs (cdr newcmd))
(inhibit-read-only t)
org-agenda-sticky)
(if (not (org-agenda-check-type t 'agenda))
(error "Not available in non-agenda views")
(add-text-properties (point-min) (point-max)
`(org-redo-cmd ,newcmd org-last-args ,newargs))
(org-agenda-redo)
(goto-char (point-min))
(while (not (or (= (or (get-text-property (point) 'day) 0) day)
(save-excursion (move-beginning-of-line 2) (eobp))))
(move-beginning-of-line 2))
(setq org-agenda-sticky org-agenda-sticky-orig
org-agenda-this-buffer-is-sticky org-agenda-sticky))))
(org-agenda-sticky-orig org-agenda-sticky)
(org-agenda-buffer-tmp-name (buffer-name))
(args (get-text-property (min (1- (point-max)) (point))
'org-last-args))
(0-arg (or current-prefix-arg (car args)))
(2-arg (nth 2 args))
(with-hour-p (nth 4 org-agenda-redo-command))
(newcmd (list 'org-agenda-list 0-arg date
(org-agenda-span-to-ndays
2-arg (org-time-string-to-absolute date))
with-hour-p))
(newargs (cdr newcmd))
(inhibit-read-only t)
org-agenda-sticky)
(add-text-properties (point-min) (point-max)
`(org-redo-cmd ,newcmd org-last-args ,newargs))
(org-agenda-redo)
(goto-char (point-min))
(while (not (or (= (or (get-text-property (point) 'day) 0) day)
(save-excursion (move-beginning-of-line 2) (eobp))))
(move-beginning-of-line 2))
(setq org-agenda-sticky org-agenda-sticky-orig
org-agenda-this-buffer-is-sticky org-agenda-sticky)))
(defun org-agenda-goto-today ()
"Go to today's date in the agenda buffer.