From 53fa8c0eda9a10101dce74f66abc3b16695b5587 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 4 Oct 2016 07:28:32 +0300 Subject: [PATCH] Revert "[Fix #1044] Prefer `call-process` to `shell-command-to-string` (#1045)" This reverts commit ee5ce8d0799d6db366025cc664faf683cfdb4cca. --- .gitignore | 3 +-- CHANGELOG.md | 1 - Cask | 3 +-- projectile.el | 33 ++++++--------------------------- test/projectile-test.el | 21 --------------------- 5 files changed, 8 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index 26f031b25..7be95799a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /elpa -/.elpa /.cask *.elc *~ [#]*[#] -/TAGS +/TAGS \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d59f93f5..f302f9d2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,6 @@ * [#1024](https://github.com/bbatsov/projectile/issues/1024): Do not cache ignored project files. * [#1022](https://github.com/bbatsov/projectile/issues/1022): Scan for Fossil's checkout DB, not its config DB. * [#1007](https://github.com/bbatsov/projectile/issues/1007): Make use of `projectile-go-function`. -* [#1044](https://github.com/bbatsov/projectile/issues/1044): Replace `shell-command-to-string` invocations with `call-process` invocations where possible to avoid shell startup cost. ## 0.14.0 (2016-07-08) diff --git a/Cask b/Cask index 389143bd4..0690997e0 100644 --- a/Cask +++ b/Cask @@ -6,5 +6,4 @@ (development (depends-on "noflet") (depends-on "helm") - (depends-on "ag") - (depends-on "el-mock")) + (depends-on "ag")) diff --git a/projectile.el b/projectile.el index 009c71bb3..b0161224a 100644 --- a/projectile.el +++ b/projectile.el @@ -37,12 +37,11 @@ ;;; Code: (require 'cl-lib) +(require 'thingatpt) +(require 'ibuffer) +(require 'ibuf-ext) (require 'compile) -(require 'eshell) (require 'grep) -(require 'ibuf-ext) -(require 'ibuffer) -(require 'thingatpt) (eval-when-compile (defvar ag-ignore-list) @@ -1076,29 +1075,9 @@ they are excluded from the results of this function." (when cmd (projectile-files-via-ext-command cmd)))) -(defun projectile-call-process-to-string (program &rest args) - "Invoke the executable PROGRAM with ARGS and return the output as a string." - (with-temp-buffer - (apply 'call-process program nil (current-buffer) nil args) - (buffer-string))) - -(defun projectile-shell-command-to-string (command) - "Try to run COMMAND without actually using a shell and return the output. - -The function `eshell-search-path' will be used to search the PATH -environment variable for an appropriate executable using the text -occuring before the first space. If no executable is found, -fallback to `shell-command-to-string'." - (cl-destructuring-bind - (the-command . args) (split-string command " ") - (let ((binary-path (eshell-search-path the-command))) - (if binary-path - (apply 'projectile-call-process-to-string binary-path args) - (shell-command-to-string command))))) - (defun projectile-files-via-ext-command (command) "Get a list of relative file names in the project root by executing COMMAND." - (split-string (projectile-shell-command-to-string command) "\0" t)) + (split-string (shell-command-to-string command) "\0" t)) (defun projectile-index-directory (directory patterns progress-reporter) "Index DIRECTORY taking into account PATTERNS. @@ -2867,8 +2846,8 @@ Invokes the command referenced by `projectile-switch-project-action' on switch. With a prefix ARG invokes `projectile-commander' instead of `projectile-switch-project-action.'" (let ((switch-project-action (if arg - 'projectile-commander - projectile-switch-project-action))) + 'projectile-commander + projectile-switch-project-action))) (run-hooks 'projectile-before-switch-project-hook) ;; use a temporary buffer to load PROJECT-TO-SWITCH's dir-locals before calling SWITCH-PROJECT-ACTION (with-temp-buffer diff --git a/test/projectile-test.el b/test/projectile-test.el index 96d359f21..28b0cfe62 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -717,27 +717,6 @@ (should (equal (list (expand-file-name "vendor/client-submodule/" project)) (projectile-get-all-sub-projects project))))))) -(ert-deftest projectile-test-projectile-shell-command-to-string-fallback () - (let ((command "command arg1 arg2") - (command-path "/path/to/command") - shell-command-args call-process-args) - (noflet ((shell-command-to-string (&rest args) - (setq shell-command-args args)) - (call-process (&rest args) - (setq call-process-args args))) - (noflet ((eshell-search-path (_command) nil)) - (projectile-shell-command-to-string command) - (should (equal shell-command-args (list command))) - (should (equal call-process-args nil))) - (setq shell-command-args nil - call-process-args nil) - (noflet ((eshell-search-path (_command-name) command-path)) - (projectile-shell-command-to-string command) - (should (equal shell-command-args nil)) - (should (equal (car call-process-args) command-path)) - (should (equal (-slice call-process-args 4) - (cdr (split-string command " ")))))))) - ;; Local Variables: ;; indent-tabs-mode: nil ;; End: