;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/today.el (defun eat-and-beat (re data &optional no-save) (if (looking-at re) (replace-match data) (insert data) (unless no-save (save-buffer) ))) (defun today () (interactive) (let ((re "[[:digit:]]\\{4\\}-[[:digit:]]\\{2\\}-[[:digit:]]\\{2\\}") (date (format-time-string "%F")) ) (eat-and-beat re date) )) (defun now () (interactive) (let ((time-re "[[:digit:]]\\{2\\}:[[:digit:]]\\{2\\}:[[:digit:]]\\{2\\}") (time (format-time-string "%T")) ) (eat-and-beat time-re time) )) (provide 'today)