diff options
author | Vincent Ambo <mail@tazj.in> | 2021-02-22T08·49+0200 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-02-22T13·50+0000 |
commit | bef01b141931f80afeb9716ba199eaaa9d0c1505 (patch) | |
tree | 6bb6c84a1a03c54abd929e7600b819550ed61c70 /users/tazjin/emacs/config | |
parent | 83e81def2316de2800d3a78b8294835a5319c191 (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')
-rw-r--r-- | users/tazjin/emacs/config/bindings.el | 3 | ||||
-rw-r--r-- | users/tazjin/emacs/config/functions.el | 8 | ||||
-rw-r--r-- | users/tazjin/emacs/config/init.el | 3 |
3 files changed, 12 insertions, 2 deletions
diff --git a/users/tazjin/emacs/config/bindings.el b/users/tazjin/emacs/config/bindings.el index 7188bd3ef37b..029aa2d0e507 100644 --- a/users/tazjin/emacs/config/bindings.el +++ b/users/tazjin/emacs/config/bindings.el @@ -34,6 +34,9 @@ ;; Open a file in project: (global-set-key (kbd "C-c f") 'project-find-file) +;; Search in a project +(global-set-key (kbd "C-c r g") 'rg-in-project) + ;; Open a file via magit: (global-set-key (kbd "C-c C-f") #'magit-find-file-worktree) diff --git a/users/tazjin/emacs/config/functions.el b/users/tazjin/emacs/config/functions.el index 74c737ad71e1..5963d142c14b 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) diff --git a/users/tazjin/emacs/config/init.el b/users/tazjin/emacs/config/init.el index 158ee67d694e..b473746fbe6a 100644 --- a/users/tazjin/emacs/config/init.el +++ b/users/tazjin/emacs/config/init.el @@ -45,8 +45,7 @@ (use-package counsel :after (ivy) - :config (counsel-mode 1) - :bind (("C-c r g" . counsel-rg))) + :config (counsel-mode 1)) (use-package dash) (use-package dash-functional) |