Subject: bug#77497: 30.1.50; "]" in the prompt in minibuffer-regexp-mode causes warning

From: Juri Linkov <[email-masked]>
Date: Thu, 03 Apr 2025 20:35:48 +0300

> 2. C-M-% ]
>
> 3. "]" is now in the prompt; type "foo" and see a minibuffer-message "Not in character
> alternative".
>
> 4. RET
>
> 5. C-M-%
>
> 6. "] -> foo" is in the prompt (as a default); type "bar" and also see a
> minibuffer-message "Not in character alternative".
>
> This also happens for longer strings e.g. "foobar]".
>
> This is especially annoying because C-M-% uses the previous M-%
> replacement as a default; so if M-% was used explicitly to replace a
> string containing ], it will confuse a subsequent C-M-%.

I can reproduce this with

  (read-regexp "Query replace regexp (default ]foo → ): ") bar

but not with

  (read-regexp "Replace regexp (default ]foo → ): ") bar