changeset 17893:ad5fda4d4c36

(mh-file-command-p): New function. (mh-path-search): Use that. (mh-find-progs): Don't check current directory unless explicitly requested. Don't set mh-progs or mh-lib if the programs are not found. Give an error message unless they are found.
author Richard M. Stallman <rms@gnu.org>
date Tue, 20 May 1997 05:26:22 +0000
parents b3514551f08d
children 488536bc29c2
files lisp/mail/mh-utils.el
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/mh-utils.el	Tue May 20 05:18:15 1997 +0000
+++ b/lisp/mail/mh-utils.el	Tue May 20 05:26:22 1997 +0000
@@ -576,8 +576,14 @@
       (setq mail-user-agent 'mh-e-user-agent)
       (run-hooks 'mh-find-path-hook))))
 
+(defun mh-file-command-p (file)
+  "Return t if file FILE is the name of a executable regular file."
+  (and (file-regular-p file) (file-executable-p file)))
+
 (defun mh-find-progs ()
-  (or (file-exists-p (expand-file-name "inc" mh-progs))
+  "Find the `inc' and `mhl' programs of MH.
+Set the `mh-progs' and `mh-lib' variables to the file names."
+  (or (and mh-progs (mh-file-command-p (expand-file-name "inc" mh-progs)))
       (setq mh-progs
 	    (or (mh-path-search exec-path "inc")
 		(mh-path-search '("/usr/local/bin/mh/"
@@ -587,10 +593,8 @@
 				  "/usr/contrib/mh/bin/" ;BSDI
 				  "/usr/local/bin/"
 				  )
-				"inc")
-		mh-progs
-		"/usr/local/bin/")))
-  (or (file-exists-p (expand-file-name "mhl" mh-lib))
+				"inc"))))
+  (or (and mh-lib (mh-file-command-p (expand-file-name "mhl" mh-lib)))
       (setq mh-lib
 	    ;; Look for a lib directory roughly parallel to the bin
 	    ;; directory:  Strip any trailing `mh' or `bin' path
@@ -608,14 +612,15 @@
 		   "mhl"))
 		(mh-path-search '("/usr/local/bin/mh/") "mhl")
 		(mh-path-search exec-path "mhl") ;unlikely
-		mh-lib
-		"/usr/local/lib/mh/"))))
+		)))
+  (unless (and mh-progs mh-lib)
+    (error "Cannot find the commands `inc' and `mhl'")))
 
 (defun mh-path-search (path file)
   ;; Search PATH, a list of directory names, for FILE.
   ;; Returns the element of PATH that contains FILE, or nil if not found.
   (while (and path
-	      (not (file-exists-p (expand-file-name file (car path)))))
+	      (not (mh-file-command-p (expand-file-name file (car path)))))
     (setq path (cdr path)))
   (car path))