From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: How to add pseudo vector types Date: Thu, 15 Jul 2021 12:19:31 -0400 Message-ID: <00DD5BFE-D14E-449A-9319-E7B725DEBFB3@gmail.com> References: <83h7gw6pyj.fsf@gnu.org> <45EBF16A-C953-42C7-97D1-3A2BFEF7DD01@gmail.com> <83y2a764oy.fsf@gnu.org> <83v95b60fn.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) 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="37782"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 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 Thu Jul 15 18:20:44 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 1m446O-0009Zl-0h for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Jul 2021 18:20:44 +0200 Original-Received: from localhost ([::1]:49810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m446M-00034n-LU for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Jul 2021 12:20:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m445K-0001LF-8S for emacs-devel@gnu.org; Thu, 15 Jul 2021 12:19:38 -0400 Original-Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:45855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m445G-0004Qv-4r; Thu, 15 Jul 2021 12:19:37 -0400 Original-Received: by mail-qv1-xf2a.google.com with SMTP id ay16so3083548qvb.12; Thu, 15 Jul 2021 09:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=iYhcoBG6/e20KhA8brh6cRtuKF9/cBJ6D0L0NFW55ks=; b=ECYUos8Rpjr93t6/R3tfmdvqFtg5KfJS5K97KcLB1s7a892xsib33rHc8LELO8IjZy CgGW3ML6ZWgE6GmlVGXSk74I53dKoHyeJk7+311BKPIKiDfpaCyAgGzNkVl8vsdpV2El QRGqn9+rhmO2sKyzWkyPaEiSXrrJcbUbut7Si33upjc5Ul+M+8t8v3Nz60juD7f+2bHO fRbzjG6uUKIsgUPjSs/8PylCNU61OrR5MYqlKJupUt/XHgwJmst62TzNCrbRpwt+4Tr8 LX5W1e5ZlUOX/y7c80IovQt48GIWNxCirX+FnY5uGFOHq3SCwSK8zYpfKITYw1bMrCqM sxeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=iYhcoBG6/e20KhA8brh6cRtuKF9/cBJ6D0L0NFW55ks=; b=JCjukax14J5PnX9zb1WqdlfpcD+Qr/lA8KvB950iRjsbkZSsV3eFKr9G5EQh3gAfns iAgpQlSHa3JPCHOSlneAafCKssEj1L+7i/R+PYzy8NDC+0pI8AyduQyklmXQiFv4ePve qO9gwGaPnX+By70HONtja5rFdAr3jUu9KjtB2cpNxJcz0BpupOolrF2FYH/9/DKkEtVF 3AsqxHeHIBU0yY+BQSK3g4JM9Mn2BcmaMbxPB1qWevLywbz50Vdqk23vJfZloUYnoVLG OS1Vp+9jsa2fOAv6SkRQtqY+OlOdpvSyUO1astp5Vdh2KUKWNaT6Sxmi1+U/AoksGeMm wPiQ== X-Gm-Message-State: AOAM5319KURa9c5TwwwpaDBiiO0JXgHAwXcV5B89vAwpwx01mc2dJtBQ M7DPZZsZzw9vp0Ge4Puo3aJANUIZJtWtGw== X-Google-Smtp-Source: ABdhPJy2D0+qmdgh2VjEL2ndn/39+jxEICrFsXma8bqRdAMCCmxlft8ldgWyqrxbFiVvUOhVs5OaAg== X-Received: by 2002:a0c:fde3:: with SMTP id m3mr5217659qvu.55.1626365972801; Thu, 15 Jul 2021 09:19:32 -0700 (PDT) Original-Received: from ?IPv6:2601:98a:4200:9210:b02d:e0d8:dab6:21b? ([2601:98a:4200:9210:b02d:e0d8:dab6:21b]) by smtp.gmail.com with ESMTPSA id a62sm2741567qke.108.2021.07.15.09.19.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jul 2021 09:19:32 -0700 (PDT) In-Reply-To: <83v95b60fn.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=casouri@gmail.com; helo=mail-qv1-xf2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:271263 Archived-At: > On Jul 15, 2021, at 11:50 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Thu, 15 Jul 2021 11:17:02 -0400 >> Cc: Stefan Monnier , >> emacs-devel@gnu.org >>=20 >>> Great, then please try also to liberate the implementation from = using >>> JSON, it's a major slowdown factor. >>=20 >> JSON? I didn=E2=80=99t write anything involving JSON.=20 >=20 > Then what is json-module.zip about? That=E2=80=99s a language definition for tree-sitter, so it tells = tree-sitter how to parse a JSON file. There are definitions for Python, = Ruby, C, etc. I just used JSON for an example. It=E2=80=99s named = json-module because it is a dynamic module. >=20 >> While you are looking at the patch, here are some questions for = integrating tree-sitter with out buffer implementation. What I = envisioned is for each buffer to have a `parser-list=E2=80=99, and on = buffer change, we update each parser=E2=80=99s tree. I think modifying = signal_after_change is enough to cover al the cases? >=20 > Why do you need to do this when a buffer is updated? why not use > display as the trigger? Large portions of a buffer will never be > displayed, and some buffers will not be displayed at all. Why waste > cycles on them? Redisplay is perfectly equipped to tell you when some > chunk of buffer text is going to be redrawn, and it already knows to > do nothing if the buffer haven't changed. Tree-sitter expects you to tell it every single change to the parsed = text. Say you have a buffer with some content and scrolled through it, = so tree-sitter has parsed the whole buffer. Then some elisp edited some = text outside the visible portion. Redisplay doesn=E2=80=99t happen, we = don=E2=80=99t tell this edit to tree-sitter. Then I scroll to the place = that has been edited. What now? I=E2=80=99ve lost the change = information, and tree-sitter=E2=80=99s tree is out-dated. We can fontify on-demand, but we can=E2=80=99t parse on-demand. What we = can do is to only parse the portion from BOB to the visible portion. So = we won=E2=80=99t parse the whole buffer unless you scroll to the bottom. >=20 >> And, for tree-sitter to take the buffer=E2=80=99s content directly, = we need to tell it to skip the gap. >=20 > AFAIR, tree-sitter allows the calling package to provide a function to > access the text, isn't that so? If so, you could write a function > that accesses buffer text via BYTE_POS_ADDR etc., and that knows how > to skip the gap already. Yes, that function returns a char*. But what if the gap is in the middle = of the portion that tree-sitter wants to read? Alternatively, we can = copy the text out and pass it to tree-sitter, but you don=E2=80=99t like = that, IIRC. >=20 >> I only need to modify gap_left, gap_right, make_gap_smaller and = make_gap_larger, right? >=20 > Why would you need to _modify_ any of these? Because I want to let tree-sitter to know where is the gap so it can = avoid it when reading text. Yuan=