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: master 361c5fc2d8e 3/3: Support more predicates in tree-sitter search functions Date: Thu, 13 Apr 2023 18:57:50 -0700 Message-ID: References: <168142374534.3804.10641447592850495150@vcs2.savannah.gnu.org> <20230413220905.E3C7BC13A84@vcs2.savannah.gnu.org> <87o7nrjq0k.fsf@yahoo.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) 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="33043"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 14 03:58:59 2023 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 1pn8iI-0008SE-VZ for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Apr 2023 03:58:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pn8hV-0006em-F1; Thu, 13 Apr 2023 21:58:09 -0400 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 1pn8hS-0006eV-V8 for emacs-devel@gnu.org; Thu, 13 Apr 2023 21:58:06 -0400 Original-Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pn8hR-0006f0-1Z for emacs-devel@gnu.org; Thu, 13 Apr 2023 21:58:06 -0400 Original-Received: by mail-pj1-x1036.google.com with SMTP id fw22-20020a17090b129600b00247255b2f40so3096835pjb.1 for ; Thu, 13 Apr 2023 18:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681437483; x=1684029483; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LiVN0Ulr1xRNxO2JmzmCXXVrYzT56ZOXM8+bjs4mXTU=; b=ND882KPbng4SLL4MlB1ATu8+d0rq1nQT1xmbAZPVrYXv6LT7OVhYwtWGBDqRXdBjOh IaR5d5G7SdophbiN02+pGhOq7FCjsc4ncmFSDq53/eEPWreWZeD7vByqHESFyfeIKGBj UtU4izL7N4t/GqddaWsxMX2evhZbWybqGdKF2yGPyYDazGovhFf6MO6pxl92IL2Ue0qj fOSrESc1ep/lNL58P3GEnaEXzanhyOvt72Z5KGwyxVsB+SFzKtn8BNHgBcl6uZRwAtq7 uYvBhZ3YVwHN+BEJ4CbqN751DLLizojP4/AanCXxr/Hga4DCzXmBtNz9QPpT1B8EjOiL 9DFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681437483; x=1684029483; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LiVN0Ulr1xRNxO2JmzmCXXVrYzT56ZOXM8+bjs4mXTU=; b=flgRz/Lh4OlrhDqOYN7uu9woq94ZWME12XpXwopazN9CLQQKXsKFnpD8OzAOiWbba9 2dX9acKseo7RXzpur3IB64euwFJ4ceByEIepZibC11QTjU1Zl35f4Lsg0dLYBXdp/I0/ Uzpwq2FBS0AP8KRlr6HQMO4xT3BLEwooP1ZR0VImMHVChxPY+e925LUGgStzTb76MlXH KCqf+T8rNxpF1o3I6vZU2DRkkzT2aStqv20dE0XmnchdE9vJ1Ah2lLsBwkK2Olh58Rw6 uoVOoH8qTL6aKXkCW7QVUGxFkXWmb0cIwrkOhHvfD3QcIQLWuLdNgYr9quRd2Six0vzo 8u3w== X-Gm-Message-State: AAQBX9fhBcqAWlmTuGRzzdSzy0vSLEpjvkQxkMb3stlBMcRI2VJQpz4U ZuPfWJvR3k9c1uGmQFumuPY= X-Google-Smtp-Source: AKy350Yo1H4pw3EToTTfKf+DnPA0pk0LvelaFwmrO+Xs3wgpHXH52mFITTg6jhfIC1Dekfeov+USXQ== X-Received: by 2002:a17:90a:4598:b0:247:471:143b with SMTP id v24-20020a17090a459800b002470471143bmr3679041pjg.26.1681437482521; Thu, 13 Apr 2023 18:58:02 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id gi7-20020a17090b110700b00246844d364esm1899556pjb.45.2023.04.13.18.58.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Apr 2023 18:58:02 -0700 (PDT) In-Reply-To: <87o7nrjq0k.fsf@yahoo.com> X-Mailer: Apple Mail (2.3731.500.231) Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=casouri@gmail.com; helo=mail-pj1-x1036.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.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:305301 Archived-At: It seems that you=E2=80=99ve fixes most of the things you mentioned, = thanks. > How is this function robust against deeply nested or circular = predicate > structures? Shouldn't there be a recursion limit? Ok, I can add a recursion limit check. > Please remove the redundant braces. Is it really necessary? IMHO having the braces is clearer when the = statement has more than one line. >=20 > ISTM that if `treesit_traverse_validate_predicate' returns false, > `signal_data' is always initialized. I like to always initialize variables. >=20 > The initialization of `signal_data' is thus redundant. In fact, I'm > pretty sure you could have `treesit_traverse_validate_predicate' = return > Qnil upon success, and a signal upon failure. Either way should be fine. I=E2=80=99ve been using the current style = throughout treesit.c. >=20 >> if (!NILP (process_fn)) >> CHECK_TYPE (FUNCTIONP (process_fn), Qfunctionp, process_fn); >> @@ -3595,6 +3718,7 @@ syms_of_treesit (void) >> DEFSYM (Qoutdated, "outdated"); >> DEFSYM (Qhas_error, "has-error"); >> DEFSYM (Qlive, "live"); >> + DEFSYM (Qnot, "not"); >>=20 >> DEFSYM (QCanchor, ":anchor"); >> DEFSYM (QCequal, ":equal"); >> @@ -3619,6 +3743,7 @@ syms_of_treesit (void) >> "user-emacs-directory"); >> DEFSYM (Qtreesit_parser_deleted, "treesit-parser-deleted"); >> DEFSYM (Qtreesit_pattern_expand, "treesit-pattern-expand"); >> + DEFSYM (Qtreesit_invalid_predicate, "treesit-invalid-predicate"); >>=20 >> DEFSYM (Qor, "or"); >>=20 >> @@ -3646,6 +3771,9 @@ syms_of_treesit (void) >> define_error (Qtreesit_parser_deleted, >> "This parser is deleted and cannot be used", >> Qtreesit_error); >> + define_error (Qtreesit_invalid_predicate, >> + "Invalid predicate, see TODO for valid forms for a predicate", >> + Qtreesit_error); >=20 > Shouldn't this be in actual documentation and not etc/TODO? Oh, that=E2=80=99s not etc/TODO. I=E2=80=99m going to add a variable in = treesit.el which would document the shape of predicates, then I=E2=80=99ll= replace the TODO with the name of that variable. At least that=E2=80=99s = the plan for now. Yuan