From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= 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 10:33:21 +0100 Message-ID: <87h6pw9tpa.fsf@gmail.com> References: <87bkg4bkfu.fsf@fastmail.fm> <83a5voa328.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40001"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Tassilo Horn , Stefan Monnier , 64784@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 22 11:31:24 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 1qN8xQ-000AHV-Eo for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Jul 2023 11:31:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qN8x6-0001mf-4h; Sat, 22 Jul 2023 05:31:04 -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 1qN8x4-0001kw-CL for bug-gnu-emacs@gnu.org; Sat, 22 Jul 2023 05:31:02 -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 1qN8x4-0000KV-46 for bug-gnu-emacs@gnu.org; Sat, 22 Jul 2023 05:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qN8x3-00069K-V2 for bug-gnu-emacs@gnu.org; Sat, 22 Jul 2023 05:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jul 2023 09:31:01 +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.169001825623624 (code B ref 64784); Sat, 22 Jul 2023 09:31:01 +0000 Original-Received: (at 64784) by debbugs.gnu.org; 22 Jul 2023 09:30:56 +0000 Original-Received: from localhost ([127.0.0.1]:35474 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qN8wx-00068w-QF for submit@debbugs.gnu.org; Sat, 22 Jul 2023 05:30:56 -0400 Original-Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:53756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qN8wu-00068g-PX for 64784@debbugs.gnu.org; Sat, 22 Jul 2023 05:30:54 -0400 Original-Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-98df3dea907so419223666b.3 for <64784@debbugs.gnu.org>; Sat, 22 Jul 2023 02:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690018247; x=1690623047; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ch0vcw5YJkeY6R9T0g85vRCZeZT91llqraJDi2R0heM=; b=Girxrm3Syi3IHdQRquw1hTzYI5yCIGIOJg4TyzCsYtnyYlDE+khotGJabRJEUypRho kZRYRoSOHfAeIc9EejXXYWX1n0N2USSF2QjDv7SK5foH2nnPw9JZQeq7j4b8V2E4Ny7g NQ2usbhxCQIa/Lh+PKLxL9iUyxGeLioj5Ei7NAusgJyuEh6M3Fup3CcsodTcJTVLivvV 0tpFXRWFU266xeivGfZeY4T7MMmy62rDLl1gwT+EFK5qgKtaKn8WvntgA/xQRJVsH9Az uQ6pq+LwmdxLEFE3v/65zczSCoeQAS2DbOKzOlA0plqtribJvWCSGTxE1+keAfevqXaf WAWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690018247; x=1690623047; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ch0vcw5YJkeY6R9T0g85vRCZeZT91llqraJDi2R0heM=; b=PYIsK9hMJXQj8sehEl79d/55bWeH1ZkatI9ybxskbASzipGXtFyxajaDwNdx2FyPy0 zJUBPVvVo3MSN+bThlzvGN/Ru8ELcZUgfGMFAbXOJWx8v85EOQP4HBB+MTfPJ4usZKPA vO8djbWvAXodWeWswHi4xbMkXSZiI8zH4vpVgVbpCQ5xOqePpUazKf0HMWetu/XA/Skn XhwphYNqB+47T+jwQ2JYP/I1QHRYtx09nyg/dUjjKUz5TMoWh09JSZzpQPI3KoOBUo/E wd1hRaVQnD+tdPiPyKWlemOKI/9Sx0FOEjQV7kw0fFPUljE5tCekVdULby9h8nxnnDUq 650g== X-Gm-Message-State: ABy/qLaPWAD33SDeCua4NtGZDY0A0GrRf0cRUvQWvjFhalbDpZvz7Xsy Mq+GpT1AcAvTgIECVNXTBaIFiOSWj3I= X-Google-Smtp-Source: APBJJlFd8Q5jabSzZbkVYLbb/pbdCSd2XGfYMcKOmRTisVQLaDaSK2ToDMT1HG1auNu66le8HQY18g== X-Received: by 2002:a17:906:106:b0:986:d833:3cf9 with SMTP id 6-20020a170906010600b00986d8333cf9mr3983444eje.39.1690018246648; Sat, 22 Jul 2023 02:30:46 -0700 (PDT) Original-Received: from krug ([87.196.73.34]) by smtp.gmail.com with ESMTPSA id u20-20020a170906c41400b00993928e4d1bsm3251803ejz.24.2023.07.22.02.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jul 2023 02:30:46 -0700 (PDT) In-Reply-To: <83a5voa328.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 22 Jul 2023 09:11:11 +0300") 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:265793 Archived-At: Eli Zaretskii writes: >> From: Tassilo Horn >> Date: Sat, 22 Jul 2023 07:06:58 +0200 >>=20 >>=20 >> I'm in a rust-ts-mode buffer and ran eglot. When I hit RET (bound to >> newline), I get the following error: >>=20 >> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p re= turn) >> 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 :documentOnTypeFormattingPro= vider)) > ;; transform carriage return into line-feed > (adjusted-ie (if (=3D 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 =3D, 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=C3=A3o