From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fu Yuan Newsgroups: gmane.emacs.devel Subject: Re: How to add pseudo vector types Date: Tue, 3 Aug 2021 09:00:46 -0400 Message-ID: <5C591122-3D0D-4C34-BA43-7B42B31A91CF@gmail.com> References: <83bl6en2ax.fsf@gnu.org> Mime-Version: 1.0 (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="21853"; mail-complaints-to="usenet@ciao.gmane.io" Cc: cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 03 15:02:02 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mAu3V-0005Oo-QW for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 15:02:01 +0200 Original-Received: from localhost ([::1]:56532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAu3T-0006cf-I9 for ged-emacs-devel@m.gmane-mx.org; Tue, 03 Aug 2021 09:01:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAu2Q-0005w0-N2 for emacs-devel@gnu.org; Tue, 03 Aug 2021 09:00:54 -0400 Original-Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]:38466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAu2P-00016d-4J; Tue, 03 Aug 2021 09:00:54 -0400 Original-Received: by mail-qv1-xf2c.google.com with SMTP id cg4so5473953qvb.5; Tue, 03 Aug 2021 06:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=aVCxSh5v/DghrFuRt1bQMwd9yDrlUA+phU7c3NcRQFc=; b=ErRwit60Kg9dQ+IR5i4SLVY/YkJqlpI2u94JEfYrPoIfUrcBeGURyOpdtlJofgLWQR sM/6xXppE30rN7g1wS/qELcPZwarIYFQPLW4bJ3pDTyJ/fZou2E9XGEMRblPxwL7zE+F YFyPMwId9WAKatOHFHzqGlEbCojnCKyo06pKnaww4d1SV0duSHnCQEgigvJzxXk8Kouz FrNSjIq9oO+82gWP1khdNPUWZPTPPIGTjWxuOouvREoTEm/37bQSeiljy5U1ldVILNL/ mx4OBNEy/PJQteQiEBRoQYCA+ouQcLA3pB4fCEQtBq4IGWqE8V8BtUvSTNcWDQN6mLvt 0tWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=aVCxSh5v/DghrFuRt1bQMwd9yDrlUA+phU7c3NcRQFc=; b=h7wy7R9lvXTdIsdwF9MkHAzBxV5jviSlJgMk6wEKRbDrV1bBcAG5ZoC/4nEhuJIFg8 ZiC9OTQMChZ+g+486iECcyRB83fSYYLij9xw5f+n6DP4J4b6P56nao0kBQINcMEegHVD WfbxOEkStdj9u/sScCQj/tcicGuJG10RK3p3MtJkzkoTEfliBoYgOk7r/KWi43pOsWZu 5gAhaqKzEY+p2nQ68KcZ6oWpfAEk2vR762b/L2L7CDxe4IwwebVOwjWleZAcJn0hOIgV //dUGBFRBjmXzM4xpfpEnvHs186Zbw/TDLtWB9ddBWD9NMD+fVbqAP/6u/39I9d4nhqL rv6g== X-Gm-Message-State: AOAM5337m1m5HO+OdxoAUomPgUr2cO86Ztp4uIVglqxBrdG6ivDsgAxN 0COoPWS+BN8V16rcysFiA/w= X-Google-Smtp-Source: ABdhPJxhkOg9EbigjtE8xIW3d6I4jjsPGtmNsUxsahRWLUGHLgaj6+kYeknftDlE5jzwTRx6G9Eh/g== X-Received: by 2002:a05:6214:260a:: with SMTP id gu10mr372815qvb.33.1627995651230; Tue, 03 Aug 2021 06:00:51 -0700 (PDT) Original-Received: from ?IPv6:2607:fb90:a902:79bf:ece0:4f2a:436e:c17b? ([2607:fb90:a902:79bf:ece0:4f2a:436e:c17b]) by smtp.gmail.com with ESMTPSA id x7sm5823478qtw.24.2021.08.03.06.00.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Aug 2021 06:00:50 -0700 (PDT) In-Reply-To: <83bl6en2ax.fsf@gnu.org> X-Mailer: iPhone Mail (17H35) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2c; envelope-from=casouri@gmail.com; helo=mail-qv1-xf2c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271972 Archived-At: > =E5=9C=A8 2021=E5=B9=B48=E6=9C=883=E6=97=A5=EF=BC=8C=E4=B8=8A=E5=8D=888:25= =EF=BC=8CEli Zaretskii =E5=86=99=E9=81=93=EF=BC=9A >=20 > =EF=BB=BF >>=20 >> From: Fu Yuan >> Date: Tue, 3 Aug 2021 08:00:46 -0400 >> Cc: stephen_leake@stephe-leake.org, cpitclaudel@gmail.com, >> monnier@iro.umontreal.ca, emacs-devel@gnu.org >>=20 >>> Hmm... so a change that begins before the restriction and ends inside >>> the restriction will be sent as if it began at BEGV? And the rest of >>> the change will be discarded? Shouldn't you split such changes in >>> tow, send to TS the part inside the restriction, and store the rest >>> for the future, when/if the buffer is widened? >>=20 >> Tree-sitter doesn=E2=80=99t care about the content in a change, it will r= e-scan the buffer content when it re-parses. We only need to inform it the r= ange of the change, so it knows where to re-scan when it re-parses. When the= buffer is widened, we will tell tree-sitter that range [BUF_BEG, BUF_BEGV] h= as changed, and it will re-scan that part when re-parsing. >=20 > But that's sub-optimal, no? Imagine a very large buffer which was > narrowed to a small portion near EOB, then a modification made very > close to EOB but partially before BEGV, then the buffer widened. With > your method, TS will now have to re-parse almost the entire buffer, > whereas we know it needs to re-parse a very small portion of it. It is indeed, but that=E2=80=99s unavoidable by the way we hide the hidden p= art of the buffer from tree-sitter. We pretend BUF_BEGV is the beginning of t= he buffer and nothing exists before it. Then when we widen, we need to =E2=80= =9Cinsert=E2=80=9D the content between BUF_BEG and BUF_BEGV. I.e., as far as= tree-sitter can tell, we inserted that text. If you want to hide something then re-show it to tree-sitter, and want tree-= sitter to know how to re-parse minimally, you should use tree-sitter-parser-= set-included-ranges (ts_parser_set_included_ranges). I=E2=80=99ve wrote the l= isp binding for it but haven=E2=80=99t pushed the change. The reason why I didn=E2=80=99t implement narrow with set-ranges was explain= ed earlier. Yuan=