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: Mon, 26 Jul 2021 12:40:31 -0400 Message-ID: References: <83h7gw6pyj.fsf@gnu.org> <83y2a764oy.fsf@gnu.org> <83v95b60fn.fsf@gnu.org> <00DD5BFE-D14E-449A-9319-E7B725DEBFB3@gmail.com> <83r1fz5xr9.fsf@gnu.org> <1AAB1BCC-362B-4249-B785-4E0530E15C60@gmail.com> <83czri67h0.fsf@gnu.org> <46BBFF88-76C3-4818-8805-5437409BEA93@gmail.com> <83wnpq46uk.fsf@gnu.org> <533BD53B-4E85-4E9E-B46A-346A5BBAD0F5@gmail.com> <258CB68D-1CC1-42C8-BDCD-2A8A8099B783@gmail.com> <1a776770-50b7-93cd-6591-c9a5b3a56eb8@gmail.com> <8335s64v10.fsf@gnu.org> <5380C92B-6C15-4490-A1E0-1C3132DBB16A@gmail.com> <83k0li2shw.fsf@gnu.org> <86wnpg82v3.fsf@stephe-leake.org> <83lf5wyn0z.fsf@gnu.org> <86pmv66yqg.fsf@stephe-leake.org> <83a6maw705.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="30418"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?Q?Cl=C3=A9ment_Pit-Claudel?= , Stephen Leake , Stefan Monnier , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 26 18:41:13 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 1m83fD-0007kg-DH for ged-emacs-devel@m.gmane-mx.org; Mon, 26 Jul 2021 18:41:11 +0200 Original-Received: from localhost ([::1]:58792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m83fC-00087H-Bj for ged-emacs-devel@m.gmane-mx.org; Mon, 26 Jul 2021 12:41:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m83ee-0007Hp-Dr for emacs-devel@gnu.org; Mon, 26 Jul 2021 12:40:36 -0400 Original-Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:44698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m83ec-00015v-RN; Mon, 26 Jul 2021 12:40:36 -0400 Original-Received: by mail-qk1-x735.google.com with SMTP id k7so9405357qki.11; Mon, 26 Jul 2021 09:40: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=l/BmTvCIhPOaUdKJ2jkmt7RjZziE3yimp7Wfrr5Df8g=; b=TXpQHaal2xMfM24G5qQzsQ++hjWSuj6d8ifINwyNm90uoXx+5c4U3A9CT/XBkJRDLf GENcVZAiqw7Qr6gk8ZIPwCW1VnhZ8Rbx8dfncR6bRFi1Lp7zcgLt009hnipYp1WF9gmS 7/9qPNpy2O6S67n8mLrz3wZXhUMqG+Q34KnIwN7kp2LFNxnyDezaKYsQRkiybnynV7FB xs6Ow99xHrbt0HpvAmzT+rVRa/zBxDI9otEx1zYwvAFUptbqFI4JdJ03kTn9gyOg/mrO q/nyzqUTQk7kRpAyPC6iLrFRtYAm3iZj7ES4nA4B6DW+zzpg1+F4d542C6QN5YPW6UZE RBPg== 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=l/BmTvCIhPOaUdKJ2jkmt7RjZziE3yimp7Wfrr5Df8g=; b=osYQaEkYXfDp1fnCs9C0PcocudL5LkuMXIfk9ahRg2ssf4lSNzGYYiqctnE2pChzY1 XExzonVC/nujt2X9WUyBYdXJKy+nF2v9xit8QLIxJXWh17e8eJjsp+oQnbV6ybV/gRHs 4ao9paYxDw7UcalDAxQ972pgzpwjg8vHDFell6wHxTSarWYwI09kwJe+m08KBY+u/kCt uP0AoS/wpoCT9f4+sv1sbM6XptlYF9cvxREOlb/5Cl8Pv/Qg/v736TTG0G6ifwcYijUm AAHEJbPpg3GV4UscUKEohC/RoqCSTY7HS8/go63+Zl9mHOL/mDnA8vQ69hPLvtpo13L3 89xw== X-Gm-Message-State: AOAM532yJhwlKOTtTPIq3cBK+agWqhpNlELKh5dZ0eg//Qk8nGxh88AL dlBOiaMP59TSxcjN/8EBNRI5txmo5a5SeA== X-Google-Smtp-Source: ABdhPJz4i1eXIYuTk0itTta3nn0pG82+nJndpCxV68J+56AkOva/VQnFxR+pReDxDXwWHMJ7QD4Z1A== X-Received: by 2002:ae9:e30d:: with SMTP id v13mr17884621qkf.332.1627317633074; Mon, 26 Jul 2021 09:40:33 -0700 (PDT) Original-Received: from 2603-7080-0302-635e-540d-2222-3fe9-1314.res6.spectrum.com (2603-7080-0302-635e-540d-2222-3fe9-1314.res6.spectrum.com. [2603:7080:302:635e:540d:2222:3fe9:1314]) by smtp.gmail.com with ESMTPSA id u184sm255273qkd.53.2021.07.26.09.40.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Jul 2021 09:40:32 -0700 (PDT) In-Reply-To: <83a6maw705.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=casouri@gmail.com; helo=mail-qk1-x735.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:271653 Archived-At: >=20 >>>> unless the narrowing is for multi-major-mode. >>>=20 >>> And what would you do in that case, if you allow TS to look beyond = the >>> restriction? >>=20 >> In the multi-major-mode case, there is a separate parser for each >> language, and each sub-mode region in the text would get its own = parser >> tree (ie, it acts like a separate file), and that parser tree is only >> told about changes to those regions. So the parser will never try to >> look outside the region; it doesn't need to know about narrowing. >=20 > Once again, we are talking about the function used by TS to read > buffer text. Not about the parser or its caller. Low-level code, > which knows nothing about the context, should never look beyond the > restriction. It doesn=E2=80=99t harm for tree-sitter to see the rest of the buffer, = it doesn=E2=80=99t modify anything, all it does it reading the text. = OTOH, restricting tree-sitter to the bounds of narrows adds complexity = for no benefit (as far as I can see). Maybe narrowing is the context = that low level code should ignore, or at least tree-sitter should = ignore. The only benefit that I can think of is =E2=80=9Cwe firmly = adhere to the =E2=80=98contract=E2=80=99 that no one can look beyond the = narrowed region=E2=80=9D, but is it a good contract? Is there really a = contract in the first place? IMO, narrowing acts like masking tapes over = the rest of the buffer, so that user edits like re-replace wouldn=E2=80=99= t spill out. Demanding everything in Emacs to not have access to the = rest of the buffer is dogmatic (in the sense that it is too rigid and is = simply following the doctrine blindly).=20 And about language definitions and font-locking, I just realized that = tree-sitter language definitions provides highlighting patterns, and we = only need to minimally modify them to use them for Emacs, so there = aren=E2=80=99t much manual effort involved. Also, anyone have thoughts on how should tree-sitter intergrate with = font-lock beyond the current simple interface? Yuan=