summaryrefslogtreecommitdiff
path: root/lisp/progmodes/xref.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2015-07-10 04:34:41 +0300
committerDmitry Gutov <dgutov@yandex.ru>2015-07-10 04:40:09 +0300
commitf8c720b55b9419c849ea9febe6f888761a61949b (patch)
tree1b8c1d5e3846eff794d04f69cbb71d54dab82922 /lisp/progmodes/xref.el
parent78c3e14aafb6125ea584c78e13df41a35f18c51e (diff)
downloademacs-f8c720b55b9419c849ea9febe6f888761a61949b.tar.gz
Introduce a Project API
* lisp/progmodes/project.el: New file. * lisp/cedet/ede.el: (project-try-ede): New function. (project-root): New implementation. * lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Set project-search-path-function. (elisp--xref-find-references): Delegate some logic to project-search-path. (elisp-search-path): New function. (elisp-xref-find): Don't implement `matches' anymore. * lisp/progmodes/etags.el: Don't implement `matches'. Delegate some logic to project-search-path. (etags-search-path): New function. * lisp/progmodes/xref.el (xref-find-function): Remove `matches' from the API. (xref-find-regexp): Move whatever common logic was in elisp and etags implementations, and search the directories returned by project-directories and project-search-path.
Diffstat (limited to 'lisp/progmodes/xref.el')
-rw-r--r--lisp/progmodes/xref.el26
1 files changed, 19 insertions, 7 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index f175c89c573..042429e3efe 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -54,6 +54,7 @@
(require 'eieio)
(require 'ring)
(require 'pcase)
+(require 'project)
(defgroup xref nil "Cross-referencing commands"
:group 'tools)
@@ -182,9 +183,6 @@ found, return nil.
(apropos PATTERN): Find all symbols that match PATTERN. PATTERN
is a regexp.
- (matches REGEXP): Find all matches for REGEXP in the related
-files. REGEXP is an Emacs regular expression.
-
IDENTIFIER can be any string returned by
`xref-identifier-at-point-function', or from the table returned
by `xref-identifier-completion-table-function'.
@@ -598,7 +596,7 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
(tb (cl-set-difference (buffer-list) bl)))
(cond
((null xrefs)
- (user-error "No known %s for: %s" (symbol-name kind) input))
+ (user-error "No %s found for: %s" (symbol-name kind) input))
((not (cdr xrefs))
(xref-push-marker-stack)
(xref--pop-to-location (xref--xref-location (car xrefs)) window))
@@ -661,10 +659,25 @@ With prefix argument, prompt for the identifier."
;;;###autoload
(defun xref-find-regexp (regexp)
- "Find all matches for REGEXP."
+ "Find all matches for REGEXP.
+With \\[universal-argument] prefix, you can specify the directory
+to search in."
;; FIXME: Prompt for directory.
(interactive (list (xref--read-identifier "Find regexp: ")))
- (xref--show-xrefs regexp 'matches regexp nil))
+ (let* ((dirs (if current-prefix-arg
+ (list (read-directory-name "In directory: "))
+ (let ((proj (project-current)))
+ (project--prune-directories
+ (nconc
+ (project-directories proj)
+ (project-search-path proj))))))
+ (xref-find-function
+ (lambda (_kind regexp)
+ (cl-mapcan
+ (lambda (dir)
+ (xref-collect-matches regexp dir))
+ dirs))))
+ (xref--show-xrefs regexp 'matches regexp nil)))
(declare-function apropos-parse-pattern "apropos" (pattern))
@@ -807,7 +820,6 @@ tools are used, and when."
(xref-make-file-location file line
(current-column))))))))
-
(provide 'xref)
;;; xref.el ends here