From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: can a command specify overwrite selection behavior? Date: Wed, 1 Sep 2010 01:11:51 -0700 (PDT) Organization: http://groups.google.com Message-ID: <05a87fbb-31a7-40c3-a890-6c7aacaefac3@t5g2000prd.googlegroups.com> References: <33ac6984-0a0c-4db8-8ea1-50ec5c271a25@x18g2000pro.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291860747 14135 80.91.229.12 (9 Dec 2010 02:12:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 02:12:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 03:12:23 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 1PQVzY-0003q4-IL for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 03:12:20 +0100 Original-Received: from localhost ([127.0.0.1]:35809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQVzX-0000bN-QE for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 21:12:19 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!t5g2000prd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 26 Original-NNTP-Posting-Host: 67.180.85.8 Original-X-Trace: posting.google.com 1283328713 1284 127.0.0.1 (1 Sep 2010 08:11:53 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 1 Sep 2010 08:11:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t5g2000prd.googlegroups.com; posting-host=67.180.85.8; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4, gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:181048 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:76450 Archived-At: On Aug 31, 10:33=A0pm, Xah Lee wrote: > i have this code that inserts date. > > (defun insert-date () > =A0 "Insert current date." > =A0 (interactive) > =A0 (insert (format-time-string "%Y-%m-%d")) > =A0 ) > (put 'insert-date 'delete-selection t) > > the last line is to make sure that if i have a text selection, just > overwrite it. > > but it doesn't work. > ... work around: (defun insert-date () "Insert current date." (interactive) (when (region-active-p) (delete-region (region-beginning) (region-end) ) ) (insert (format-time-string "%Y-%m-%d")) )