From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83a5voa328.fsf@gnu.org> References: <87bkg4bkfu.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34968"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64784@debbugs.gnu.org To: Tassilo Horn , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 22 08:11:28 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qN5pv-0008sA-Qj for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Jul 2023 08:11:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qN5pg-0005Hr-BV; Sat, 22 Jul 2023 02:11:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qN5pX-0005FO-2T for bug-gnu-emacs@gnu.org; Sat, 22 Jul 2023 02:11:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qN5pW-0002bN-QX for bug-gnu-emacs@gnu.org; Sat, 22 Jul 2023 02:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qN5pW-0006kx-By for bug-gnu-emacs@gnu.org; Sat, 22 Jul 2023 02:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jul 2023 06:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64784 X-GNU-PR-Package: emacs Original-Received: via spool by 64784-submit@debbugs.gnu.org id=B64784.169000624725949 (code B ref 64784); Sat, 22 Jul 2023 06:11:02 +0000 Original-Received: (at 64784) by debbugs.gnu.org; 22 Jul 2023 06:10:47 +0000 Original-Received: from localhost ([127.0.0.1]:35299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qN5pG-0006kT-PB for submit@debbugs.gnu.org; Sat, 22 Jul 2023 02:10:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qN5pC-0006kE-Dm for 64784@debbugs.gnu.org; Sat, 22 Jul 2023 02:10:45 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qN5p5-0002PE-Bo; Sat, 22 Jul 2023 02:10:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=3Rd/laCVII/RmjOgQzITVGdzJp5tURbBatWYseMjgPE=; b=JO2ZgshjPlG30pCmWKJa 5kuYKmhecrVSyoaLgjsgGUf9Y+YVoCGOmL2bIjAY7qxvoWdT2X3/LH+UUrw87yO5grXLeWab64coQ cIIqUfoWqYSOMB4zrkm74cXaZsWiZnEOy1hr7RZ+5oYg816ZhPSDEq1TTWFpOaoWk6tidKJSAo6vW hIR6LcUWEMrrVB32ecivqHWwlBV5xDVtAdVpvZvqrL8wgfCSI3J3AROGjDJroXjXeHLtoQic79eB0 wyck8K2bkaa3+wsq/PHzMmvU4p/BzHLkOJIfYjGGVEyfJ2RnXgJpEMPcGDZU13e9DHnlYnvC5TQoI HGlJ/TQFFqOTXg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qN5p4-0006nz-DX; Sat, 22 Jul 2023 02:10:35 -0400 In-Reply-To: <87bkg4bkfu.fsf@fastmail.fm> (message from Tassilo Horn on Sat, 22 Jul 2023 07:06:58 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:265774 Archived-At: > From: Tassilo Horn > 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?