Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs -- keybind questions

Tags:

emacs

emacs23

I have successfully used Ctrl+Shift+Up ' Ctrl+Shift+down '

Ctrl+Shift+left' Ctrl+Shift+Right to different commands. But when I

tried to use Ctrl+s to the command save-buffer and Ctrl+Shift+s, which

is equivalent to Ctrl+S, to another command, it has some problem.

save-buffer works fine, but when I type Ctrl+Shift+s, it excute

the command save-buffer. I used Ctrl+q to find the control sequences of

Ctrl+s and Ctrl+Shift+S, I get the same result, which is ^S.

I expect that I will get ^s for Ctrl+s, but it doesn't.

Anyone knows the reason?

Another queston is: I use Ctrl+c for the command killing-ring-save. In this

case, all commands (which are of large number) begin with Ctrl+c don't work now.

Is there a way to replace the prefix Ctrl+c by another customized prefix?


I may pose my question in the wrong direction. I use ctrl+c as

killing-ring-save. It works fine in emacs (no mode). But if I open a .c file (C-mode), then

when I type Ctrl+c, it waits me to type another key. I think in this case,

ctrl+c is regarded as a prefix. In this case, I need the following modifications:

Using a custom defined prefix, say Ctrl+a, as Ctrl+c ; Remove the

prefix Ctrl+c ; Using Ctrl+c as killing-ring-save.

I add the following to my ~/.emacs :

(global-set-key (kbd "C-a") mode-specific-map)

(global-set-key (kbd "C-c") 'kill-ring-save)

(global-set-key (kbd "C-f") 'isearch-forward)

(global-set-key (kbd "C-v") 'yank)

(global-set-key (kbd "C-s") 'save-buffer)

(defun my-c-initialization-hook ()

(define-key c-mode-base-map (kbd "C-a") mode-specific-map)

(define-key c-mode-base-map (kbd "C-c") 'kill-ring-save))

(add-hook 'c-initialization-hook 'my-c-initialization-hook)

But this doesn't work. Ctrl+c is still regarded as a prefix, so I can't use it

as kill-ring-save. Furthermore, if I type Ctrl+a Ctrl+c, it said it's not

defined. (I thought it will have the same result as I type Ctrl+c Ctrl+c)

like image 222
user565739 Avatar asked May 08 '26 02:05

user565739


1 Answers

The C-c binding is tricky, CUA mode solves it well, by only making it do kill-ring-save when you have a region marked.

like image 125
ocodo Avatar answered May 11 '26 14:05

ocodo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!