From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: (insert ...) won't respect delete-selection-mode Date: Wed, 8 Oct 2008 00:20:03 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1223451649 16448 80.91.229.12 (8 Oct 2008 07:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2008 07:40:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 08 09:41:46 2008 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.50) id 1KnTg1-0008Bl-72 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 09:41:45 +0200 Original-Received: from localhost ([127.0.0.1]:60306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KnTex-0000rK-Ay for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 03:40:39 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!a18g2000pra.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 59 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1223450403 31430 127.0.0.1 (8 Oct 2008 07:20:03 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 8 Oct 2008 07:20:03 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a18g2000pra.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:163179 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:58523 Archived-At: On Oct 7, 2:08=C2=A0pm, Chetan wrote: > "Drew Adams" writes: > >> i have a some 20 personal commands that insert some text. However, i > >> have delete-selection-mode on, meaning that when a region is active, > >> any typing should delete/override it. > > >> But when calling my insert text commands it will just insert at the > >> end of region. Here's a example: > >> (defun insert-date () "Insert current date." (interactive) > >> =C2=A0 (insert (format-time-string "%Y-%m-%d"))) > > >> Do i need to modify each commands to check on mark-active and delete- > >> selection-mode then call delete region first? Or, is there some > >> variable i can just set? > > > See the Commentary at the beginning of `delsel.el': > > > ;; =C2=A0Commands that delete the selection need a `delete-selection' > > ;; =C2=A0property on their symbols. Commands that insert text but do no= t > > ;; =C2=A0have this property do not delete the selection. =C2=A0The prop= erty can > > ;; =C2=A0be one of these values: > > ;; =C2=A0'yank > > ;; =C2=A0 =C2=A0 =C2=A0For commands which do a yank; ensures the region= about to be > > ;; =C2=A0 =C2=A0 =C2=A0deleted isn't yanked. > > ;; =C2=A0'supersede > > ;; =C2=A0 =C2=A0 =C2=A0Delete the active region and ignore the current = command, > > ;; =C2=A0 =C2=A0 =C2=A0i.e. the command will just delete the region. > > ;; =C2=A0'kill > > ;; =C2=A0 =C2=A0 =C2=A0`kill-region' is used on the selection, rather t= han > > ;; =C2=A0 =C2=A0 =C2=A0`delete-region'. =C2=A0(Text selected with the m= ouse will typically > > ;; =C2=A0 =C2=A0 =C2=A0be yankable anyhow.) > > ;; =C2=A0non-nil > > ;; =C2=A0 =C2=A0 =C2=A0The normal case: delete the active region prior = to executing > > ;; =C2=A0 =C2=A0 =C2=A0the command which will insert replacement text. > > > Example: > > > (put 'insert-date 'delete-selection t) > > The command also needs to be activated with keyboard. M-x does not > do it. Thank you both. Why does it needs to be called from keyboard? Unfortunately most of my commands are used by calling a short alias. Xah =E2=88=91 http://xahlee.org/ =E2=98=84