Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Previous: Mouse Buttons, Up: Key Bindings


57.4.11 Disabling Commands

Disabling a command marks the command as requiring confirmation before it can be executed. The purpose of disabling a command is to prevent beginning users from executing it by accident and being confused.

An attempt to invoke a disabled command interactively in Emacs displays a window containing the command's name, its documentation, and some instructions on what to do immediately; then Emacs asks for input saying whether to execute the command as requested, enable it and execute it, or cancel. If you decide to enable the command, you are asked whether to do this permanently or just for the current session. (Enabling permanently works by automatically editing your .emacs file.) You can also type ! to enable all commands, for the current session only.

The direct mechanism for disabling a command is to put a non-nil disabled property on the Lisp symbol for the command. Here is the Lisp program to do this:

     (put 'delete-region 'disabled t)

If the value of the disabled property is a string, that string is included in the message displayed when the command is used:

     (put 'delete-region 'disabled
          "It's better to use `kill-region' instead.\n")

You can make a command disabled either by editing the .emacs file directly or with the command M-x disable-command, which edits the .emacs file for you. Likewise, M-x enable-command edits .emacs to enable a command permanently. See Init File.

If Emacs was invoked with the -q or --no-init-file options (see Initial Options), it will not edit your ~/.emacs init file. This is because editing the init file from such a session might overwrite the lines you might have on your init file which enable and disable commands.

Whether a command is disabled is independent of what key is used to invoke it; disabling also applies if the command is invoked using M-x. Disabling a command has no effect on calling it as a function from Lisp programs.


 
 
  Published under the terms of the GNU General Public License Design by Interspire