Hello,

When `org-read-date-popup-calendar' is non-nil (the default),
`org-read-date' hides the cursor in the calendar buffer:

    (org-eval-in-calendar '(setq cursor-type nil) t)

`cursor-type' is a per-buffer variable, so this creates a buffer-local
value in *Calendar*.  The `unwind-protect' around the prompt removes
the temporary local keymap, the `post-command-hook' function and the
date overlay, but it never restores `cursor-type'.  After the prompt
returns (or is aborted with C-g), *Calendar* has no visible cursor.

`org-read-date' reuses an existing *Calendar* buffer, so a calendar
the user already had open loses its cursor.  The cursor stays hidden
until `calendar-mode' runs again (e.g. via M-x calendar), because
that clears the buffer-local variables.  It is still hidden if the
calendar window is visible, or if the user returns to the buried
buffer with C-x b.

I first hit this through a capture template with `:time-prompt t'
(org-capture calls `org-read-date' to pick the date tree entry).
After I cancelled the capture with C-c C-k, the calendar window had
no cursor.  `C-c .' and `C-c C-s' trigger it the same way.

Steps to reproduce (emacs -Q):

  1. M-x calendar
  2. Move to another window (C-x o) and run
       M-: (org-read-date) RET
     then press RET to accept the default date.
  3. Select the calendar window: the cursor is not shown.
     In that buffer, C-h v cursor-type shows nil, with a
     buffer-local value.

Batch check:

  echo "" | emacs -Q --batch --eval '(progn (require (quote org))
    (calendar)
    (with-current-buffer calendar-buffer
      (message "before: local=%S value=%S"
               (local-variable-p (quote cursor-type)) cursor-type))
    (org-read-date)
    (with-current-buffer calendar-buffer
      (message "after: local=%S value=%S"
               (local-variable-p (quote cursor-type)) cursor-type)))'

  Output:
    before: local=nil value=t
    after: local=t value=nil

Expected: after `org-read-date' returns or is aborted, the calendar
buffer's `cursor-type' is what it was before the call.

Suggested fix: in the cleanup part of the `unwind-protect' in
`org-read-date', next to `(bury-buffer calendar-buffer)', restore the
cursor, e.g.

    (when (get-buffer calendar-buffer)
      (with-current-buffer calendar-buffer
        (kill-local-variable 'cursor-type)))

(or save the previous value before hiding it and put it back).

Workaround I'm using now:

    (defun my/org-read-date-restore-calendar-cursor (orig &rest args)
      (unwind-protect
          (apply orig args)
        (when-let* ((name (bound-and-true-p calendar-buffer))
                    (buf (get-buffer name)))
          (with-current-buffer buf
            (kill-local-variable 'cursor-type)))))
    (advice-add 'org-read-date :around
                #'my/org-read-date-restore-calendar-cursor)

Emacs  : GNU Emacs 30.2 (build 2, aarch64-apple-darwin23.6.0, NS
appkit-2487.70 Version 14.8.7 (Build 23J520))
 of 2026-07-25
Package: Org mode version 9.7.11 (release_9.7.11 @
/Applications/Emacs.app/Contents/Resources/lisp/org/)

Thanks,
Seong-Kook Shin w/ Claude

Reply via email to