emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 361c5fc2d8e 3/3: Support more predicates in tree-sitter searc


From: Yuan Fu
Subject: Re: master 361c5fc2d8e 3/3: Support more predicates in tree-sitter search functions
Date: Thu, 13 Apr 2023 18:57:50 -0700

It seems that you’ve 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.
> 
> ISTM that if `treesit_traverse_validate_predicate' returns false,
> `signal_data' is always initialized.

I like to always initialize variables.

> 
> 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’ve been using the current style throughout 
treesit.c.

> 
>>   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");
>> 
>>   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");
>> 
>>   DEFSYM (Qor, "or");
>> 
>> @@ -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);
> 
> Shouldn't this be in actual documentation and not etc/TODO?

Oh, that’s not etc/TODO. I’m going to add a variable in treesit.el which would 
document the shape of predicates, then I’ll replace the TODO with the name of 
that variable. At least that’s the plan for now.

Yuan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]