From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: feature/tree-sitter 06db8015ea 1/5: Extract out treesit_make_ranges Date: Tue, 15 Nov 2022 19:52:22 +0800 Message-ID: <87bkp8h1u1.fsf@yahoo.com> References: <166850936462.27011.17289179422833914249@vcs2.savannah.gnu.org> <20221115104926.4D491C0E4C8@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3162"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Yuan Fu To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 15 12:53:25 2022 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 1ouuVJ-0000gt-4y for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Nov 2022 12:53:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouuUl-0002Vx-Vh; Tue, 15 Nov 2022 06:52:51 -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 1ouuUg-0002Qb-Ut for emacs-devel@gnu.org; Tue, 15 Nov 2022 06:52:46 -0500 Original-Received: from sonic312-23.consmr.mail.ne1.yahoo.com ([66.163.191.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ouuUb-0000Vh-9F for emacs-devel@gnu.org; Tue, 15 Nov 2022 06:52:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1668513154; bh=SvJhPTKq52kQOM6QvKjHrei+7hR87ktvQZOEbas3DOc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=B0edjIxaU2BFmkug82TxNeQ1XeyEaTyQGk4rNJLm48HMBFPrZ9R8J/GFrN2hmdSnZboUyt2Bo5PFMkA50O0WGYXtWfVUgNabi5IYukZ7zGtOgX/FMcUYSz3zgofYmlpyu0TTHaHAn94ng9hYEgGhiyDpThf/errWGYZhTG8YK5bYl0oN3QVKI+keTZ3kDZ4kqFpvW3uPdnSiwHi6Kk4ZTDV7t8LcBlVmsVN9arc6dzevMGaWyvLBv8ZNI0L0HQrwHLhNsG+hqIWiRsp6xjgKVO5PsNIQu/JRR4yZZT5LfRxIzFHFnSAqUK+rLTGARFfwirv+7WDKd78K+SN4jV+m7Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1668513154; bh=qFyDuVEAJrBB+mkNyNsKCiDJVd92PN4/1AHS6CTLXA6=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=HkIDW3Dk7KRaasSbtU71krnerkDFCP23VZGzhwTLOHiM2Xwtun6Q/wdWe11zpWpjM3I+4kQ0HL8oEYN4qoEFBSynSNp03CAkRJzQmueunPnaQ57GW4+tP0NwOMyCP2VdfUfBSwi6vyCZJsXX1J2iyFR5FKj4JIh0XbBsJ9D8riZe1EwQ88S1CXpRfaFl3eeYf491FnjW/RDucvWf44AIAbMb4+urTo9dC99p5OAy0VTKkI3iX1PqwUJa49w1o/1gtmlu4D4b4our6zsxhFIf2ljNm2D12uQVBAh5zyYHg6kPil6bUX35a65Va91IgX+JAGPvADlbt5A/U1KfoAo4TQ== X-YMail-OSG: k_Kv.TAVM1mthjkKPglseGvYrz3_atcR_vgnPZ5ask57MCUgobtW16gVagEMHQf YkZOzFhcp0wzkkdjpjjKK_gOdfQdAccyGkkPTBNoZStH0sI4H5fwe5Qp0ULiGNsR24Un0oaxpe3z 5Aq1HE35jmMagEZh_LvQArgNvm3PPqUaRkgFiWIES8XziDPYpXgiJZpGPz2fn34qoX5ktHqpjFHz u8eU.trXzseYIP58moKAGOX2oserXWuuM1xQQkK3Ug2Q5HxXn36eRC66irownEwsGQREBgZfAWlk 7t915BKSw.yc3DaMqt62.90dzh9_vmiQD8Nd3BBVfvX0ZnpOd5zwoZz28BO6_FeeWsMnSm19e7aY tgH4t8Hna6k2emTnMKAjI510GiPG17tbtibiqpsatXA.kOWdcDAh6gPMkRxuwQHXhJB9OI3nU.93 Mwav8vKFhya6OMgozvSn2YjvKPRRbw04pqg8qsWvM5zDkWLFZY8Ax9g78uECO3c98fnkiTRBxRkf _wLjwKxaDcq0gtlc4LBRVzITfE7TGJ0aFOtgDfP04.L6t1pbL4dvTtwBWqgv8TyIJBFVgX2dZA5Q TASPQSfeg7Olg6xUJa9zH4Sa1TknxfAICFdKlkasZX.ma9LpyeG_66PwXygPtmqEsal3GqdoHyuZ 7a498o8dSYKYHh9.OJSVPF33nQ3HBjuJHyopycYDww_5Y712ihcIrcJ5DHpQDJ3VvLTFIsc20Ynf SFxZfUmNBsDU28fXVcd0qJ7fRkPqwp2N1.SRYr98CeGOxlADvygDhh8YE04_N5L3fosBFszri0zw YYWLcg_nUDybwjP_3.XOiJFWkFma3LHCYtjJdVExy0 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Tue, 15 Nov 2022 11:52:34 +0000 Original-Received: by hermes--production-sg3-6c8895b545-26lc9 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 390f3c783b80a7b60837bd6688aa5067; Tue, 15 Nov 2022 11:52:28 +0000 (UTC) In-Reply-To: <20221115104926.4D491C0E4C8@vcs2.savannah.gnu.org> (Yuan Fu's message of "Tue, 15 Nov 2022 05:49:25 -0500 (EST)") X-Mailer: WebService/1.1.20863 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.191.204; envelope-from=luangruo@yahoo.com; helo=sonic312-23.consmr.mail.ne1.yahoo.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.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299842 Archived-At: Yuan Fu writes: > +/* Generate a list of ranges in Lisp from RANGES. This function > + doens't take ownership of RANGES. BUFFER is used to convert > + between tree-sitter buffer offset and buffer position. */ > +static Lisp_Object > +treesit_make_ranges (const TSRange *ranges, uint32_t len, > + struct buffer *buffer) > +{ > + Lisp_Object list = Qnil; > + for (int idx = 0; idx < len; idx++) > + { > + TSRange range = ranges[idx]; > + uint32_t beg_byte = range.start_byte + BUF_BEGV_BYTE (buffer); > + uint32_t end_byte = range.end_byte + BUF_BEGV_BYTE (buffer); > + eassert (BUF_BEGV_BYTE (buffer) <= beg_byte); > + eassert (beg_byte <= end_byte); > + eassert (end_byte <= BUF_ZV_BYTE (buffer)); > + > + Lisp_Object lisp_range > + = Fcons (make_fixnum (buf_bytepos_to_charpos (buffer, beg_byte)), > + make_fixnum (buf_bytepos_to_charpos (buffer, end_byte))); > + list = Fcons (lisp_range, list); > + } > + return Fnreverse (list); > + > +} There is a trailing newline after "return Fnreverse..."