unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: kill-region defadvice
Date: Sun, 08 Jun 2008 17:18:56 -0400	[thread overview]
Message-ID: <barmar-9A2551.17185608062008@newsgroups.comcast.net> (raw)
In-Reply-To: c09cac8e-fd66-4731-947d-c18a9060ba92@d1g2000hsg.googlegroups.com

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 ***


  parent reply	other threads:[~2008-06-08 21:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-08  3:47 kill-region defadvice Joe
2008-06-08  9:10 ` Nikolaj Schumacher
2008-06-08 16:45   ` Kevin Rodgers
2008-06-08 19:56     ` Nikolaj Schumacher
2008-06-08 20:51       ` Kevin Rodgers
2008-06-09  8:25         ` Nikolaj Schumacher
2008-06-08 21:18 ` Barry Margolin [this message]
2008-06-09  1:23   ` Joe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=barmar-9A2551.17185608062008@newsgroups.comcast.net \
    --to=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).