about summary refs log tree commit diff
path: root/users/tazjin/emacs/config/functions.el
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-02-22T08·49+0200
committertazjin <mail@tazj.in>2021-02-22T13·50+0000
commitbef01b141931f80afeb9716ba199eaaa9d0c1505 (patch)
tree6bb6c84a1a03c54abd929e7600b819550ed61c70 /users/tazjin/emacs/config/functions.el
parent83e81def2316de2800d3a78b8294835a5319c191 (diff)
feat(tazjin/emacs): Add #'rg-in-project r/2225
Uses project.el to anchor the ripgrep search. In combination with my
project detection logic, this means that grepping in TVL subprojects
works automatically.

Change-Id: I2705466d1de156c08ff0401a71112864aa24f976
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2542
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin/emacs/config/functions.el')
-rw-r--r--users/tazjin/emacs/config/functions.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/users/tazjin/emacs/config/functions.el b/users/tazjin/emacs/config/functions.el
index 74c737ad71..5963d142c1 100644
--- a/users/tazjin/emacs/config/functions.el
+++ b/users/tazjin/emacs/config/functions.el
@@ -317,4 +317,12 @@ the GPG agent correctly."
     (url-retrieve "https://songwhip.com/api/" #'songwhip--handle-result nil t t)
     (message "Requesting Songwhip URL ... please hold the line.")))
 
+(defun rg-in-project (&optional prefix)
+  "Interactively call ripgrep in the current project, or fall
+  back to ripgrep default behaviour if prefix is set."
+  (interactive "P")
+  (counsel-rg nil (unless prefix
+                    (if-let ((pr (project-current)))
+                        (project-root pr)))))
+
 (provide 'functions)