Subject: bug#41781: 27.0.91; [PATCH] Eldoc describes the wrong function when reading an expression from the minibuffer

From: Stefan Monnier <[email-masked]>
Date: Tue, 23 Jun 2020 00:17:27 -0400

>> Looks like a bug in the corresponding function (`read-expression` or nearby).
> OK, I've attached another patch for that function.

Looks good to me, thanks.

> If you change `read--expression', I don't know whether you'll think it
> makes sense to add the extra overhead to `elisp--current-symbol'.

I'm not worried about the overhead, but I don't like the potential
syntax-ppss interaction, so if it's not needed, I'd rather not go there.

> I can confirm that it suffers from the fairly significant drawback of
> not working at all.  Since the major replaces the minibuffer-specific
> keymap, nothing ends up bound to `exit-minibuffer', so you can't even
> enter an expression (or do anything else, like history paging).

Fun!  Thanks for trying ;-)

> You could bind `overriding-local-map' at the top of the function, but
> with that and the syntax table you're getting close to implementing
> a de facto new mode inside the de jure old one. At that point it might
> as well be a real custom major mode, as you suggested.

Right.  It's probably worth doing something here in the longer run, tho.
E.g. the `minibuffer-local-map` and friends should really be major mode
maps (and the inheritance between the maps should probably be reflected as
inheritance between corresponding modes).  Then you'd create an
`emacs-lisp-minibuffer-mode` by deriving from some "normal" `minibuffer-local-mode`.

> And then there's the possibility that some people's
> `emacs-lisp-mode-hook' might contain code that assumes it's in a real
> buffer and misbehaves in the minibuffer.

Indeed.

> On the other hand, you could do what eshell does for `eshell-command'
> and turn on its major mode in the minibuffer while selectively binding
> C-j, C-m, M-p, etc., inside the setup hook.  I don't like this design at
> all: if I were to make changes to my `minibuffer-local-map' bindings,
> eshell would silently ignore them.  Any custom mode for minibuffer input
> should inherit an existing minibuffer keymap, in my book at least.

Agreed.

        Stefan