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

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

Re: How to bind delete key for mutiple commands ?


From: rusi
Subject: Re: How to bind delete key for mutiple commands ?
Date: Wed, 16 May 2012 09:38:28 -0700 (PDT)
User-agent: G2/1.0

On May 16, 9:22 pm, Deniz Dogan <de...@dogan.se> wrote:
> On 2012-05-16 11:30, codetweetie wrote:
>
>
>
>
>
>
>
>
>
>
>
> > Hi all,
>
> > I'm trying to bind the delete key to the following commands :
> > delete-char
> > kill-region
>
> > I tried mapping "delete" key to "kill-region" using global-set-key which
> > worked fine.
> > When I again mapped "delete" to "delete-char" obviously the command got
> > overridden.
>
> > How do I map multiple commands to the same key or key-combination ?
>
> > Thanks,
> > Anitha
>
> Hi,
>
> You need to make a new command which acts differently depending on the
> circumstances.  Define a function something like this:
>
> (defun kill-region-or-delete-char ()
>    (interactive "*")
>    (if (use-region-p)
>        (kill-region (region-beginning) (region-end))
>      (delete-char 1)))
>
> Then bind delete to that command.  There is most likely a better way to
> define the command so that it takes arguments into account, but this
> should get you on the right way.

Maybe you want this?
http://emacswiki.org/emacs/DeleteSelectionMode


reply via email to

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