emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 5153d30: When called with prefix argument, ask for


From: Dmitry Gutov
Subject: [Emacs-diffs] master 5153d30: When called with prefix argument, ask for file patterns to search as well
Date: Sun, 12 Jul 2015 15:35:24 +0000

branch: master
commit 5153d30c16aa326eedde527923b34ef24d24067f
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    When called with prefix argument, ask for file patterns to search as well
    
    * lisp/progmodes/xref.el (xref-find-regexp): When called with
    prefix argument, ask for file patterns to search as well.  When
    prompting for the directory, require an existing one.
    (xref-collect-matches): Add a new argument, FILES.  Use it in the
    above function.
---
 lisp/progmodes/xref.el |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index cc475e6..214503e 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -661,11 +661,15 @@ With prefix argument, prompt for the identifier."
 (defun xref-find-regexp (regexp)
   "Find all matches for REGEXP.
 With \\[universal-argument] prefix, you can specify the directory
-to search in."
+to search in, and the file name pattern to search for."
   (interactive (list (xref--read-identifier "Find regexp: ")))
   (let* ((proj (project-current))
+         (files (if current-prefix-arg
+                    (grep-read-files regexp)
+                  "*.*"))
          (dirs (if current-prefix-arg
-                   (list (read-directory-name "In directory: "))
+                   (list (read-directory-name "Base directory: "
+                                              nil default-directory t))
                  (project--prune-directories
                   (nconc
                    (project-directories proj)
@@ -674,7 +678,7 @@ to search in."
           (lambda (_kind regexp)
             (cl-mapcan
              (lambda (dir)
-               (xref-collect-matches regexp dir (project-ignores proj)))
+               (xref-collect-matches regexp files dir (project-ignores proj)))
              dirs))))
     (xref--show-xrefs regexp 'matches regexp nil)))
 
@@ -755,8 +759,10 @@ tools are used, and when."
       (mapc #'kill-buffer
             (cl-set-difference (buffer-list) orig-buffers)))))
 
-(defun xref-collect-matches (regexp dir ignores)
-  "Collect matches for REGEXP inside DIR using rgrep."
+(defun xref-collect-matches (regexp files dir ignores)
+  "Collect matches for REGEXP inside FILES in DIR.
+FILES is a string with glob patterns separated by spaces.
+IGNORES is a list of glob patterns."
   (cl-assert (directory-name-p dir))
   (require 'semantic/fw)
   (grep-compute-defaults)
@@ -766,7 +772,7 @@ tools are used, and when."
                                                        grep-find-template t t))
          (grep-highlight-matches nil)
          (command (xref--rgrep-command (xref--regexp-to-extended regexp)
-                                       "*.*" dir ignores))
+                                       files dir ignores))
          (orig-buffers (buffer-list))
          (buf (get-buffer-create " *xref-grep*"))
          (grep-re (caar grep-regexp-alist))



reply via email to

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