[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: I want to make C-d works in two ways.
From: |
Andreas Politz |
Subject: |
Re: I want to make C-d works in two ways. |
Date: |
Wed, 08 Dec 2010 15:20:44 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Jeongtae Roh <basil83@gmail.com> writes:
> Hi.
>
> I tried to find out a solution by myself, but failed.
>
> I hope C-d do "kill-region" command when I selected words or
> sentences.
>
> Now it works only as "delete-forward-character", even if I activate a
> region.
>
> So I studied the original code of CUA mode, because it has a function
> like this:
>
> ;; Only when the region is currently active (and highlighted since
> ;; transient-mark-mode is used), the C-x and C-c keys will work as CUA
> ;; keys
> ;; C-x -> cut
> ;; C-c -> copy
> ;; When the region is not active, C-x and C-c works as prefix keys!
>
> Can anybody tell me what should I do?
>
>
> -- Jeongtae
That's easy. Use `use-region-p' to branch to the desired command and
`call-interactively' for not having to bother about the arguments.
(defun kill-region/delete-forward-character ()
(interactive)
(call-interactively (if (use-region-p)
'kill-region
'delete-char)))
-ap