[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/project-files-pipe-grep 33945ba 1/2: Wrap call-pro
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] scratch/project-files-pipe-grep 33945ba 1/2: Wrap call-process-region in project--process-file-region |
Date: |
Fri, 11 Jan 2019 20:44:07 -0500 (EST) |
branch: scratch/project-files-pipe-grep
commit 33945ba736bed387a850084cfaf1513aa0c096f3
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Wrap call-process-region in project--process-file-region
To make project-files-pipe-grep Tramp-friendly
---
lisp/progmodes/project.el | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 55d683f..cc55d17 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -376,14 +376,13 @@ pattern to search for."
(with-temp-buffer
(insert (mapconcat #'identity files "\0"))
(setq status
- (call-process-region (point-min)
- (point-max)
- shell-file-name
- nil
- output
- nil
- shell-command-switch
- command)))
+ (project--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))
@@ -401,6 +400,24 @@ pattern to search for."
(user-error "No matches for: %s" regexp))
(xref--show-xrefs xrefs nil)))
+(defun project--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)))))
+
;;;###autoload
(defun project-find-file ()
"Visit a file (with completion) in the current project's roots.