Subject: pkg/5069: FIX: emacs MH-E doesn't work with our nmh package
To: None <gnats-bugs@gnats.netbsd.org>
From: Johnny C. Lam <lamj@stat.cmu.edu>
List: netbsd-bugs
Date: 02/25/1998 16:07:37
>Number:         5069
>Category:       pkg
>Synopsis:       FIX: emacs MH-E doesn't work with our nmh package
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 26 10:50:01 1998
>Last-Modified:
>Originator:     Johnny C. Lam
>Organization:
>Release:        1.3B
>Environment:
System: NetBSD deepthought 1.3B NetBSD 1.3B (DEEPTHOUGHT) #1: Thu Jan 22 17:27:08 EST 1998 toor@deepthought:/usr/local/src/sys/arch/mac68k/compile/DEEPTHOUGHT mac68k

>Description:
	The MH-E elisp files that come with emacs-20.2 won't work with
our nmh package because nmh installs its programs and library files
into too many places.  NetBSD installs binaries into ${PREFIX}/bin and
${PREFIX}/libexec/nmh, and installs library files into
${PREFIX}/etc/nmh.  MH-E expects user binaries to be in ${PREFIX}/bin,
and library files and non-user binaries to be in ${PREFIX}/lib/mh.
You can't tweak a working mh-e by setting mh-progs and mh-libs.

	The MH-E version is 5.0.2 and additional information from
(mh-version) is:

version: $Id: mh-e.el,v 1.17 1997/09/04 20:25:56 rms Exp $
Emacs: 20.2.1 on berkeley-unix NetBSD deepthought 1.3B NetBSD 1.3B (DEEPTHOUGHT) #1: Thu Jan 22 17:27:08 EST 1998     toor@deepthought:/usr/local/src/sys/arch/mac68k/compile/DEEPTHOUGHT mac68k

>How-To-Repeat:
	Install nmh and emacs packages, then try:

	M-x load-library <RET> mh-e <RET>
	M-x mh-version <RET>

>Fix:
	Patch the mh-e files that come with the emacs source
distribution to define a new variable `mh-lib-progs' which defines the
path to the non-user binaries, like mhl and install-mh.  Then one can
use the following definitions

	(setq mh-progs		"/usr/pkg/bin/")
	(setq mh-lib		"/usr/pkg/etc/nmh")
	(setq mh-lib-progs	"/usr/pkg/libexec/nmh")

in the .emacs file.  The patch below should be installed as
/usr/pkgsrc/editors/emacs/patches/patch-af:


--- lisp/mh-funcs.el.orig	Wed Feb 25 06:35:14 1998
+++ lisp/mh-funcs.el	Wed Feb 25 15:10:45 1998
@@ -211,7 +211,7 @@
   (let ((print-command
 	 (if (numberp msg-or-seq)
 	     (format "%s -nobell -clear %s %s | %s"
-		     (expand-file-name "mhl" mh-lib)
+		     (expand-file-name "mhl" mh-lib-progs)
 		     (mh-msg-filename msg-or-seq)
 		     (if (stringp mhl-formfile)
 			 (format "-form %s" mhl-formfile)
@@ -223,7 +223,7 @@
 			         (format "Sequence from %s" mh-current-folder))))
 	     (format "(scan -clear %s ; %s -nobell -clear %s %s) | %s"
 		     (mapconcat (function (lambda (msg) msg)) msg-or-seq " ")
-		     (expand-file-name "mhl" mh-lib)
+		     (expand-file-name "mhl" mh-lib-progs)
 		     (if (stringp mhl-formfile)
 			 (format "-form %s" mhl-formfile)
 		       "")
--- lisp/mh-utils.el.orig	Wed Feb 25 06:35:14 1998
+++ lisp/mh-utils.el	Wed Feb 25 15:12:20 1998
@@ -38,12 +38,18 @@
 (defvar mh-lib nil
   "Directory containing the MH library.
 This directory contains, among other things,
-the mhl program and the components file.")
+the components file.")
+
+(defvar mh-lib-progs nil
+  "Directory containing the supporting MH commands,
+such as install-mh and mhl.")
 
 ;;;###autoload
 (put 'mh-progs 'risky-local-variable t)
 ;;;###autoload
 (put 'mh-lib 'risky-local-variable t)
+;;;###autoload
+(put 'mh-lib-progs 'risky-local-variable t)
 
 ;;; User preferences:
 
@@ -532,7 +538,7 @@
 (defvar mail-user-agent 'mh-e-user-agent) ;from reporter.el 3.2
 
 (defun mh-find-path ()
-  ;; Set mh-progs and mh-lib.
+  ;; Set mh-progs, mh-lib, and mh-lib-progs.
   ;; (This step is necessary if MH was installed after this Emacs was dumped.)
   ;; From profile file, set mh-user-path, mh-draft-folder,
   ;; mh-unseen-seq, mh-previous-seq, mh-inbox.
@@ -586,8 +592,9 @@
   (and (file-regular-p file) (file-executable-p file)))
 
 (defun mh-find-progs ()
-  "Find the `inc' and `mhl' programs of MH.
-Set the `mh-progs' and `mh-lib' variables to the file names."
+  "Find the `inc' and `mhl' programs of MH, and the components file.
+Set the `mh-progs', `mh-lib', and `mh-lib-progs' variables to the 
+directory 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")
@@ -599,7 +606,7 @@
 				  "/usr/local/bin/"
 				  )
 				"inc"))))
-  (or (and mh-lib (mh-file-command-p (expand-file-name "mhl" mh-lib)))
+  (or (and mh-lib (file-exists-p (expand-file-name "components" mh-lib)))
       (setq mh-lib
 	    ;; Look for a lib directory roughly parallel to the bin
 	    ;; directory:  Strip any trailing `mh' or `bin' path
@@ -614,18 +621,24 @@
 		  (mh-path-search
 		   (list (expand-file-name "lib/mh/" mh-base)
 			 (expand-file-name "mh/lib/" mh-base))
-		   "mhl"))
+		   "components"
+		   'file-exists-p))
+		)))
+  (or (and mh-lib-progs
+	   (mh-file-command-p (expand-file-name "mhl" mh-lib-progs)))
+      (setq mh-lib-progs
+	    (or (mh-path-search mh-lib "mhl")
 		(mh-path-search '("/usr/local/bin/mh/") "mhl")
 		(mh-path-search exec-path "mhl") ;unlikely
 		)))
-  (unless (and mh-progs mh-lib)
-    (error "Cannot find the commands `inc' and `mhl'")))
+  (unless (and mh-progs mh-lib mh-lib-progs)
+    (error "Cannot find the commands `inc' and `mhl' and the file `components'")))
 
-(defun mh-path-search (path file)
+(defun mh-path-search (path file &optional (func-p 'mh-file-command-p))
   ;; 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 (mh-file-command-p (expand-file-name file (car path)))))
+	      (not (funcall func-p (expand-file-name file (car path)))))
     (setq path (cdr path)))
   (car path))
 
@@ -644,7 +657,7 @@
   ;; mh-exec-cmd will display to the user.
   ;; The MH 5 version of install-mh might try prompt the user
   ;; for information, which would fail here.
-  (mh-exec-cmd (expand-file-name "install-mh" mh-lib) "-auto")
+  (mh-exec-cmd (expand-file-name "install-mh" mh-lib-progs) "-auto")
   ;; now try again to read the profile file
   (erase-buffer)
   (condition-case err
@@ -916,7 +929,8 @@
 (defun mh-exec-lib-cmd-output (command &rest args)
   ;; Execute MH library command COMMAND with ARGS.
   ;; Put the output into buffer after point.  Set mark after inserted text.
-  (apply 'mh-exec-cmd-output (expand-file-name command mh-lib) nil args))
+  (apply 'mh-exec-cmd-output
+	 (expand-file-name command mh-lib-progs) nil args))
 
 
 (defun mh-handle-process-error (command status)
>Audit-Trail:
>Unformatted: