summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorgan Smith <Morgan.J.Smith@outlook.com>2023-12-23 14:58:53 -0500
committerIhor Radchenko <yantar92@posteo.net>2023-12-24 12:11:16 +0100
commit11e16e5f9e54fc3e486cab8e05a3485a58295b1a (patch)
tree8f4477d55b980b2744f4d33c5b608bb4916f1818
parent7440911e492e01eec36cf4252a9194edf7e00462 (diff)
downloadorg-mode-11e16e5f9.tar.gz
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".
-rw-r--r--lisp/org-agenda.el48
1 files changed, 24 insertions, 24 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 6a9b1cc..a1b2f3d 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -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.