From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nikolaj Schumacher Newsgroups: gmane.emacs.help Subject: Re: kill-region defadvice Date: Mon, 09 Jun 2008 10:25:51 +0200 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 1213000147 25569 80.91.229.12 (9 Jun 2008 08:29:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Jun 2008 08:29:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Kevin Rodgers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jun 09 10:29:49 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 1K5cl3-0004F0-NQ for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Jun 2008 10:29:41 +0200 Original-Received: from localhost ([127.0.0.1]:47843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K5ckF-0002H2-Kd for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Jun 2008 04:28:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K5chS-0000ZV-Mz for help-gnu-emacs@gnu.org; Mon, 09 Jun 2008 04:25:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K5chO-0000WK-KP for help-gnu-emacs@gnu.org; Mon, 09 Jun 2008 04:25:55 -0400 Original-Received: from [199.232.76.173] (port=48819 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K5chN-0000Vl-Pz for help-gnu-emacs@gnu.org; Mon, 09 Jun 2008 04:25:54 -0400 Original-Received: from fmmailgate03.web.de ([217.72.192.234]:51226) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K5chN-0000Ve-NB for help-gnu-emacs@gnu.org; Mon, 09 Jun 2008 04:25:53 -0400 Original-Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate03.web.de (Postfix) with ESMTP id 02353DF24A5F; Mon, 9 Jun 2008 10:25:52 +0200 (CEST) Original-Received: from [77.189.8.107] (helo=thursday) by smtp07.web.de with asmtp (WEB.DE 4.109 #226) id 1K5chL-0008K4-00; Mon, 09 Jun 2008 10:25:51 +0200 In-Reply-To: (Kevin Rodgers's message of "Sun\, 08 Jun 2008 14\:51\:02 -0600") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (darwin) X-Sender: n_schumacher@web.de X-Provags-ID: V01U2FsdGVkX1/A0rYVzQOJP88NgpIimmchuybtrS/2A4XAoXzs EzoxBuTSKTKedUUrhbjuy6NDohh7ng6CAw4Fnmkgroyzk3eAyE C4QGmfwdjLZJzdo7EF9g== X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 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:54635 Archived-At: Kevin Rodgers wrote: > Nikolaj Schumacher wrote: >> Kevin Rodgers wrote: >> >>> Nikolaj Schumacher wrote: >>>> Joe wrote: >>>> >>>>> Originally I did this by writing a new function that checked >>>>> if the mark was active. However, I think that using defadvice is a >>>>> better solution but I got stuck while trying to write it. >>>> >>>> No, it's not! By using advice, you modify the kill-region function and >>>> risk that any command using it will backward-kill-word instead. >>> >>> Just write the advice as >>> >>> (if (and (interactive-p) mark-active) >>> ad-do-it >>> (backward-kill-word 1)) >> >> Still not a good idea. >> `interactive-p' will return nil when used in a keyboard macro. That >> will most likely cause unintended behavior at some point. > > (if (and (or (interactive-p) executing-kbd-macro) > mark-active) First of all, that should probably read: (if (or (not (or (interactive-p) executing-kbd-macro) mark-active)) But that still won't work. executing-kbd-macro will remain non-nil when called non-interactively by another command while inside a macro. Of course, I'm not saying that it can't be done. I'm just saying it's easy to mess up and difficult to debug. regards, Nikolaj Schumacher