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 12:04:55 +0200 Organization: FH-Trier Message-ID: <1223460628.620979@arno.fh-trier.de> References: 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 1223463532 22316 80.91.229.12 (8 Oct 2008 10:58:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2008 10:58:52 +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 12:59:48 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 1KnWlb-0002Nb-1B for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 12:59:43 +0200 Original-Received: from localhost ([127.0.0.1]:51356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KnWkW-0000mV-Rz for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 06:58:36 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-stu1.dfn.de!news.belwue.de!news.uni-kl.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Original-NNTP-Posting-Host: 143-93-54-11.arno.fh-trier.de Original-X-Trace: news.uni-kl.de 1223460646 27335 143.93.54.11 (8 Oct 2008 10:10:46 GMT) Original-X-Complaints-To: usenet@news.uni-kl.de Original-NNTP-Posting-Date: Wed, 8 Oct 2008 10:10:46 +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-217-076.pools.arcor-ip.net X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) Original-Xref: news.stanford.edu gnu.emacs.help:163189 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:58532 Archived-At: Xah wrote: > 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) -ap