diff options
| author | Dmitry Gutov | 2015-07-12 18:35:08 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2015-07-12 18:35:08 +0300 |
| commit | 5153d30c16aa326eedde527923b34ef24d24067f (patch) | |
| tree | 3cfdddadaf9e67bb59bea08d646cb12f2890ad38 | |
| parent | 62d5d46551c2adca780d5da1e58ea7f37d6fb933 (diff) | |
| download | emacs-5153d30c16aa326eedde527923b34ef24d24067f.tar.gz emacs-5153d30c16aa326eedde527923b34ef24d24067f.zip | |
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.
| -rw-r--r-- | 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 cc475e6e7e4..214503efc5e 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el | |||
| @@ -661,11 +661,15 @@ With prefix argument, prompt for the identifier." | |||
| 661 | (defun xref-find-regexp (regexp) | 661 | (defun xref-find-regexp (regexp) |
| 662 | "Find all matches for REGEXP. | 662 | "Find all matches for REGEXP. |
| 663 | With \\[universal-argument] prefix, you can specify the directory | 663 | With \\[universal-argument] prefix, you can specify the directory |
| 664 | to search in." | 664 | to search in, and the file name pattern to search for." |
| 665 | (interactive (list (xref--read-identifier "Find regexp: "))) | 665 | (interactive (list (xref--read-identifier "Find regexp: "))) |
| 666 | (let* ((proj (project-current)) | 666 | (let* ((proj (project-current)) |
| 667 | (files (if current-prefix-arg | ||
| 668 | (grep-read-files regexp) | ||
| 669 | "*.*")) | ||
| 667 | (dirs (if current-prefix-arg | 670 | (dirs (if current-prefix-arg |
| 668 | (list (read-directory-name "In directory: ")) | 671 | (list (read-directory-name "Base directory: " |
| 672 | nil default-directory t)) | ||
| 669 | (project--prune-directories | 673 | (project--prune-directories |
| 670 | (nconc | 674 | (nconc |
| 671 | (project-directories proj) | 675 | (project-directories proj) |
| @@ -674,7 +678,7 @@ to search in." | |||
| 674 | (lambda (_kind regexp) | 678 | (lambda (_kind regexp) |
| 675 | (cl-mapcan | 679 | (cl-mapcan |
| 676 | (lambda (dir) | 680 | (lambda (dir) |
| 677 | (xref-collect-matches regexp dir (project-ignores proj))) | 681 | (xref-collect-matches regexp files dir (project-ignores proj))) |
| 678 | dirs)))) | 682 | dirs)))) |
| 679 | (xref--show-xrefs regexp 'matches regexp nil))) | 683 | (xref--show-xrefs regexp 'matches regexp nil))) |
| 680 | 684 | ||
| @@ -755,8 +759,10 @@ tools are used, and when." | |||
| 755 | (mapc #'kill-buffer | 759 | (mapc #'kill-buffer |
| 756 | (cl-set-difference (buffer-list) orig-buffers))))) | 760 | (cl-set-difference (buffer-list) orig-buffers))))) |
| 757 | 761 | ||
| 758 | (defun xref-collect-matches (regexp dir ignores) | 762 | (defun xref-collect-matches (regexp files dir ignores) |
| 759 | "Collect matches for REGEXP inside DIR using rgrep." | 763 | "Collect matches for REGEXP inside FILES in DIR. |
| 764 | FILES is a string with glob patterns separated by spaces. | ||
| 765 | IGNORES is a list of glob patterns." | ||
| 760 | (cl-assert (directory-name-p dir)) | 766 | (cl-assert (directory-name-p dir)) |
| 761 | (require 'semantic/fw) | 767 | (require 'semantic/fw) |
| 762 | (grep-compute-defaults) | 768 | (grep-compute-defaults) |
| @@ -766,7 +772,7 @@ tools are used, and when." | |||
| 766 | grep-find-template t t)) | 772 | grep-find-template t t)) |
| 767 | (grep-highlight-matches nil) | 773 | (grep-highlight-matches nil) |
| 768 | (command (xref--rgrep-command (xref--regexp-to-extended regexp) | 774 | (command (xref--rgrep-command (xref--regexp-to-extended regexp) |
| 769 | "*.*" dir ignores)) | 775 | files dir ignores)) |
| 770 | (orig-buffers (buffer-list)) | 776 | (orig-buffers (buffer-list)) |
| 771 | (buf (get-buffer-create " *xref-grep*")) | 777 | (buf (get-buffer-create " *xref-grep*")) |
| 772 | (grep-re (caar grep-regexp-alist)) | 778 | (grep-re (caar grep-regexp-alist)) |