If I want to delete everything in a buffer with elisp, how do I do that?
Have you tried
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
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).