Function: shell--highlight-undef-executable-find
shell--highlight-undef-executable-find is a byte-compiled function
defined in shell.el.gz.
Signature
(shell--highlight-undef-executable-find COMMAND)
Documentation
Return non-nil if COMMAND is found in exec-path(var)/exec-path(fun).
Similar to executable-find, but use cache stored in
shell--highlight-undef-exec-cache.
Source Code
;; Defined in /usr/src/emacs/lisp/shell.el.gz
(defun shell--highlight-undef-executable-find (command)
"Return non-nil if COMMAND is found in `exec-path'.
Similar to `executable-find', but use cache stored in
`shell--highlight-undef-exec-cache'."
(let ((remote (file-remote-p default-directory))
as ret found-in-cache delta-time)
(if (null remote)
(executable-find command)
(setq delta-time
shell-highlight-undef-remote-file-name-inhibit-cache)
(pcase (setq as (assoc remote shell--highlight-undef-exec-cache))
(`(,_ ,time ,hash)
(when (pcase delta-time
((pred numberp) (<= (float-time) (+ time delta-time)))
('t nil)
('nil t))
(setq ret (gethash command hash))
(setq found-in-cache t)))
(_ (setq as (list remote 0 (make-hash-table :test #'equal)))
(push as shell--highlight-undef-exec-cache)))
(if found-in-cache
ret
;; Build cache
(setcar (cdr as) (float-time))
(let ((hash (clrhash (caddr as))))
(dolist (dir (exec-path))
(pcase-dolist (`(,f . ,attr)
(condition-case nil
(directory-files-and-attributes
(concat remote dir) nil nil 'nosort 'integer)
(file-error nil)))
;; Approximation. Assume every non-directory file in $PATH is an
;; executable. Alternatively, we could check
;; `file-executable-p', but doing so for every file in $PATH is
;; slow on remote machines.
(unless (eq t (file-attribute-type attr))
(puthash f t hash))))
(gethash command hash))))))