diff options
Diffstat (limited to 'lisp/progmodes/xref.el')
-rw-r--r-- | lisp/progmodes/xref.el | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 3e3a37f6da5..bbf899e7017 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1,8 +1,8 @@ ;;; xref.el --- Cross-referencing commands -*-lexical-binding:t-*- ;; Copyright (C) 2014-2020 Free Software Foundation, Inc. -;; Version: 1.0.1 -;; Package-Requires: ((emacs "26.3") (project "0.1.1")) +;; Version: 1.0.2 +;; Package-Requires: ((emacs "26.3")) ;; This is a GNU ELPA :core package. Avoid functionality that is not ;; compatible with the version of Emacs recorded above. @@ -263,13 +263,16 @@ be found, return nil. The default implementation uses `semantic-symref-tool-alist' to find a search tool; by default, this uses \"find | grep\" in the -`project-current' roots." +current project's main and external roots." (mapcan (lambda (dir) (xref-references-in-directory identifier dir)) (let ((pr (project-current t))) (cons - (project-root pr) + (if (fboundp 'project-root) + (project-root pr) + (with-no-warnings + (project-roots pr))) (project-external-roots pr))))) (cl-defgeneric xref-backend-apropos (backend pattern) @@ -1281,13 +1284,13 @@ FILES must be a list of absolute file names." (insert (mapconcat #'identity files "\0")) (setq default-directory dir) (setq status - (project--process-file-region (point-min) - (point-max) - shell-file-name - output - nil - shell-command-switch - command))) + (xref--process-file-region (point-min) + (point-max) + shell-file-name + output + nil + shell-command-switch + command))) (goto-char (point-min)) (when (and (/= (point-min) (point-max)) (not (looking-at grep-re)) @@ -1302,6 +1305,24 @@ FILES must be a list of absolute file names." hits))) (xref--convert-hits (nreverse hits) regexp))) +(defun xref--process-file-region ( start end program + &optional buffer display + &rest args) + ;; FIXME: This branching shouldn't be necessary, but + ;; call-process-region *is* measurably faster, even for a program + ;; doing some actual work (for a period of time). Even though + ;; call-process-region also creates a temp file internally + ;; (http://lists.gnu.org/archive/html/emacs-devel/2019-01/msg00211.html). + (if (not (file-remote-p default-directory)) + (apply #'call-process-region + start end program nil buffer display args) + (let ((infile (make-temp-file "ppfr"))) + (unwind-protect + (progn + (write-region start end infile nil 'silent) + (apply #'process-file program infile buffer display args)) + (delete-file infile))))) + (defun xref--rgrep-command (regexp files dir ignores) (require 'find-dired) ; for `find-name-arg' (defvar grep-find-template) |