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 09:48:42 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1223460628.620979@arno.fh-trier.de> 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 1223487693 17480 80.91.229.12 (8 Oct 2008 17:41:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2008 17:41:33 +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 19:42:30 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 1Knd37-0001hY-9g for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 19:42:13 +0200 Original-Received: from localhost ([127.0.0.1]:51073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Knd23-0001cZ-Gl for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 13:41:07 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!a2g2000prm.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 70 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1223484522 15168 127.0.0.1 (8 Oct 2008 16:48:42 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 8 Oct 2008 16:48:42 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a2g2000prm.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:163207 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:58551 Archived-At: On Oct 8, 3:04=C2=A0am, Andreas Politz wrote: > Xahwrote: > > On Oct 7, 2:08 pm, 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 = not > >>> ;; =C2=A0have this property do not delete the selection. =C2=A0The pr= operty can > >>> ;; =C2=A0be one of these values: > >>> ;; =C2=A0'yank > >>> ;; =C2=A0 =C2=A0 =C2=A0For commands which do a yank; ensures the regi= on 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 curren= t 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= than > >>> ;; =C2=A0 =C2=A0 =C2=A0`delete-region'. =C2=A0(Text selected with the= mouse 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 prio= r 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. > > > =C2=A0Xah > > =E2=88=91http://xahlee.org/ > > > =E2=98=84 > > Because it't a different command. > > (put 'execute-extended-command 'delete-selection t) LOL. When i tried this, it'll just delete the region when you do M-x, regardless what command you gonna call. for a moment i was gonna say Thanks! Great solution! Xah =E2=88=91 http://xahlee.org/ =E2=98=84