I would like to be able to run M-x calendar, navigate to a date, press some keystroke which would do one of the following:

  1. place the selected date onto the kill ring


  1. close the calendar and insert the selected date into my current buffer.

Is there any built-in functionality for this?


org-read-date uses the function calendar from the calendar.el library. It is not necessary to be in an org-mode buffer to use org-read-date; i.e, the function org-insert-copy-date should work in just about any buffer that is read-write. The nifty thing about org-read-date is that you can use the mouse to select a date and exit, or use the minibuffer to select a date (which has some pretty overlays).

(defun org-insert-copy-date ()
"Insert a date at point using `org-read-date' with its optional argument
of TO-TIME so that the user can customize the date format more easily.
Also, copy the time-string to the `kill-ring'."
  (require 'org)
  (let* ((time (org-read-date nil 'to-time nil "Date:  "))
         (time-string (format-time-string "%Y-%m-%d" time)))
    (kill-new time-string)
    (insert time-string)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.