(locate-executable)

仕事が暇めだったので、でっち上げてみた。
これで良いはず ><

(defun locate-executable (basename)
  (let
      ((suffix (list nil ".exe" ".com" ".cmd" ".bat"))
       (exist-flag nil)
       (return-value nil))
    (dolist (s suffix)
      (unless exist-flag
	(setq return-value
	      (locate-library (concat basename s) nil exec-path))
	(when return-value
	  (when (file-executable-p return-value)
	    (setq exist-flag t)))))
    return-value))

何が嬉しいのか。

Windows 上の Emacsen から実行ファイルを探す際は、通常 "foo.exe" 等と拡張子のついた文字列を与える必要がある。

他の環境でも実行する elisp の場合、以下のような冗長な記述を要する。

(or
 (locate-library "foo" nil exec-path)
 (locate-library "foo.exe" nil exec-path))

locate-executable なら以下の記述で済む。

(locate-executable "foo")
追記

id:topia 師より以下の指摘あり。

何故 locate-file や exec-suffixes を使わないのですか。

……そんなの知りませんでした先生。

再追記

locate-file と exec-suffixes は emacs21 にはなかった模様。
そろそろ emacs21 を切り捨てるか。そういえば emacs21 は動作確認にしか起動していない。