When This is reproducible in emacs -Q in my version of GNU Emacs running on my Ubuntu machine:

GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of 2017-09-22, modified by Debian

The steps below are intended to allow me to "select" (mark) all of the text in the default value of any minibuffer prompt, and immediately start typing which should erase the marked text (M-x delete-selection-mode), but not error out with the "Text is read-only" error because I've also marked the prompt part of the minibuffer text:

  1. Type: M-x eval-expression
  2. Type: (read-string "foo")
  3. Type: C-x h which runs the command mark-whole-buffer which positions point at (point-min) in the minibuffer, which is just to the left of the read-only text
  4. Type: x (or any character that would insert that character)
  5. See the error: Text is read-only

What I expect to happen is that only the writable text is selected by C-x h and not the read-only prompt text.

I don't want to have to play games with hook functions that I replace the C-x h binding to (e.g., using text properties such as given in https://emacs.stackexchange.com/a/2133/15483), unless there isn't a cleaner way.

I tried to use the tips suggested in http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html but that does not inhibit motion back to (point-min), that is, this does not work:

(setq minibuffer-prompt-properties (quote (read-only t cursor-intangible t face minibuffer-prompt)))

I suspect there is some special property (https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Properties.html) that prevents the cursor from "hopping over" the read-only prompt part of the minibuffer, but I can't figure out just what it might be.

1 Answer 1


In Emacs 26.1 there is an updated definition of mark-whole-buffer that avoids the problem you describe:

(defun mark-whole-buffer ()
  "Put point at beginning and mark at end of buffer.
If narrowing is in effect, only uses the accessible part of the buffer.
You probably should not use this function in Lisp programs;
it is usually a mistake for a Lisp function to use any subroutine
that uses or sets the mark."
  (declare (interactive-only t))
  (push-mark (point-max) nil t)
  ;; This is really `point-min' in most cases, but if we're in the
  ;; minibuffer, this is at the end of the prompt.
  (goto-char (minibuffer-prompt-end)))

If you can't update emacs you can add the new definition to your init file.


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.