From f34e9dc1560bdb0177b4ad818db9724b18eecd90 Mon Sep 17 00:00:00 2001 From: Regis Xu Date: Sat, 24 Feb 2018 11:13:09 +0800 Subject: [PATCH 1/2] Fix ag-dired command arguments quote on Windows #87 --- ag.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ag.el b/ag.el index 0c457c0..1e7aeab 100644 --- a/ag.el +++ b/ag.el @@ -547,11 +547,17 @@ See also `find-dired'." (buffer-name (if ag-reuse-buffers "*ag dired*" (format "*ag dired pattern:%s dir:%s*" regexp dir))) - (cmd (concat ag-executable " " (combine-and-quote-strings ag-dired-arguments " ") " -g '" regexp "' " - (shell-quote-argument dir) - " | grep -v '^$' | sed s/\\'/\\\\\\\\\\'/ | xargs -I '{}' " - insert-directory-program " " - dired-listing-switches " '{}' &"))) + (cmd (if (string= system-type "windows-nt") + (concat ag-executable " " (combine-and-quote-strings ag-dired-arguments " ") " -g \"" regexp "\" " + (shell-quote-argument dir) + " | grep -v \"^$\" | sed \"s/'/\\\\\\\\'/g\" | xargs -I '{}' " + insert-directory-program " " + dired-listing-switches " '{}' &") + (concat ag-executable " " (combine-and-quote-strings ag-dired-arguments " ") " -g '" regexp "' " + (shell-quote-argument dir) + " | grep -v '^$' | sed s/\\'/\\\\\\\\\\'/ | xargs -I '{}' " + insert-directory-program " " + dired-listing-switches " '{}' &")))) (with-current-buffer (get-buffer-create buffer-name) (switch-to-buffer (current-buffer)) (widen) From 4752401422fc8ed366fbd44178ad6af5a030e75b Mon Sep 17 00:00:00 2001 From: Regis Xu Date: Sat, 24 Feb 2018 11:14:42 +0800 Subject: [PATCH 2/2] Fix ag-dired command to escape all ' in file name. --- ag.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ag.el b/ag.el index 1e7aeab..d9c7f37 100644 --- a/ag.el +++ b/ag.el @@ -555,7 +555,7 @@ See also `find-dired'." dired-listing-switches " '{}' &") (concat ag-executable " " (combine-and-quote-strings ag-dired-arguments " ") " -g '" regexp "' " (shell-quote-argument dir) - " | grep -v '^$' | sed s/\\'/\\\\\\\\\\'/ | xargs -I '{}' " + " | grep -v '^$' | sed s/\\'/\\\\\\\\\\'/g | xargs -I '{}' " insert-directory-program " " dired-listing-switches " '{}' &")))) (with-current-buffer (get-buffer-create buffer-name)