From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Uwe Siart Newsgroups: gmane.emacs.help Subject: Re: Insert date and Time Date: Tue, 02 Mar 2010 14:25:17 +0100 Organization: Technische =?iso-8859-1?Q?Universit=E4t_M=FCnchen?= Message-ID: <87zl2q3lfm.fsf@siart.de> References: <27714370.post@talk.nabble.com> <871vg35d7c.fsf@siart.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1267537302 4500 80.91.229.12 (2 Mar 2010 13:41:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 2 Mar 2010 13:41:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 02 14:41:38 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NmSLw-0003h5-Uz for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Mar 2010 14:41:37 +0100 Original-Received: from localhost ([127.0.0.1]:40811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmSLw-0005lz-En for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Mar 2010 08:41:36 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.glorb.com!news2.glorb.com!feeder.erje.net!weretis.net!feeder2.news.weretis.net!news-peer.in.tum.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 24 Original-NNTP-Posting-Host: pegasus.hft.e-technik.tu-muenchen.de Original-X-Trace: news.in.tum.de 1267536295 22584 129.187.140.137 (2 Mar 2010 13:24:55 GMT) Original-X-Complaints-To: usenet@in.tum.de Original-NNTP-Posting-Date: Tue, 2 Mar 2010 13:24:55 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (windows-nt) Cancel-Lock: sha1:n9is9eAzCsxaOsrZLQ59fG9qZ1c= Original-Xref: news.stanford.edu gnu.emacs.help:177265 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:72304 Archived-At: Andreas Röhler 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