If I want to delete everything in a buffer with elisp, how do I do that?
Asked
Active
Viewed 7,132 times
3 Answers
31
Have you tried erase-buffer
?
erase-buffer is an interactive built-in function in `C source code'.
(erase-buffer)
Delete the entire contents of the current buffer.
Any narrowing restriction in effect (see `narrow-to-region') is removed,
so the buffer is truly empty after this.
How to find such a function? M-x apropos buffer erase

Drew
- 77,472
- 10
- 114
- 243
-1
There's also this answer:
C-x h + del
key clears the buffer
Note: This requires transient-mark-mode
to be enabled (which it is by default).

Joshua Goldberg
- 143
- 4
erase-buffer
is called. – lawlist Oct 19 '15 at 21:13kill-buffer
is your friend. – Drew Oct 19 '15 at 21:54