help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kill-region defadvice


From: Barry Margolin
Subject: Re: kill-region defadvice
Date: Sun, 08 Jun 2008 17:18:56 -0400
User-agent: MT-NewsWatcher/3.5.3b2 (Intel Mac OS X)

In article 
<c09cac8e-fd66-4731-947d-c18a9060ba92@d1g2000hsg.googlegroups.com>,
 Joe <joesmoe10@gmail.com> wrote:

> Hey all,
> 
> I liked the tip in Steve Yegge's "Effective Emacs" of rebinding
> backward-kill-word to C-w but I still wanted to use C-w for kill-
> region.  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.

Others have answered your programming question, but I'd like to comment 
on your original premise.

I assume you only want this special behavior when the command is bound 
to C-w, because the "w" means "word" to you (was this the kill-word 
command in some other editor you've used in the past?).  But if you use 
defadvice, your advice will be obeyed even if the command were on some 
other key.  Or if a function used (call-interactively 'kill-region).

So I think it would be better to write a new function, and bind C-w to 
that.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


reply via email to

[Prev in Thread] Current Thread [Next in Thread]