From ea157ffc4382057bd3f2e924e80866ebd2fd33d7 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 28 May 2013 21:05:51 +0100 Subject: Emacs: add command to insert a formatted date --- emacs/init.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/emacs/init.el b/emacs/init.el index 30b4e6b..4941e36 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -306,6 +306,16 @@ Values: `desktop', `server', `laptop'") (setq calendar-week-start-day 1) (calendar-set-date-style 'iso))) +(defun insert-date (prefix) + "Insert the current date. With prefix-argument, use British format. With + two prefix arguments, write out the day and month name." + (interactive "P") + (let ((format (cond + ((not prefix) "%Y-%m-%d") + ((equal prefix '(4)) "%d/%m/%Y") + ((equal prefix '(16)) "%A, %d %B %Y")))) + (insert (format-time-string format)))) + ;;;; Directory browsing (use-package dired :defer t -- cgit 1.4.1