[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 3bd1d87 182/184: counsel.el (counsel-locate-cmd-es): Encod

From: Oleh Krehel
Subject: [elpa] master 3bd1d87 182/184: counsel.el (counsel-locate-cmd-es): Encode command to local codepage
Date: Wed, 16 Oct 2019 13:15:18 -0400 (EDT)

branch: master
commit 3bd1d87341dc8a3465cea6acbaff271fd7b9d396
Author: Zhu Zihao <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-locate-cmd-es): Encode command to local codepage
    Fixes #2278
 counsel.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/counsel.el b/counsel.el
index 59d411a..109a215 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2446,12 +2446,22 @@ string - the full shell command to run."
   (counsel-require-program "mdfind")
   (format "mdfind -name '%s'" input))
+(defvar w32-ansi-code-page)
 (defun counsel-locate-cmd-es (input)
   "Return a shell command based on INPUT."
   (counsel-require-program "es.exe")
-  (format "es.exe -i -r -p %s"
-          (counsel--elisp-to-pcre
-           (ivy--regex input t))))
+  (let ((raw-string (format "es.exe -i -r -p %s"
+                            (counsel--elisp-to-pcre
+                             (ivy--regex input t)))))
+    ;; W32 don't use Unicode by default, so we encode search command
+    ;; to local codepage to support searching filename contains non-ASCII
+    ;; characters.
+    (if (and (eq system-type 'windows-nt)
+             (boundp 'w32-ansi-code-page))
+        (encode-coding-string raw-string
+                              (intern (format "cp%d" w32-ansi-code-page)))
+      raw-string)))
 (defun counsel-locate-function (input)
   "Call the \"locate\" shell command with INPUT."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]