GNU bug report logs - #61726
[PATCH] Eglot: Support positionEncoding capability

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Thu, 23 Feb 2023 08:06:01 UTC

Severity: normal

Tags: patch

Done: João Távora <joaotavora <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 61726 <at> debbugs.gnu.org, joaotavora <at> gmail.com
Subject: bug#61726: [PATCH] Eglot: Support positionEncoding capability
Date: Sat, 25 Feb 2023 15:47:21 +0200
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Cc: joaotavora <at> gmail.com,  61726 <at> debbugs.gnu.org
> Date: Sat, 25 Feb 2023 12:29:02 +0100
> 
> On Sat, 25 Feb 2023 at 12:57, Eli Zaretskii wrote:
> 
> >> From: Augusto Stoffel <arstoffel <at> gmail.com>
> >> Cc: joaotavora <at> gmail.com,  61726 <at> debbugs.gnu.org
> >> Date: Fri, 24 Feb 2023 19:08:14 +0100
> >> 
> >> I also didn't attempt to make 'eglot-move-to-bytewise-column' and
> >> 'eglot-bytewise-column' "correct" in the cases where 'json-serialize'
> >> throws an error.  I think it's clear that Eli and I have different
> >> definitions "correctness" in this context, but Eli's proposal requires
> >> substantial further work, including recovering from possible errors
> >> raising from 'json-serialize'.
> >
> > No, it doesn't.  All I'm asking for is to use encode-coding-string or
> > encode-coding-region to measure the actual number of bytes in a UTF-8
> > sequence that corresponds to a region of text.  Nothing else is
> > required or requested.
> >
> > Can you please humor me and implement eglot-bytewise-column like that?
> 
> I would be glad to do that, but unfortunately I'd have to ask your
> advice as to how to make the corresponding adaptation of
> eglot-move-to-bytewise-column.

Instead of this:

  (defun eglot-bytewise-column ()
    "Calculate current column using the LSP `utf-8' criterion."
    (- (position-bytes (point)) (position-bytes (line-beginning-position))))

use this:

  (defun eglot-bytewise-column ()
    "Calculate current column using the LSP `utf-8' criterion."
    (length (encode-coding-region (line-beginning-position) (point)
             'utf-8-unix t)))




This bug report was last modified 2 years and 139 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.