GNU bug report logs -
#64784
30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-marker-p return) in eglot--post-self-insert-hook
Previous Next
Reported by: Tassilo Horn <thorn <at> fastmail.fm>
Date: Sat, 22 Jul 2023 05:11:02 UTC
Severity: normal
Found in version 30.0.50
Done: João Távora <joaotavora <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 64784 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Tassilo Horn <thorn <at> 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
This bug report was last modified 1 year and 306 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.