From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chetan Newsgroups: gmane.emacs.help Subject: Re: (insert ...) won't respect delete-selection-mode Date: Tue, 07 Oct 2008 14:08:09 -0700 Organization: Noname Inc. Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1223415718 28523 80.91.229.12 (7 Oct 2008 21:41:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 Oct 2008 21:41:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 07 23:42:56 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 1KnKKW-0005zl-0K for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Oct 2008 23:42:56 +0200 Original-Received: from localhost ([127.0.0.1]:34462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KnKJS-0006KZ-F6 for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Oct 2008 17:41:50 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!flpi089.ffdc.sbc.com!prodigy.net!flpi088.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!nlpi070.nbdc.sbc.com.POSTED!8e1d8614!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Emacs Gnus Cancel-Lock: sha1:u5iJ0Gwcn1/5Y7K6nK9wQiW4XE0= Original-Lines: 42 Original-NNTP-Posting-Host: 75.37.16.137 Original-X-Complaints-To: abuse@prodigy.net Original-X-Trace: nlpi070.nbdc.sbc.com 1223413690 ST000 75.37.16.137 (Tue, 07 Oct 2008 17:08:10 EDT) Original-NNTP-Posting-Date: Tue, 07 Oct 2008 17:08:10 EDT X-UserInfo1: Q[R_PJONEJVOBTLZOZKN^_TDFZ\@@FXLM@TDOCQDJ@_@FNHB_NVUAH_[BL[\IRKIANGGJBFNJF_DOLSCENSY^U@FRFUEXR@KFXYDBPWBCDQJA@X_DCBHXR[C@\EOKCJLED_SZ@RMWYXYWE_P@\\GOIW^@SYFFSWHFIXMADO@^[ADPRPETLBJ]RDGENSKQQZN Original-Xref: news.stanford.edu gnu.emacs.help:163168 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:58511 Archived-At: "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. Chetan