emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/projectile 93c61a98f2 1/3: Add new command projectile-find


From: ELPA Syncer
Subject: [nongnu] elpa/projectile 93c61a98f2 1/3: Add new command projectile-find-references
Date: Thu, 27 Oct 2022 12:59:47 -0400 (EDT)

branch: elpa/projectile
commit 93c61a98f2ee983d856f1c419caea7fb2ab1ad19
Author: Bozhidar Batsov <bozhidar@batsov.dev>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>

    Add new command projectile-find-references
---
 CHANGELOG.md  |  1 +
 projectile.el | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 086e48553c..5f60c47e5c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
 
 * [#1591](https://github.com/bbatsov/projectile/issues/1591): Add `project.el` 
integration that will make Projectile the default provider for project lookup.
 * [#1799](https://github.com/bbatsov/projectile/pull/1799): Make it possible 
to ignore special project buffers.
+* Add new command `projectile-find-references` (bound to `C-c C-p ?` and `C-c 
C-p s x`).
 
 ### Bug fixed
 
diff --git a/projectile.el b/projectile.el
index 9041cd9ad3..f746c0ba23 100644
--- a/projectile.el
+++ b/projectile.el
@@ -4216,6 +4216,16 @@ installed to work."
                    args))
           (t (error "Packages `ripgrep' and `rg' are not available")))))
 
+(defun projectile-find-references (&optional symbol)
+  "Find all references to SYMBOL in the current project.
+
+A thin wrapper around `xref-references-in-directory'."
+  (interactive)
+  (when (fboundp 'xref-references-in-directory)
+    (let ((project-root (projectile-acquire-root))
+          (symbol (or symbol (read-from-minibuffer "Lookup in project: " 
(projectile-symbol-at-point)))))
+      (xref--show-xrefs (xref-references-in-directory symbol project-root) 
nil))))
+
 (defun projectile-tags-exclude-patterns ()
   "Return a string with exclude patterns for ctags."
   (mapconcat (lambda (pattern) (format "--exclude=\"%s\""
@@ -5815,6 +5825,7 @@ thing shown in the mode line otherwise."
     (define-key map (kbd "5 t") 
#'projectile-find-implementation-or-test-other-frame)
     (define-key map (kbd "!") #'projectile-run-shell-command-in-root)
     (define-key map (kbd "&") #'projectile-run-async-shell-command-in-root)
+    (define-key map (kbd "?") #'projectile-find-references)
     (define-key map (kbd "a") #'projectile-find-other-file)
     (define-key map (kbd "b") #'projectile-switch-to-buffer)
     (define-key map (kbd "d") #'projectile-find-dir)
@@ -5838,6 +5849,7 @@ thing shown in the mode line otherwise."
     (define-key map (kbd "s g") #'projectile-grep)
     (define-key map (kbd "s r") #'projectile-ripgrep)
     (define-key map (kbd "s s") #'projectile-ag)
+    (define-key map (kbd "s x") #'projectile-find-references)
     (define-key map (kbd "S") #'projectile-save-project-buffers)
     (define-key map (kbd "t") 
#'projectile-toggle-between-implementation-and-test)
     (define-key map (kbd "T") #'projectile-find-test-file)
@@ -5912,7 +5924,8 @@ thing shown in the mode line otherwise."
          ["Search with ag" projectile-ag]
          ["Search with ripgrep" projectile-ripgrep]
          ["Replace in project" projectile-replace]
-         ["Multi-occur in project" projectile-multi-occur])
+         ["Multi-occur in project" projectile-multi-occur]
+         ["Find references in project" projectile-find-references])
         ("Run..."
          ["Run shell" projectile-run-shell]
          ["Run eshell" projectile-run-eshell]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]