CC MODE Version 5 Documentation. Node: Hungry-deletion of whitespace

PREV Auto-newline insertion UP Minor Modes NEXT Auto-fill mode interaction

4.2: Hungry-deletion of whitespace

Hungry deletion of whitespace, or as it more commonly called, hungry-delete mode, is a simple feature that some people find extremely useful. In fact, you might find yourself wanting hungry-delete in all your editing modes!

In a nutshell, when hungry-delete mode is enabled, hitting the BACKSPACE key[1] will consume all preceding whitespace, including newlines and tabs. This can really cut down on the number of BACKSPACE's you have to type if, for example you made a mistake on the preceding line.

By default, when you hit the BACKSPACE key CC Mode runs the command c-electric-backspace, which deletes text in the backwards direction. When deleting a single character, or when BACKSPACE is hit in a literal (see Auto-newline insertion), or when hungry-delete mode is disabled, the function contained in the c-backspace-function variable is called with one argument (the number of characters to delete). This variable is set to backward-delete-char-untabify by default.

Similarly, hitting the DELETE key runs the command c-electric-delete. When deleting a single character, or when DELETE is hit in a literal, or when hungry-delete mode is disabled, the function contained in the c-delete-function variable is called with one argument (the number of characters to delete). This variable is set to delete-char by default.

However, if delete-key-deletes-forward is nil, or your Emacs does not support separation of BACKSPACE and DEL, then c-electric-delete simply calls c-electric-backspace.


[1] I say ``hit the BACKSPACE key'' but what I really mean is ``when Emacs receives the BackSpace key event''. The difference usually isn't significant to most users, but advanced users will realize that under window systems such as X, any physical key (keycap) on the keyboard can be configured to generate any keysym, and thus any Emacs key event. Also, the use of Emacs on TTYs will affect which keycap generates which key event. From a pedantic point of view, here we are only concerned with the key event that Emacs receives.

PREV Auto-newline insertion UP Minor Modes NEXT Auto-fill mode interaction