[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#64784: 30.0.50; Eglot: Lisp error: (wrong-type-argument number-or-ma
From: |
Eli Zaretskii |
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 09:11:11 +0300 |
> 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?