Python buffers support comint-delete-output, but if I forget to do it before entering another command, I have a big hunk of text I can't easily erase.

In shell mode, I can set the mark and run comint-previous-prompt, and then erase the region. But in Python buffers, it tells me that the text is read only. I can run read-only-mode, to attempt to turn it off, but it doesn't work.

If I try to kill the lines manually, it mostly works (but is too tedious), but one out of every 50 lines or so will be read-only and I can't kill it.

If I try something like M-1 0 0 C-k, it invariably tells me the text is read-only, and won't kill any of it.

Running GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2023-08-16

1 Answer 1


You should be able to use comint-clear-buffer ("C-c M-o") to remove everything. There is also comint-kill-region that should properly deal with the read-only prompts, at least according to its documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.