summary refs log tree commit diff
path: root/emacs/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/init.el')
-rw-r--r--emacs/init.el11
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)