From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70541: track-changes-mode logs warnings (with input method, in Eglot buffer) Date: Tue, 23 Apr 2024 23:14:16 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16429"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70541@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: Richard Copley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 24 05:15:20 2024 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 1rzT6O-000423-Ax for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Apr 2024 05:15:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzT61-0007iF-TR; Tue, 23 Apr 2024 23:14:57 -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 1rzT5z-0007hx-9x for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 23:14:55 -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 1rzT5z-0006qd-0A for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 23:14:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzT6F-0002Y9-54 for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 23:15:11 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Apr 2024 03:15:10 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70541 X-GNU-PR-Package: emacs Original-Received: via spool by 70541-submit@debbugs.gnu.org id=B70541.17139285059715 (code B ref 70541); Wed, 24 Apr 2024 03:15:10 +0000 Original-Received: (at 70541) by debbugs.gnu.org; 24 Apr 2024 03:15:05 +0000 Original-Received: from localhost ([127.0.0.1]:55937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzT62-0002Vb-FU for submit@debbugs.gnu.org; Tue, 23 Apr 2024 23:15:03 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11817) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzT5v-0002Sl-8e for 70541@debbugs.gnu.org; Tue, 23 Apr 2024 23:14:56 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D0BE4800D0; Tue, 23 Apr 2024 23:14:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1713928466; bh=i1xCb/VS8jpMU5/sL3UBqyrl+ZGFqNLCDy/pVSjiMoU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=W7wfq4X7krErdpr1PmohpWbOM4Y8T0atrR8UZZLMrdhmBoQc3JCc7y0tA4nOvZRB+ kxm34UI4BTwnR8lBafYb0+Cj8TGsxLb0ETAfSB7JqroPkcAPPg1UvKfaleuRk93Pa3 UPXfPuognqZbycwwsQeALswtkSbjFABaK1+kGUoXP391cgtfPRSYn9DjtsWOdkf0Va JeQa2SD6UNgA6PtyZJxWCEmv8HgquKffdBk5ZMBhAtXzs06Mru6YqxoFaF54cjX+IC fjZ+o2yvRnMtby7/OcFhVgXelD89vEQuiYTpSxRIerUijz4IXuHX/Cq3veclkMIjgY XVz/RnVpebOpw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B7FC980191; Tue, 23 Apr 2024 23:14:26 -0400 (EDT) Original-Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8E4F8120211; Tue, 23 Apr 2024 23:14:26 -0400 (EDT) In-Reply-To: (Richard Copley's message of "Tue, 23 Apr 2024 21:44:05 +0100") 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:283902 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > * Ensure clangd is on the path > * Start editing a scratch file like this in C++ mode: > > int main() { > const char * s =3D ""; > } > > * Start Eglot (M-x eglot RET) > * Enable TeX input method (C-u C-\ TeX RET) > * Start typing the superscript alphabet into the string (^ a ^ b ^ c ^ d = ...) > > How far you get before the warning pops up seems to depend on timing. To make it reliable, here's what you need to do after enabling the TeX input method: type "quickly"; foo^ wait a couple seconds and you should get the=20 =C2=BB Warning (emacs): Missing/incorrect calls to =E2=80=98before/af= ter-change-functions=E2=80=99!! Details logged to =E2=80=98track-changes--error-log=E2=80=99 The problem is that Quail inserts an underlined `^` in the buffer to show you the part of the input that's already been typed and it does so stealthily (i.e. within `with-silent-modifications`), which implies that the `before/after-change-functions` have not been called, and as a consequence the size of the buffer is not the one that track-changes expects (and the content of the buffer doesn't corresponds to what Eglot will send to the LSP server based on the changes it has witnessed, which can cause errors since Eglot has to send buffer positions and those may not mean the same any more for the LSP server). I suggest the patch below (the second hunk is unrelated, I just bumped into it while tracking this bug). Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=quail.patch diff --git a/lisp/international/quail.el b/lisp/international/quail.el index 48d2ccb8828..cb7aa89b252 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el @@ -1334,9 +1334,13 @@ quail-input-method (quail-setup-overlays (quail-conversion-keymap)) (with-silent-modifications (unwind-protect - (let ((input-string (if (quail-conversion-keymap) + (let* (;; `with-silent-modifications' inhibits the modification + ;; hooks, but that's a part of `with-silent-modifications' + ;; we don't actually want here (bug#70541). + (inhibit-modification-hooks nil) + (input-string (if (quail-conversion-keymap) (quail-start-conversion key) - (quail-start-translation key)))) + (quail-start-translation key)))) (setq quail-guidance-str "") (when (and (stringp input-string) (> (length input-string) 0)) @@ -1871,10 +1875,9 @@ quail-delete-last-char (defsubst quail-point-in-conversion-region () "Return non-nil value if the point is in conversion region of Quail mode." - (let (start pos) - (and (setq start (overlay-start quail-conv-overlay)) - (>= (setq pos (point)) start) - (<= pos (overlay-end quail-conv-overlay))))) + (let ((start (overlay-start quail-conv-overlay))) + (and start + (<= start (point) (overlay-end quail-conv-overlay))))) (defun quail-conversion-backward-char () (interactive) --=-=-=--