Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This is from a .el file loaded in my .emacs file. What do you think?

;;; Sun keyboard bindings

;; the below line does not work:
;; when <cancel> is pressed, the minibuffer echoes "Quit"
;; but that is the only thing it does

;; (global-set-key [cancel] 'keyboard-quit)

;; Note: I got the 'keyboard-quit from C-h c and then C-g
;; (C-g is the normal way for me to abort)

;; Those work, so it has probably something to do
;; with the peculiarities of 'keyboard-quit, rather than
;; the actual keybinding (or?)

(global-set-key [SunProps] 'describe-variable)
(global-set-key [SunFront] 'next-buffer)
(global-set-key [SunOpen] 'list-buffers)
(global-set-key [XF86Copy] 'clipboard-kill-ring-save)
(global-set-key [XF86Paste] 'x-clipboard-yank)
(global-set-key [XF86Cut] 'clipboard-kill-region)
share|improve this question
1  
What did you expect keyboard-quit to do? The behavior you describe sounds normal to me. –  Kyle Jones Feb 17 '12 at 1:02
    
If you hit it (the cancel button on the keyboard after doing the above stuff) it does not produce the same effect as when you do C-g. On the contrary, nothing happens. –  Emanuel Berg Feb 17 '12 at 2:18
add comment

1 Answer

up vote 5 down vote accepted

Due to the fact that Control+G has to interrupt Emacs while it's doing other things (and not reading normal input), it's hardcoded into the Emacs core and can't be rebound using normal methods. There is a set-quit-char function, but it only works with ASCII characters.

(set-quit-char QUIT)

Specify character used for quitting.
QUIT must be an ASCII character.

This function only has an effect on the controlling tty of the Emacs
process.

In short, you'd have to patch and recompile Emacs to do what you want.

However, it is possible to get some of what you want. If you do

(define-key local-function-key-map [cancel] [7]) ; 7 is C-g

then cancel should work like C-g, but only when Emacs is reading normal input. It won't interrupt a long-running Elisp function the way C-g will. But it will cancel a C-x C-f or similar command that's reading input from the minibuffer.

share|improve this answer
    
Wow, did I find something that was that difficult? I'm impressed! But even more so by your answer. –  Emanuel Berg Feb 17 '12 at 2:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.