bug-gnu-emacs
[Top][All Lists]
Advanced

[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: João Távora
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
User-agent: Gnus/5.13 (Gnus v5.13)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]