Monday, December 10, 2007

Emacs Tip #3: disabling commands

Emacs disables some commands by default, upcase-region is one such
command. I'm not sure why the commands are disabled, but they are,
and it can be real confusing when you come across one.

When you do, Emacs will prompt you with something like:


You have typed C-x C-u, invoking disabled command upcase-region:
Convert the region to upper case. In programs, wants two arguments.
These arguments specify the starting and ending character numbers of
the region to operate on. When used as a command, the text between
point and the mark is operated on.
See also `capitalize-region'.

You can now type
Space to try the command just this once, but leave it disabled,
Y to try it and enable it (no questions if you use it again),
! to try it and enable all commands in this session, or
N to do nothing (command remains disabled).


Very confusing for me.

One way of turning off such behavior is to add this to your .emacs:

(setq disabled-command-hook nil)

For more information on disabling commands, read the info page reached
by the following key sequence:

C-h i m elisp RET m disabling RET

1 comment:

Unknown said...

This can be achieved for individual commands with
(put 'upcase-region 'disabled nil)