0

I want to use keyboard when selecting a date in calendar (while setting deadline or schedule in org mode).

The cursor is set to nil and it's not visible where the cursor is.

I've tracked down the code

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

in the org.el file.
Similar question has been asked (https://emacs.stackexchange.com/a/53717/12031)

and some history about it. (https://list.orgmode.org/87d36uip6p.fsf@gnu.org/)

How should I go about changing the behavior of this code?

I tried :around and :after . with error (if: Wrong type argument: stringp, (25816 61424))
I guess something wrong with my code

(defun my-org-read-date (orig-fn &rest args)
  (progn
    ;; (apply orig-fn args)

    (apply 'org-read-date args)
    (org-eval-in-calendar '(setq cursor-type t) t)
    )
  )

(advice-remove 'org-read-date  #'my-org-read-date)
(advice-add 'org-read-date :around #'my-org-read-date)



(defun my-cursor ()
  (org-eval-in-calendar '(setq cursor-type 'bar) t)
  )

(defun my-cursor2 ()
  (setq cursor-type 'bar)
  )


(add-hook 'calendar-mode-hook
          (define-key calendar-mode-map (kbd "!") 'my-cursor2)
          )
Drew
  • 75,699
  • 9
  • 109
  • 225
eugene
  • 481
  • 1
  • 5
  • 11
  • How about using an `advice-add` / `:after` with `org-read-date` that takes the calendar buffer and sets the cursor-type to make it visible again; e.g., `(with-current-buffer "*Calendar*" ...)`? Such an approach would perhaps be preferred to redefining a large function such as `org-read-date` ... – lawlist Aug 12 '23 at 13:28
  • @lawlist thanks for the suggestion, after I asked the question, I've tried few things, (I edited the OP), and it's not working yet.. – eugene Aug 12 '23 at 14:16
  • 1
    @lawlist after seeing https://scripter.co/emacs-lisp-advice-combinators/, I think advice-add won't work, because org-read-date doesn't return until I select a date. and I need see the cursor before I select a date.. – eugene Aug 12 '23 at 14:24

1 Answers1

0

As to the master branch of Emacs 29 as of 08/12/2023, the behavior that needs to be changed is caused by line 13728 of org.el, within the function org-read-date -- i.e., (org-eval-in-calendar '(setq cursor-type nil) t)

https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org.el#L13728

One approach is to advice the function org-eval-in-calendar to look for the code at issue, and then substitute the argument at issue with a new argument, and then apply the function using said new argument:

(defun my-func (orig-fun &rest args)
  (when (equal (car args) '(setq cursor-type nil))
    (setcar args '(setq cursor-type 'bar)))
  (apply orig-fun args))

(advice-add 'org-eval-in-calendar :around #'my-func)
lawlist
  • 18,826
  • 5
  • 37
  • 118
  • Thank you for the answer. I thought of setting the function (cursor-type) nil and using :before in order to nullify the effect of the line. well. TY! – eugene Aug 13 '23 at 04:55