diff options
author | noa | 2025-02-16 21:49:32 +0800 |
---|---|---|
committer | noa | 2025-02-16 21:49:32 +0800 |
commit | 713820ab03f3c021c4c142d95508f52c08815ff1 (patch) | |
tree | 53e907c560db83fd988c2617d8f139c94657e9f4 /emacs | |
parent | 3b9caec342aff429df5f3e0157436696298774da (diff) |
Improve defun to insert date/time
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/init.el | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/emacs/init.el b/emacs/init.el index 37abb6f..94d9e34 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -543,9 +543,16 @@ The misspelled word is taken from OVERLAY. WORD is the corrected word." ;; Insert date and time at point ;; Sometimes it's useful to be able to add a timestamp. I use this for notes. Use the same binding as notepad.exe. -(defun noa/insert-date-time () +(defun noa/insert-date (&optional time) + "Insert the current date into the buffer. +With prefix argument TIME, also add the current time." + (interactive "P") + (if time + (insert (format-time-string "[%Y-%m-%d %H:%M]")) + (insert (format-time-string "[%Y-%m-%d]")))) +(defun noa/insert-datetime () (interactive) - (insert (format-time-string "<%Y-%m-%d>"))) + (noa/insert-date t)) (global-set-key (kbd "<f5>") 'noa/insert-date-time) |