From: Daniel Koning <dk@danielkoning.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 41781@debbugs.gnu.org
Subject: bug#41781: 27.0.91; [PATCH] Eldoc describes the wrong function when reading an expression from the minibuffer
Date: Mon, 22 Jun 2020 19:08:57 -0500 [thread overview]
Message-ID: <m2o8pazlra.fsf@danielkoning.com> (raw)
In-Reply-To: <jwv7dw1itbk.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 20 Jun 2020 12:51:19 -0400")
[-- Attachment #1: Type: text/plain, Size: 2425 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> When eldoc is activated in the minibuffer and uses the elisp backend
> because we're reading an elisp expression, then the syntax-table should
> also be set accordingly, indeed (not only for eldoc but also for
> forward-sexp, ...).
>
> Looks like a bug in the corresponding function (`read-expression` or nearby).
OK, I've attached another patch for that function.
>>> For one, the elisp-mode.el function `elisp--current-symbol' isn't
>>> wrapped in a `with-syntax-table', unlike other similar definitions
>>> in the same file. I think anyone invoking this function could
>>> reasonably expect it to observe elisp syntax, so that's what my tiny
>>> patch addresses.
>
> It's probably OK to do it as in your patch, yes.
>
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'. It
does have a silent dependency on the syntax table, which is arguably an
inherent bug. But it's an internal function which only (right now) gets
called in one place.
> I'm pretty sure just calling the major will break something.
> I can't offhand tell you what, tho. Writing the comment was faster than
> trying it out and then seeing how to fix the corresponding problems.
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). 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. 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.
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.
Daniel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: read--expression patch --]
[-- Type: text/x-patch, Size: 1283 bytes --]
From 7b3a19b3616b3a1c8dbd26673f2034bc6b19ebed Mon Sep 17 00:00:00 2001
From: Daniel Koning <dk@danielkoning.com>
Date: Mon, 22 Jun 2020 19:03:20 -0500
Subject: [PATCH] lisp/simple.el (read--expression): Set syntax table.
Use `emacs-lisp-mode-syntax-table' when reading a Lisp expression from
the minibuffer.
Copyright-paperwork-exempt: yes
---
lisp/simple.el | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index ea16d1400c..8e71432f9c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1608,8 +1608,11 @@ read--expression
(let ((minibuffer-completing-symbol t))
(minibuffer-with-setup-hook
(lambda ()
- ;; FIXME: call emacs-lisp-mode (see also
- ;; `eldoc--eval-expression-setup')?
+ ;; FIXME: instead of just applying the syntax table, maybe
+ ;; use a special major mode tailored to reading Lisp
+ ;; expressions from the minibuffer? (`emacs-lisp-mode'
+ ;; doesn't preserve the necessary keybindings.)
+ (set-syntax-table emacs-lisp-mode-syntax-table)
(add-hook 'completion-at-point-functions
#'elisp-completion-at-point nil t)
(run-hooks 'eval-expression-minibuffer-setup-hook))
--
2.20.1
next prev parent reply other threads:[~2020-06-23 0:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 2:56 bug#41781: 27.0.91; [PATCH] Eldoc describes the wrong function when reading an expression from the minibuffer Daniel Koning
2020-06-20 7:49 ` Eli Zaretskii
2020-06-20 16:51 ` Stefan Monnier
2020-06-23 0:08 ` Daniel Koning [this message]
2020-06-23 4:17 ` Stefan Monnier
2020-06-23 13:58 ` Daniel Koning
2020-06-23 14:09 ` Stefan Monnier
2020-06-23 16:42 ` Daniel Koning
2020-06-23 18:37 ` Stefan Monnier
2020-07-04 7:57 ` Eli Zaretskii
2020-08-05 15:59 ` Lars Ingebrigtsen
2020-08-08 8:09 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2o8pazlra.fsf@danielkoning.com \
--to=dk@danielkoning.com \
--cc=41781@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).