From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: Insert date and Time Date: Tue, 02 Mar 2010 11:36:03 +0100 Message-ID: <4B8CEA13.8050907@easy-emacs.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: 7bit X-Trace: dough.gmane.org 1267526079 30201 80.91.229.12 (2 Mar 2010 10:34:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 2 Mar 2010 10:34:39 +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 11:34:35 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 1NmPQt-0004Sc-WD for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Mar 2010 11:34:32 +0100 Original-Received: from localhost ([127.0.0.1]:47887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmPQt-00009Q-Ez for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Mar 2010 05:34:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NmPQI-00006g-SS for help-gnu-emacs@gnu.org; Tue, 02 Mar 2010 05:33:54 -0500 Original-Received: from [140.186.70.92] (port=33092 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmPQH-00005P-FK for help-gnu-emacs@gnu.org; Tue, 02 Mar 2010 05:33:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NmPQG-0000NZ-Vf for help-gnu-emacs@gnu.org; Tue, 02 Mar 2010 05:33:53 -0500 Original-Received: from moutng.kundenserver.de ([212.227.17.8]:54430) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NmPQG-0000NF-Iu for help-gnu-emacs@gnu.org; Tue, 02 Mar 2010 05:33:52 -0500 Original-Received: from [192.168.178.27] (p54BE8ED4.dip0.t-ipconnect.de [84.190.142.212]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0M9cAV-1NshDo18P9-00CcSM; Tue, 02 Mar 2010 11:33:47 +0100 User-Agent: Thunderbird 2.0.0.19 (X11/20081227) In-Reply-To: <871vg35d7c.fsf@siart.de> X-Provags-ID: V01U2FsdGVkX1+nTMEh21zwo8suv3zZDqbwHC/sfCrMbPmKYzi 8n14MRjTDQgqhttPhB8lqo/i8dFMJhSgp8neVToZDOBigZr9JG PFyFMUjG/SKmyx4D3hCTKDE1f5auJ5xrklveo51djU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:72294 Archived-At: Uwe Siart wrote: > Tim Visher writes: > >> I use this function to insert a time stamp at point: >> >> (defun insert-time-stamp () >> "Inserts a time stamp 'YYYY-MM-DD HH:MM AM/PM'" >> (interactive) >> (insert (format-time-string "%Y-%m-%d - %I:%M %p"))) > > 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"))) Andreas -- https://code.launchpad.net/~a-roehler/python-mode https://code.launchpad.net/s-x-emacs-werkstatt/