;;; Provide functions for inserting formatted time/date. (require 'dash) (defgroup insert-datetime nil "You can modify Insert Datetime format strings here. See: `format-time-string'." :group 'tools) ;;; Bart Simpson anti-chalkboard technique. (let ((list '(("datetime" "%X") ("date" "%F") ("time" "%r") ("year" "%Y") ("month" "%m") ("week" "%U") ("day" "%e") ("day-of-year" "%j") ("day-of-month" "%d") ("day-of-week" "%A") ("hour" "%H") ("minute" "%M") ("second" "%S") )) (custom-proto "(defcustom insert-datetime-format-%s \"%s\" \"Format string for \`insert-%s\'.\" :group 'insert-datetime)") (defun-proto "(defun insert-%s () \"Insert %s at point.\" (interactive) (insert (format-time-string insert-datetime-format-%s (current-time))))")) (--map (eval (read (format custom-proto (car it) (cadr it) (car it)))) list) (--map (eval (read (format defun-proto (car it) (cadr it) (car it)))) list) ) (provide 'insert-datetime)