From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: (insert ...) won't respect delete-selection-mode Date: Wed, 08 Oct 2008 23:09:17 +0200 Organization: FH-Trier Message-ID: <1223500491.534035@arno.fh-trier.de> References: <1223460628.620979@arno.fh-trier.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1223502105 4136 80.91.229.12 (8 Oct 2008 21:41:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2008 21:41:45 +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 23:42:42 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 1Kngng-0000tC-Eq for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 23:42:32 +0200 Original-Received: from localhost ([127.0.0.1]:56262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kngmc-0000WE-JP for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 17:41:26 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!kanaga.switch.ch!switch.ch!news.belwue.de!news.uni-kl.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 61 Original-NNTP-Posting-Host: 143-93-54-11.arno.fh-trier.de Original-X-Trace: news.uni-kl.de 1223500510 17399 143.93.54.11 (8 Oct 2008 21:15:10 GMT) Original-X-Complaints-To: usenet@news.uni-kl.de Original-NNTP-Posting-Date: Wed, 8 Oct 2008 21:15:10 +0000 (UTC) User-Agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724) In-Reply-To: Cache-Post-Path: arno.fh-trier.de!unknown@dslb-084-059-101-192.pools.arcor-ip.net X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) Original-Xref: news.stanford.edu gnu.emacs.help:163232 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:58576 Archived-At: Xah wrote: > On Oct 8, 3:04 am, 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) >>>>>> (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': >>>>> ;; Commands that delete the selection need a `delete-selection' >>>>> ;; property on their symbols. Commands that insert text but do not >>>>> ;; have this property do not delete the selection. The property can >>>>> ;; be one of these values: >>>>> ;; 'yank >>>>> ;; For commands which do a yank; ensures the region about to be >>>>> ;; deleted isn't yanked. >>>>> ;; 'supersede >>>>> ;; Delete the active region and ignore the current command, >>>>> ;; i.e. the command will just delete the region. >>>>> ;; 'kill >>>>> ;; `kill-region' is used on the selection, rather than >>>>> ;; `delete-region'. (Text selected with the mouse will typically >>>>> ;; be yankable anyhow.) >>>>> ;; non-nil >>>>> ;; The normal case: delete the active region prior to executing >>>>> ;; the 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 >>> ∑http://xahlee.org/ >>> ☄ >> 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 > ∑ http://xahlee.org/ > > ☄ > Yes, but you get the idea. -ap