I'm trying to reset the binding for "C-x C-c". Specifically, I want to rebind it to a function that asks me if I really want to quit (I just fat finger it way too much). I've done this before under Linux with no issues. Under Mac OS X, when I evaluate the expression

(global-unset-key “\C-x\C-c”)

I get:

eval-buffer: Symbol's value as variable is void: “C-xC-c”

So, why is it void? The command does exit Emacs, so it can't be void. I must not be referring to "C-x C-c" correctly. But what is the correct way?

I get the same problem when using global-set-key to bind the command sequence to a new function.

I'm using GNU Emacs 23.0.0 from MacPorts and Mac OS X 10.5 (Leopard).

link|improve this question
feedback

3 Answers

up vote 4 down vote accepted

Somehow, you are using smartquotes.

Use

(global-unset-key "\C-x\C-c")  ;; use this

instead of

(global-unset-key “\C-x\C-c”)  ;; Not this one!
link|improve this answer
This was the problem. I copied the code from a website. Somehow, all the quotes (single and double) became smartquotes. – Rob Jones Sep 10 '09 at 17:32
2  
A fair number of websites (say, all the WordPress blogs in the world that haven't been tweaked) will force change all quotes to smart-quotes. It's a plague for code copying. – Telemachus Sep 28 '09 at 17:23
feedback

Emacs has a configuration for what you asked that does not require to touch the C-x C-c binding.

Just add to your config one of the following:

(setq confirm-kill-emacs 'y-or-n-p)

(setq confirm-kill-emacs 'yes-or-no-p)

The first one will you ask you to type a single character y/n for confirmation, while the second one will ask you the full answer yes/no.

link|improve this answer
feedback

This is a start, here is a somewhat relevant page http://www.delorie.com/gnu/docs/emacs/emacs%5F496.html , but it seems what you want is to redefine the binding, not to remove it. Or just always have a modified file around, that way it will ask before quitting (and you could automate that in your .emacs or ~/.emacs.d/init.el )

http://www.delorie.com/gnu/docs/emacs/emacs%5F502.html

link|improve this answer
Those don't help much. I know what I want to do, and I'm fairly confident I'm going about it in the right manner. I don't understand how to represent C-x C-c. What I think I've used in the past is not working here. – Rob Jones Sep 10 '09 at 3:17
That is a really old manual. The OP is on Emacs 23. C-h i, or if you really want to read it on the web, gnu.org/software/emacs/manual/emacs.html – Richard Hoskins Sep 10 '09 at 4:50
feedback

Your Answer

 
or
required, but never shown

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