[emacs] [lisp] locate-executable

標準添付の executable-find が全く同じ機能でした。 *1

(defun locate-executable (arg)
  (if (and (boundp 'exec-suffixes) (fboundp 'locate-file)) ;; emacs22 feature
      (locate-file arg exec-path exec-suffixes 'file-executable-p)
    (let
	((name arg)
	 (exec-suffixes (list nil ".exe" ".com" ".cmd" ".bat")))
      (car
       (remove nil
	       (mapcar
		#'(lambda (arg)
		   (locate-library
		    (concat name arg) nil exec-path)) exec-suffixes))))))

e22 の時は locate-file で済ませるようにしてみました。

*1:Emacs 22 では実装も同じでした……。