From 2e644dfb1bf83564fe48be3271df4d7f1324281c Mon Sep 17 00:00:00 2001 From: Mountain Man <43313373+MountainMan1312@users.noreply.github.com> Date: Sun, 23 Jul 2023 20:08:48 -0400 Subject: Add keybinds to insert date and time without org formatting --- init.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index 35857c4..d8f8d9e 100644 --- a/init.el +++ b/init.el @@ -1515,30 +1515,43 @@ ;; format. ;; --------------------------------- -;; Active timestamp +;; Insert 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-active () "Insert active timestamp at POINT in the format of `mm/date-time-format-active'." (interactive) (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 +;; Insert 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))) +;; Insert current date with no formatting +(defvar mm/date-format "%Y-%m-%d" + "Date format for `mm/insert-date-string'.") +(defun mm/insert-date-string () + "Insert date at POINT in the format of `mm/date-format'." + (interactive) + (insert (format-time-string mm/date-format (current-time)))) +(global-set-key (kbd "C-c i C-u D") (lambda () (interactive) (mm/insert-date-string))) + +;; Insert current time with no formatting +(defvar mm/time-format "%H:%M" + "Time format for `mm/insert-time-string'.") +(defun mm/insert-time-string () + "Insert time at POINT in the format of `mm/time-format'." + (interactive) + (insert (format-time-string mm/time-format (current-time)))) +(global-set-key (kbd "C-c i t") (lambda () (interactive) (mm/insert-time-string))) -- cgit v1.2.3