Allow modifying the score of matches using a regex

This commit is contained in:
Kovid Goyal
2025-05-23 11:31:50 +05:30
parent daea53ac6d
commit 96436f10f7
4 changed files with 114 additions and 47 deletions

View File

@@ -24,7 +24,8 @@ opt(
add_to_default=True,
long_text='''
Regular expression to exclude directories. Matching directories will not be recursed into, but
you can still or change into them to inspect their contents. Can be specified multiple times. Matches against the absolute path to the directory.
you can still or change into them to inspect their contents. Can be specified multiple times.
Matches against the absolute path to the directory.
If the pattern starts with :code:`!`, the :code:`!` is removed and the remaining pattern is removed from the list of patterns. This
can be used to remove the default excluded directory patterns.
''',
@@ -37,6 +38,13 @@ opt('max_depth', '4', option_type='positive_int', long_text='''
The maximum depth to which to scan the filesystem for matches. Using large values will slow things down considerably. The better
approach is to use a small value and first change to the directory of interest then actually select the file of interest.
''')
opt('+modify_score', r'(^|/)\.[^/]+(/|$) *= 0.5', add_to_default=True, long_text='''
Modify the score of items matching the specified regular expression (matches against the absolute path).
Can be used to make certain files and directories less or more prominent in the results.
Can be specified multiple times. The default includes rules to reduce the score of hidden items.
The syntax is :code:`regular-expression operator value`. Supported operators are: :code:`*=, +=, -=, /=`.
''')
egr()
def main(args: list[str]) -> None: