diff --git a/elisp/ghc-comp.el b/elisp/ghc-comp.el index d463825..4dac92c 100644 --- a/elisp/ghc-comp.el +++ b/elisp/ghc-comp.el @@ -96,8 +96,7 @@ unloaded modules are loaded") ;;; (defun ghc-boot (n) - (if (not (executable-find ghc-module-command)) - (message "%s not found" ghc-module-command) + (ghc-executable-find ghc-module-command (ghc-read-lisp-list (lambda () (message "Initializing...") @@ -106,8 +105,7 @@ unloaded modules are loaded") n))) (defun ghc-load-modules (mods) - (if (not (executable-find ghc-module-command)) - (message "%s not found" ghc-module-command) + (ghc-executable-find ghc-module-command (ghc-read-lisp-list (lambda () (message "Loading names...") diff --git a/elisp/ghc-func.el b/elisp/ghc-func.el index b409128..4514df1 100644 --- a/elisp/ghc-func.el +++ b/elisp/ghc-func.el @@ -162,16 +162,20 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun ghc-run-ghc-mod (cmds) - (cond - ((executable-find ghc-module-command) + (ghc-executable-find ghc-module-command (let ((cdir default-directory)) (with-temp-buffer (cd cdir) (apply 'call-process ghc-module-command nil t nil (append (ghc-make-ghc-options) cmds)) - (buffer-substring (point-min) (1- (point-max)))))) - (t - (message "%s not found" ghc-module-command) - nil))) + (buffer-substring (point-min) (1- (point-max))))))) + +(defmacro ghc-executable-find (cmd &rest body) + ;; (declare (indent 1)) + `(if (not (executable-find ,cmd)) + (message "\"%s\" not found" ,cmd) + ,@body)) + +(put 'ghc-executable-find 'lisp-indent-function 1) (provide 'ghc-func) diff --git a/elisp/ghc-info.el b/elisp/ghc-info.el index 504b7a9..039019e 100644 --- a/elisp/ghc-info.el +++ b/elisp/ghc-info.el @@ -77,8 +77,7 @@ (defun ghc-show-type () (interactive) - (if (not (executable-find ghc-module-command)) - (message "%s not found" ghc-module-command) + (ghc-executable-find ghc-module-command (let ((modname (or (ghc-find-module-name) "Main"))) (ghc-show-type0 modname)))) diff --git a/elisp/ghc-ins-mod.el b/elisp/ghc-ins-mod.el index 9cd2326..5fc1515 100644 --- a/elisp/ghc-ins-mod.el +++ b/elisp/ghc-ins-mod.el @@ -12,8 +12,7 @@ (defun ghc-insert-module () (interactive) - (if (not (executable-find ghc-hoogle-command)) - (message "\"%s\" not found" ghc-hoogle-command) + (ghc-executable-find ghc-hoogle-command (let* ((expr0 (ghc-things-at-point)) (expr (ghc-read-expression expr0))) (let ((mods (ghc-function-to-modules expr)))