[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Insert date and Time
From: |
Uwe Siart |
Subject: |
Re: Insert date and Time |
Date: |
Tue, 02 Mar 2010 14:25:17 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (windows-nt) |
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> Uwe Siart wrote:
>> Nice gimmick. To make it perfect I'd like insert-time-stamp to replace
>> region (if there is a region). How to achieve this? (insert "string")
>> does not replace region but inserts at point.
>
> May be that way:
>
> (defun insert-time-stamp ()
> "Inserts a time stamp 'YYYY-MM-DD HH:MM AM/PM'"
> (interactive "*")
> (let ((beg (when (region-active-p)
> (region-beginning)))
> (end (when
> (region-active-p) (region-end))))
> (when (and beg end)
> (delete-region beg end)))
> (insert (format-time-string "%Y-%m-%d - %I:%M %p")))
Quite the thing. Many thanks!
--
Uwe