2

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).

3 Answers 3

4

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!
2
  • This was the problem. I copied the code from a website. Somehow, all the quotes (single and double) became smartquotes.
    – Rob Jones
    Sep 10, 2009 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, 2009 at 17:23
5

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.

-2

This is a start, here is a somewhat relevant page http://www.delorie.com/gnu/docs/emacs/emacs_496.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_502.html

2
  • 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, 2009 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 Sep 10, 2009 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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