From 013dc8a9550c181a5cd23b9585cea08d01df2ebf Mon Sep 17 00:00:00 2001 From: Mountain Man <43313373+MountainMan1312@users.noreply.github.com> Date: Sat, 24 Jun 2023 14:55:21 -0400 Subject: Separate keybinds for insert active/inactive date/time --- init.el | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index 4715660..258f65e 100644 --- a/init.el +++ b/init.el @@ -1324,18 +1324,36 @@ ;; --------------------------------- ;; Insert date/time at POINT ;; ------------------------- -;; [YYYY-MM-DD HH:mm] +;; Keybinds to quickly insert +;; date/time at point in the correct +;; format. ;; --------------------------------- -(defvar mm/date-time-format "[%Y-%m-%d %a %H:%M]" - "Format of the date to insert with `mm/insert-date-time' function. See help of `format-time-string' for alternative formats.") +;; Active timestamp +(defvar mm/date-time-format-active "<%Y-%m-%d %a %H:%M>" + "Active date/time format for `mm/insert-date-time-active' function. +See help of `format-time-string' for alternative formats.") -(defun mm/insert-date-time () - "Insert the current date time in the format of `mm/date-time-format' at POINT." +(defun mm/insert-date-time-active () + "Insert active timestamp at POINT in the format of `mm/date-time-format-active'." (interactive) - (insert (format-time-string mm/date-time-format (current-time)))) + (insert (format-time-string mm/date-time-format-active (current-time)))) + +(global-set-key (kbd "C-c i D") (lambda () (interactive) (mm/insert-date-time-active))) + +;; Inactive timestamp +(defvar mm/date-time-format-inactive "[%Y-%m-%d %a %H:%M]" + "Inactive timestamp format for `mm/insert-date-time-inactive' function. +See help of `format-time-string' for alternative formats.") + +(defun mm/insert-date-time-inactive () + "Insert inactive timestamp at POINT in the format of `mm/date-time-format-inactive'." + (interactive) + (insert (format-time-string mm/date-time-format-inactive (current-time)))) + +(global-set-key (kbd "C-c i d") (lambda () (interactive) (mm/insert-date-time-inactive))) + -(global-set-key (kbd "C-c i d") (lambda () (interactive) (mm/insert-date-time))) ;; --------------------------------- -- cgit v1.2.3