;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/time-insert.el (defun insert-shell-command (cmd) (interactive "s Command: ") (let ((pos (point)) (end (point-max)) ) (shell-command cmd 1) (goto-char (+ pos (- (point-max) end 1))) ) (delete-char 1) ) (defun get-date () (format-time-string "%F") ) (defun insert-date () (interactive) (insert (get-date)) ) (defun insert-time () (interactive) (insert-shell-command "date +\"%H:%M:%S\"") ) (defun insert-now () (interactive) (insert-date) (insert " ") (insert-time) (save-buffer) ) (defalias 'now #'insert-now) (defun updated () (unless (looking-at "$") (kill-line) ) (insert " ") (insert-date) (save-buffer) ) ;; example file: ;; ;; --------------------------------------------- ;; list of things to read ;; --------------------------------------------- ;; ;; * the Emacs manual ;; ;; * Kate Moss's autobiography ;; ;; * X-Men and Alita comics ;; ;; * big book on computer architecture (maybe) ;; ;; * the hygrometer ;; ;; --------------------------------------------- ;; (updated) 2020-05-10 ;; ^eval me! ;; --------------------------------------------- (provide 'time-insert)