branch: externals/ivy-hydra
commit dd43ab1217f72948dc5cd669467e33b8b568db44
Author: Basil L. Contovounesios <[email protected]>
Commit: Basil L. Contovounesios <[email protected]>

    Add Emacs 27 executable-find compatibility shim
    
    * counsel.el (counsel--executable-find): New function wrapping 2-arg
    executable-find in Emacs 27.
    (counsel-require-program): Use it to move version check from runtime
    to load time, and pacify byte-compiler.
    
    Re: #2618.
---
 counsel.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/counsel.el b/counsel.el
index 6cfb652..8c8434e 100644
--- a/counsel.el
+++ b/counsel.el
@@ -114,6 +114,14 @@ complex regexes."
      str)
     str))
 
+(defalias 'counsel--executable-find
+  ;; Gained optional argument in 27.1.
+  (if (>= emacs-major-version 27)
+      #'executable-find
+    (lambda (command &optional _remote)
+      (executable-find command)))
+  "Compatibility shim for `executable-find'.")
+
 (defun counsel-require-program (cmd)
   "Check system for program used in CMD, printing error if not found.
 CMD is either a string or a list of strings.
@@ -124,9 +132,7 @@ To skip the `executable-find' check, start the string with 
a space."
                      (car (split-string cmd)))))
       (or (and (stringp program)
                (not (string= program ""))
-               (if (<= 27 emacs-major-version)
-                   (executable-find program t)
-                 (executable-find program)))
+               (counsel--executable-find program t))
           (user-error "Required program \"%s\" not found in your path" 
program)))))
 
 (declare-function eshell-split-path "esh-util")

Reply via email to