If you are an Emacs user like me, you must try out the consult-ripgrep command from the peerless Consult [1] package by Daniel Mendler: search your whole project with ripgrep and get a live preview of every matching candidate all inside of Emacs! [1]: https://github.com/minad/consult
Ripgrep 14 Released
41–50 of 73 posts
Re: Ripgrep 14 Released
#42Re: Ripgrep 14 Released
#43Re: Ripgrep 14 Released
#44It uses the abstract syntax tree (AST) of the source code to show how the matching lines fit into the code structure. It shows relevant code from every layer of the AST, above and below the matches.
It feels quite useful when you're grepping to understand how functions, classes, variables etc are used within a non-trivial codebase.
Here's a snippet that shows grep-ast searching the django repo. Notice that it finds `ROOT_URLCONF` and then shows you the method and class that contain the matching line, including a helpful part of the docstring. If you ran this in the terminal, it would also colorize the matches.
django$ gast ROOT_URLCONF
middleware/locale.py:
│from django.conf import settings
│from django.conf.urls.i18n import is_language_prefix_patterns_used
│from django.http import HttpResponseRedirect
⋮...
│class LocaleMiddleware(MiddlewareMixin):
│ """
│ Parse a request and decide what translation object to install in the
│ current thread context. This allows pages to be dynamically translated to
│ the language the user desires (if the language is available).
⋮...
│ def process_request(self, request):
▶ urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
[0] https://github.com/paul-gauthier/grep-astRe: Ripgrep 14 Released
#45My muscle memory is still dialed in to `ack`, but I recently built an open source tool called `grep-ast` [0] that serves a similar function to ripgrep, ack, etc. The difference is that it shows matching lines in the context of the functions/methods/classes/etc that contain them. It uses the abstract syntax tree (AST) of the source code to show how the matching lines fit into the code structure. It shows relevant code…
Re: Ripgrep 14 Released
#46Congratulations on the release, Andrew! I also notice that you've joined Astral [3], which as a fan of Rust/Ruff/rg I'm thrilled about.
[1]: https://blog.burntsushi.net/transducers/
Re: Ripgrep 14 Released
#47I'm still sad that --sort-files makes ripgrep run in single-core mode. (I know you can't make --sort-files _free_ in multi-core mode, but it would still be faster than single-core) https://github.com/BurntSushi/ripgrep/issues/152
Re: Ripgrep 14 Released
#48Andrew sets an extremely high bar for open-source engineering. As a loose member of the broader Rust community, I've benefited enormously not only from his code but also from his discussion comments and his blog posts (especially [1] and [2]). Congratulations on the release, Andrew! I also notice that you've joined Astral [3], which as a fan of Rust/Ruff/rg I'm thrilled about. [1]: https://blog.burntsushi.net/transdu…
Re: Ripgrep 14 Released
#49My muscle memory is still dialed in to `ack`, but I recently built an open source tool called `grep-ast` [0] that serves a similar function to ripgrep, ack, etc. The difference is that it shows matching lines in the context of the functions/methods/classes/etc that contain them. It uses the abstract syntax tree (AST) of the source code to show how the matching lines fit into the code structure. It shows relevant code…
have you looked at semgrep? This isn't the same thing but is similarly poking at the whole "ASTs are a thing we want to grep at" problem
Both of them are sort of doing the opposite of my tool. They are letting you specify your search as a chunk of code/AST.
My tool let's you grep a regex as usual, but shows you the matches in a helpful AST aware way.