Chapter 4: Commands 15
• No numeric argument was supplied to the command (i.e. it was typed as n ormal, with
no C-u prefi x ).
You can configure the precise circumstances in which newlines get inserted (see see
Chapter 8 [Custom Auto-newlines], page 34). Typically, the style system (see Section 6.3
[Styles], page 27) will have s et this up for you, so you probably won’t have to bother.
Sometimes CC Mode inserts an auto-newline where you don’t want one, such as after a
‘}’ when you’re about to type a ‘;’. Hungry deletion can help here (see Section 4.8 [Hungry
WS Deletion], p age 15), or you can activate an appropriate clean-up, which will remove the
excess whitespace after you’ve typed the ‘;’. See Chapter 9 [Clean-ups], page 40 for a full
description. See also Section 4.6 [Electric Keys], page 12 for a summary of clean-ups listed
by key.
4.8 Hungry Deletion of Whitespace
If you want to delete an entire block of whitespace at point, you can use hungry deletion.
This deletes all the contiguous whitespace either before point or after point in a single
operation. “Whitespace” here includes tabs and newlines, but not comments or preprocessor
commands. Hungry deletion can markedly cut down on the number of times you have to
hit deletion keys when, for example, you’ve made a mistake on th e preceding line and have
already pressed C-j.
Hungry deletion is a simple feature that some people find extremely u s eful. I n fact, you
might find yourself wanting it in all your editing modes!
Loosely speaking, in what follows,
h
DEL
i
means “the backspace key” and
h
DELETE
i
means
“the forward delete key”. This is d iscus sed in more detail below.
There are two different ways you can u s e hungry deletion:
Using Hungry Delete Mode with
h
DEL
i
and C-d
Here you toggle Hungry Delete minor mode with M-x c-toggle-hungry-state
9
(see Section 4.5 [Minor Modes], page 11.) This makes
h
DEL
i
and C-d do back-
wards and forward hungry deletion.
h
DEL
i
(c-electric-backspace)
This command is r un by default when you hit the DEL key. When
hungry delete mode is enabled, it deletes any amount of white-
space in the backwards direction. Otherwise, or when used with
a prefix argument or in a literal (see Section 4.7 [Auto-newlines],
page 14), the command just deletes backwards in the usual way.
(More precisely, it calls the function contained in the variable c-
backspace-function, passing it the prefi x argument, if any.)
c-backspace-function
Hook that gets called by c-electric-backspace when it doesn’t
do an “electric” deletion of the preceding whitespace. The default
value is backward-delete-char-untabify (see section “Deletion”
in GNU Emacs Lisp Reference Manual, the function which deletes
a single character.
9
Prior to CC Mode 5.31, this command was bound to C-c C-d. C-c C-d is now the default binding for
c-hungry-delete-forward.