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#61726: [PATCH] Eglot: Support positionEncoding capability Date: Sun, 26 Feb 2023 10:38:40 +0000 Message-ID: References: <87a614g628.fsf@gmail.com> <87y1oncz09.fsf@gmail.com> <83r0ufo3uc.fsf@gnu.org> <87356vbf0b.fsf@gmail.com> <83pm9znw0i.fsf@gnu.org> <87lekn9ss3.fsf@gmail.com> <83h6vbntqd.fsf@gnu.org> <878rgn9r6u.fsf@gmail.com> <83edqfnq5u.fsf@gnu.org> <83bkljnpck.fsf@gnu.org> <874jrb9l6d.fsf@gmail.com> <834jrbnlaf.fsf@gnu.org> <87v8jr83ic.fsf@gmail.com> <83v8jrm4r0.fsf@gnu.org> <87fsav7x81.fsf@gmail.com> <83a612ko73.fsf@gnu.org> <87ttza3rwh.fsf@gmail.com> <83356tluvq.fsf@gnu.org> <87a61125ox.fsf@gmail.com> <83wn45k8yu.fsf@gnu.org> <874jr9z94m.fsf@gmail.com> <83r0udj8ll.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="39759"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61726@debbugs.gnu.org, arstoffel@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 26 11:38:15 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 1pWEQ2-000ADe-Kx for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Feb 2023 11:38:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWEPw-0005hG-3X; Sun, 26 Feb 2023 05:38:08 -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 1pWEPq-0005aJ-EF for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2023 05:38:02 -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 1pWEPq-0004nZ-3h for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2023 05:38:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pWEPp-0000Qo-Ps for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2023 05:38:01 -0500 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: Sun, 26 Feb 2023 10:38:01 +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.16774078271585 (code B ref 61726); Sun, 26 Feb 2023 10:38:01 +0000 Original-Received: (at 61726) by debbugs.gnu.org; 26 Feb 2023 10:37:07 +0000 Original-Received: from localhost ([127.0.0.1]:42393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWEOx-0000PV-5V for submit@debbugs.gnu.org; Sun, 26 Feb 2023 05:37:07 -0500 Original-Received: from mail-ot1-f41.google.com ([209.85.210.41]:41710) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWEOv-0000Ow-Gu for 61726@debbugs.gnu.org; Sun, 26 Feb 2023 05:37:05 -0500 Original-Received: by mail-ot1-f41.google.com with SMTP id f19-20020a9d5f13000000b00693ce5a2f3eso2067526oti.8 for <61726@debbugs.gnu.org>; Sun, 26 Feb 2023 02:37:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677407820; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=E4kW/rshxOAiYvi7Wtj1z4ZMxMnirILzr+vl6QwBUvA=; b=f+YxoJmsGgylKATJg+tR3as0tzyLoDYmeAyrU1jsbZy0qglS3Gp+zr0QnyBTO6gwat 4d4wJH1V8KmaPU3zEYLJsCp5m3Q0Q9g7I84CvZy19x8ZSAQTZceYdQdlleUW/41RMseE JBFL+7eLME1ESW1YXaG76BrXrDZ9WQLHeHbks53HuaXfEM76JLeYbtDWBmnhm78tlqwT Xzu4KUm8IReurki1heck47XYotTeRDy1CPD8Uo8AyZ37GJjybL45k/879KdKQNySHQRy +kE/lNdmxDVbkPhEi+xp8ul9aVz6sweIZs4idM9K7311+leAJ44xawJMEF8NLO6BjJ8o B+PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677407820; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E4kW/rshxOAiYvi7Wtj1z4ZMxMnirILzr+vl6QwBUvA=; b=CTwYmsCq3JhewJBbZilOPhnM0NSYJD62eMXBJjgH/v7di3rVER5rRl+M1APCcQhuPT jUfb4QmKU7GimALoIX4Rov4dAu0f1xWq76cM+BQIFZAFVtiwmbUUGfuz6BPJlhZ+8nYc z88huQq++65X6pHBUHNwdQvX8jsawAbNMSjvlodxvQ9a3AueCuv/oA1lxqQIFgq2z0UM udvxZL8DMArndZywA7/194c7QlVaFokjf7cLUoNJN44XQ42ndJfjRFppMtxPa3V2cZaw 7j+3EfrTqot+MHiDuGwyP34ho3uaFd0PqG9Wvz8RYx0eAyoneyeTIkzxGPdm1h74uzkc 1GDw== X-Gm-Message-State: AO0yUKUCc/A8bN5Szdhe5yy6u9hymF6mJfTgxaGKjYeYx1zqRUS/50at l/JkS+Zt98IjhO7rkL2Tf7gW84ryadcL76f4UWc= X-Google-Smtp-Source: AK7set+AwKdGMojkqkUMGyt3u5kplxTzIuWDmMMTqZkgHPpCWPqdaOrLDA9gn9PtbgRbZFViPWDRGy0ls/XyXLG7vdM= X-Received: by 2002:a05:6830:39f1:b0:68b:ccee:5ead with SMTP id bt49-20020a05683039f100b0068bccee5eadmr3409418otb.3.1677407819994; Sun, 26 Feb 2023 02:36:59 -0800 (PST) In-Reply-To: <83r0udj8ll.fsf@gnu.org> 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:256782 Archived-At: On Sun, Feb 26, 2023 at 5:31 AM Eli Zaretskii wrote: > > > From: Jo=C3=A3o T=C3=A1vora > > Cc: Augusto Stoffel , 61726@debbugs.gnu.org > > Date: Sat, 25 Feb 2023 22:13:29 +0000 > > > > Eli Zaretskii writes: > > > > >> From: Augusto Stoffel > > >> Cc: joaotavora@gmail.com, 61726@debbugs.gnu.org > > >> Date: Sat, 25 Feb 2023 15:14:06 +0100 > > >> > > >> On Sat, 25 Feb 2023 at 15:47, Eli Zaretskii wrote: > > >> > > >> >> > Can you please humor me and implement eglot-bytewise-column lik= e that? > > >> >> > > >> >> I would be glad to do that, but unfortunately I'd have to ask you= r > > >> >> advice as to how to make the corresponding adaptation of > > >> >> eglot-move-to-bytewise-column. > > >> ^^^^^^^ > > > > > > Sorry. Here: > > > > > > (defun eglot-move-to-bytewise-column (column) > > > "Move to COLUMN as computed using the LSP `utf-8' criterion." > > > (let* ((bol (line-beginning-position)) > > > (goal-byte (+ (position-bytes bol) column)) > > > (eol (line-end-position))) > > > (goto-char bol) > > > (while (and (< (position-bytes (point)) goal-byte) > > > (< (point) eol)) > > > (if (>=3D (char-after) #x3fff80) ; raw bytes take 2 bytes in the= buffer > > > (setq goal-byte (1+ goal-byte))) > > > (forward-char 1)))) > > > > In eglot-move-to-lsp-abiding-column (the utf-16 sibling of this > > function) we use a binary search instead of a linear search. I remembe= r > > measuring a visible improvement. I'm not sure the conditions are > > exactly the same with this one. Could/should we do the same here? > > Fine by me, but optimizing a method that is not yet used sounds a bit > premature, no? I won't object, though. There's nothing to optimize there, there's no benefit to binary search. I think this type of function, which has some utf-8/16 knowledge directly in them, is the fastest option, much faster than using encode-coding-region like I was doing before. Jo=C3=A3o