From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Tassilo Horn <thorn@fastmail.fm>,
Stefan Monnier <monnier@iro.umontreal.ca>,
64784@debbugs.gnu.org
Subject: bug#64784: 30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-marker-p return) in eglot--post-self-insert-hook
Date: Sat, 22 Jul 2023 10:33:21 +0100 [thread overview]
Message-ID: <87h6pw9tpa.fsf@gmail.com> (raw)
In-Reply-To: <83a5voa328.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 22 Jul 2023 09:11:11 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Tassilo Horn <thorn@fastmail.fm>
>> Date: Sat, 22 Jul 2023 07:06:58 +0200
>>
>>
>> I'm in a rust-ts-mode buffer and ran eglot. When I hit RET (bound to
>> newline), I get the following error:
>>
>> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p return)
>> eglot--post-self-insert-hook()
>> self-insert-command(1)
>> newline(nil 1)
>> funcall-interactively(newline nil 1)
>> call-interactively(newline nil nil)
>> command-execute(newline)
>
> This is because eglot--post-self-insert-hook assumes last-input-event
> is a character:
>
> (defun eglot--post-self-insert-hook ()
> "Set `eglot--last-inserted-char', maybe call on-type-formatting."
> (setq eglot--last-inserted-char last-input-event)
> (let ((ot-provider (eglot--server-capable :documentOnTypeFormattingProvider))
> ;; transform carriage return into line-feed
> (adjusted-ie (if (= last-input-event 13) 10 last-input-event)))
> ^^^^^^^^^^^^^^^^^^^^^^^
>
> But in this case we get the symbol 'newline' as the value.
>
> The easy way out is to use characterp before comparing with =, but I
> actually think there's a deeper problem here, because the code which
> uses this post-self-insert-hook _wants_ to process inserted newlines.
> So I think a better fix here would be to use last-command-event, not
> last-input-event. All the other post-self-insert-hook implementations
> use that, AFAICT.
>
> Stefan, am I right? Can last-command-event, when accessed from
> post-self-insert-hook, ever be something other than a character?
Even before Stefan answers, 'last-command-event' sounds right to me. In
latest master, I've replaced the previous hacky solution with a
simplified one based on this 'last-command-event' and it doesn't need
any translation and works correctly on both TTY and GUI Emacs.
Tassilo, can you test?
João
next prev parent reply other threads:[~2023-07-22 9:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-22 5:06 bug#64784: 30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-marker-p return) in eglot--post-self-insert-hook Tassilo Horn
2023-07-22 6:11 ` Eli Zaretskii
2023-07-22 9:33 ` João Távora [this message]
2023-07-22 14:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-23 7:21 ` Tassilo Horn
2023-07-23 10:20 ` bug#64784: LSP vs Emacs indentation [Was: bug#64784: 30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-marker-p return) in eglot--post-self-insert-hook] João Távora
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=87h6pw9tpa.fsf@gmail.com \
--to=joaotavora@gmail.com \
--cc=64784@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=thorn@fastmail.fm \
/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).