feat(tazjin/emacs): Add #'rg-in-project
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
This commit is contained in:
		
							parent
							
								
									83e81def23
								
							
						
					
					
						commit
						bef01b1419
					
				
					 3 changed files with 12 additions and 2 deletions
				
			
		|  | @ -34,6 +34,9 @@ | ||||||
| ;; Open a file in project: | ;; Open a file in project: | ||||||
| (global-set-key (kbd "C-c f") 'project-find-file) | (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: | ;; Open a file via magit: | ||||||
| (global-set-key (kbd "C-c C-f") #'magit-find-file-worktree) | (global-set-key (kbd "C-c C-f") #'magit-find-file-worktree) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -317,4 +317,12 @@ the GPG agent correctly." | ||||||
|     (url-retrieve "https://songwhip.com/api/" #'songwhip--handle-result nil t t) |     (url-retrieve "https://songwhip.com/api/" #'songwhip--handle-result nil t t) | ||||||
|     (message "Requesting Songwhip URL ... please hold the line."))) |     (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) | (provide 'functions) | ||||||
|  |  | ||||||
|  | @ -45,8 +45,7 @@ | ||||||
| 
 | 
 | ||||||
| (use-package counsel | (use-package counsel | ||||||
|   :after (ivy) |   :after (ivy) | ||||||
|   :config (counsel-mode 1) |   :config (counsel-mode 1)) | ||||||
|   :bind (("C-c r g" . counsel-rg))) |  | ||||||
| 
 | 
 | ||||||
| (use-package dash) | (use-package dash) | ||||||
| (use-package dash-functional) | (use-package dash-functional) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue