From 1ed525edb3b2084834c26aab985092d13dd79005 Mon Sep 17 00:00:00 2001 From: pi-bot-01 Date: Thu, 26 Mar 2026 01:01:07 -0700 Subject: [PATCH] Initial commit --- insert-datetime.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 insert-datetime.el diff --git a/insert-datetime.el b/insert-datetime.el new file mode 100644 index 0000000..9a19941 --- /dev/null +++ b/insert-datetime.el @@ -0,0 +1,46 @@ +;;; 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)