* [PATCH] lisp/org-agenda.el: Check agenda type earlier
@ 2023-12-23 19:58 Morgan Smith
2023-12-24 11:15 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Morgan Smith @ 2023-12-23 19:58 UTC (permalink / raw)
To: emacs-orgmode
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".
---
lisp/org-agenda.el | 48 +++++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index d4dd6d823..9b75ee943 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -8598,31 +8598,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.
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-24 11:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-23 19:58 [PATCH] lisp/org-agenda.el: Check agenda type earlier Morgan Smith
2023-12-24 11:15 ` 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).