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#61726: [PATCH] Eglot: Support positionEncoding capability Date: Fri, 24 Feb 2023 13:27:41 +0200 Message-ID: <83pm9znw0i.fsf@gnu.org> References: <87a614g628.fsf@gmail.com> <83cz60r7hu.fsf@gnu.org> <875ybsfvtj.fsf@gmail.com> <831qmgr17p.fsf@gnu.org> <87wn48ecdz.fsf@gmail.com> <83v8jspgnr.fsf@gnu.org> <87lekodxja.fsf@gmail.com> <83a614p4sh.fsf@gnu.org> <87cz60dus9.fsf@gmail.com> <835ybrpnqj.fsf@gnu.org> <87y1oncz09.fsf@gmail.com> <83r0ufo3uc.fsf@gnu.org> <87356vbf0b.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4575"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61726@debbugs.gnu.org, joaotavora@gmail.com To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 24 12:28:23 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 1pVWFS-00011w-Hw for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Feb 2023 12:28:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVWFA-0000p3-Hy; Fri, 24 Feb 2023 06:28:04 -0500 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 1pVWF9-0000of-0f for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 06:28:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVWF8-00059u-P2 for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 06:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVWF8-00067j-4y for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 06:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Feb 2023 11:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61726 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61726-submit@debbugs.gnu.org id=B61726.167723807323519 (code B ref 61726); Fri, 24 Feb 2023 11:28:02 +0000 Original-Received: (at 61726) by debbugs.gnu.org; 24 Feb 2023 11:27:53 +0000 Original-Received: from localhost ([127.0.0.1]:36082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVWEz-00067H-Eu for submit@debbugs.gnu.org; Fri, 24 Feb 2023 06:27:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVWEx-000673-Gd for 61726@debbugs.gnu.org; Fri, 24 Feb 2023 06:27:51 -0500 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 1pVWEq-00058E-MZ; Fri, 24 Feb 2023 06:27:45 -0500 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=fGNpM0a5fCPx+7fSNOTb3jqYrmBu53diqX+ovngbEtA=; b=Bh6rk3j/5By4XfgEVriv hAeqXmL5z4cX6U/ZGOgt8sZjLdA57kh/8r18fBYA+4Bv2TZ8Dgrm7KG+kDITkdGsH8rxjeY5+oqtM +vM7ai8ox7cn/ytsVXvgo88L8b07h6nxYzSQeGIXBzAAv+U1iMep1hf6hWTJPIOknCg03Vz4zNKpS tad9rX63l9uI6ljU9XfI2esCAQrKsrnI8e/lOin7K4Eq6h+1TwUlm+KhCZqIvZPuQDKm4OCdAX+X3 SbI2slLrGhmTnWHNZOq83bXBZy6AjjUwdlE88EO7+dChwHodws+yuj96KH8Xvuu6r4Y8h7XNoFf7L n+pfT2+uovWeVg==; 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 1pVWEn-0004hp-Vx; Fri, 24 Feb 2023 06:27:44 -0500 In-Reply-To: <87356vbf0b.fsf@gmail.com> (message from Augusto Stoffel on Fri, 24 Feb 2023 10:15:48 +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:256565 Archived-At: > From: Augusto Stoffel > Cc: joaotavora@gmail.com, 61726@debbugs.gnu.org > Date: Fri, 24 Feb 2023 10:15:48 +0100 > > >> -(defun eglot-current-column () (- (point) (line-beginning-position))) > >> +(defun eglot-current-column () > >> + "Calculate current column, counting Unicode codepoints." > >> + (- (point) (line-beginning-position))) > > > > Can we please take this opportunity to get rid of the confusing > > "column" terminology? As became evident from this discussion, we are > > not talking columns here, we are talking offsets in characters from > > BOL. So something like "pos" or "linepos" or "line-offset" should be > > better. > > > > João, are you okay with such a sweeping change in all of eglot.el? > > I like linepos, if João is fine with not making the absolute minimal > amount of changes to the code. João? > > As discussed, position-bytes is incorrect. You should instead do > > something like > > > > (length (encode-coding-string > > (buffer-substring-no-properties (point) > > (line-beginning-position)) > > 'utf-8-unix t)) > > But it is incorrect only if the buffer contains characters outside of > the Unicode range, right? If that happens, we already lost, because a > few steps later we will serialize the buffer text as JSON to send it to > the server: Why should one part of the code depend on what another part does? In my book, each part should do its job, and do it right. > > Also, for 100% reliable results, we should bind > > inhibit-field-text-motion to t when calling line-beginning-position. > > We should rather be using pos-bol, no? But how do we keep compatibility > with older Emacsen? Exactly. pos-bol is Emacs 29 and later, whereas Eglot is available from ELPA for older versions of Emacs. > >> + (tab-width 1) > > ^^^^^^^^^^^ > > This last part shouldn't be necessary: we should move by characters, > > not by columns. Why is it necessary? > > Maybe João can clarify, but I'm pretty sure this is there to support the > UTF-16 way of counting offsets, so this ideally should move to > eglot-move-to-lsp-abiding-column. Then perhaps the UTF-16 way of counting offsets should be changed as well.