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: Deniz Dogan
Subject: Re: How to bind delete key for mutiple commands ?
Date: Wed, 16 May 2012 18:22:01 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

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.

Hope that helps,
Deniz



reply via email to

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