Hello, I tumbled on the error in the subject, "Selecting deleted buffer", evaluating the following line in the "*scratch*" buffer with C-j: (kill-buffer (current-buffer)) When the other buffer isn't read-only, suppose "*foo*" is selected after killing the current buffer "*scratch*", the error "Selecting deleted buffer" appears into the echo area and the return value of the evaluation is printed into the other buffer "*foo*". If the other buffer is "*Messages*", which is read-only, the error "Buffer is read-only: #" will appear instead. I'd like to discuss the possibility to enforce printing the output either to the initial current buffer when eval-print-last-sexp has been called, or to the echo area when the prefix '-' is given. If the initial current buffer (aka standard-output) is killed, during the evaluation of the expression, we fall back to the echo area as the output medium. I attach a patch as proof of concept. Below there's a version of the current eval-print-last-sexp, as of commit 7e8d1b08e3e23bc783cad10e620c2ebe6536965c, well commented: (defun eval-print-last-sexp (&optional eval-last-sexp-arg-internal) (interactive "P") (let ((standard-output (current-buffer))) ;; This prints to `standard-output', aka `current-buffer'. (terpri) ;; Since `eval-last-sexp-arg-internal' is always replaced with t ;; when nil, the expression's return value is printed to what is ;; the actual `current-buffer' after the evaluation is done. If ;; the initial buffer is killed, the current buffer is something ;; else after the evaluation. "Buffer is read-only" is given if ;; the `current-buffer' is read-only, otherwise the return value ;; is printed at whatever is the actual `current-buffer' cursor. (eval-last-sexp (or eval-last-sexp-arg-internal t)) ;; This prints to `standard-output', aka `current-buffer' before ;; the expression is evaluated. If the `standard-output' buffer ;; has been killed evaluating the expression, the PRINTPREPARE C ;; macro will trigger an error trying to `set-buffer' the killed ;; buffer: "Selecting deleted buffer". (terpri))) Thank you. Best regards, -Matthew