Skip to content

Instantly share code, notes, and snippets.

@deadghost
Created December 8, 2016 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deadghost/786816bc119cbc88aacf0e662bbc10af to your computer and use it in GitHub Desktop.
Save deadghost/786816bc119cbc88aacf0e662bbc10af to your computer and use it in GitHub Desktop.
(defvar current-date-time-format "%a %b %d %H:%M:%S %Z %Y"
"Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")
(defvar current-time-format "%a %H:%M:%S"
"Format of date to insert with `insert-current-time' func.
Note the weekly scope of the command's precision.")
(defun insert-current-date-time ()
"insert the current date and time into current buffer.
Uses `current-date-time-format' for the formatting the date/time."
(interactive)
;; (insert "==========\n")
;; (insert (let () (comment-start)))
(insert (format-time-string current-date-time-format (current-time)))
(insert "\n"))
(defun insert-current-time ()
"insert the current time (1-week scope) into the current buffer."
(interactive)
(insert (format-time-string current-time-format (current-time)))
(insert "\n"))
(global-set-key (kbd "<f5>") 'insert-current-date-time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment