Created
May 25, 2009 03:47
-
-
Save doitian/117372 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar iy/calendar-copy-date-format-history '("%Y-%m-%d")) | |
(defun iy/calendar-copy-date (arg) | |
"Copy date under the cursor. Read format from minibuffer if ARG, | |
use recently used format if no ARG. See the function `format-time-string' | |
for the document of time format string" | |
(interactive "P") | |
(let ((date (calendar-cursor-to-date t)) | |
(format (if arg | |
(completing-read | |
"Date Format:" | |
iy/calendar-copy-date-format-history nil nil nil | |
'iy/calendar-copy-date-format-history nil nil) | |
(car iy/calendar-copy-date-format-history))) | |
string) | |
(setq date (encode-time 0 0 0 (cadr date) (car date) (nth 2 date))) | |
(setq string (format-time-string format date)) | |
(if (eq last-command 'kill-region) | |
(kill-append string nil) | |
(kill-new string)))) | |
(defun iy/calendar-mode-init () | |
(local-set-key (kbd "w") 'iy/calendar-copy-date)) | |
(add-hook 'calendar-mode-hook 'iy/calendar-mode-init) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment