diff options
| author | Bill Wohler | 2006-01-10 23:55:42 +0000 |
|---|---|---|
| committer | Bill Wohler | 2006-01-10 23:55:42 +0000 |
| commit | 191c8741fba847184d4d67d27db86c3e8ff523ac (patch) | |
| tree | d44b3c913248e022d518a7a8f096b8dadb3f95be | |
| parent | 12884b7290f45fd31d0e94b2ed3dd72d4cbf88a2 (diff) | |
| download | emacs-191c8741fba847184d4d67d27db86c3e8ff523ac.tar.gz emacs-191c8741fba847184d4d67d27db86c3e8ff523ac.zip | |
* mh-index.el (mh-index-search): Checking mh-find-path-run is
unnecessary.
* mh-init.el (mh-sys-path): Co-locate with mh-variants, which uses it.
(mh-variants): Note variable isn't meant to be accessed directly; use
function mh-variants instead.
(mh-variant-info, mh-variant-mh-info, mh-variant-mu-mh-info)
(mh-variant-nmh-info): Co-locate next to mh-variants, which uses them.
Updated to use mh-file-command-p which is more accurrate than
file-executable-p which returns t for directories.
(mh-file-command-p): Move here from mh-utils, since mh-variant-*-info
are the only functions to use it.
(mh-variant-set, mh-variant-set-variant, mh-variant-p): Use function
mh-variants instead of variable. More robust.
(mh-find-path-run): Move here from mh-utils.el. Mention that checking
this variable is unnecessary.
(mh-find-path): Move here from mh-utils.el. With the advent of MH
variants and an mhparam command that doesn't work if there isn't an MH
profile, we can't get libdir for running install-mh. So don't bother.
If there's an issue with the environment, direct the user to install
MH and run install-mh (closes SF #835192). Don't read ~/.mh_profile
directly. Use mh-profile-component which uses mhparam (closes SF
#1016027).
* mh-utils.el (mh-get-profile-field): Rename to
mh-profile-component-value. Add colon to search removing unnecessary
addition of colon to field in mh-profile-component.
(mh-profile-component): Modify call to mh-profile-component-value
accordingly. Move next to mh-profile-component-value.
(mh-find-path-run, mh-find-path, mh-file-command-p): Move to
mh-init.el. It makes sense that code that is only run once per session
(more or less) is in mh-init.el rather than cluttering mh-utils.el.
(mh-no-install, mh-install): Delete.
| -rw-r--r-- | lisp/mh-e/ChangeLog | 41 | ||||
| -rw-r--r-- | lisp/mh-e/mh-index.el | 2 | ||||
| -rw-r--r-- | lisp/mh-e/mh-init.el | 287 | ||||
| -rw-r--r-- | lisp/mh-e/mh-utils.el | 113 |
4 files changed, 233 insertions, 210 deletions
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index 786fa837212..f4a5775315b 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog | |||
| @@ -1,3 +1,44 @@ | |||
| 1 | 2006-01-10 Bill Wohler <wohler@newt.com> | ||
| 2 | |||
| 3 | * mh-index.el (mh-index-search): Checking mh-find-path-run is | ||
| 4 | unnecessary. | ||
| 5 | |||
| 6 | * mh-init.el (mh-sys-path): Co-locate with mh-variants, which uses | ||
| 7 | it. | ||
| 8 | (mh-variants): Note variable isn't meant to be accessed directly; | ||
| 9 | use function mh-variants instead. | ||
| 10 | (mh-variant-info, mh-variant-mh-info, mh-variant-mu-mh-info) | ||
| 11 | (mh-variant-nmh-info): Co-locate next to mh-variants, which uses | ||
| 12 | them. Updated to use mh-file-command-p which is more accurrate | ||
| 13 | than file-executable-p which returns t for directories. | ||
| 14 | (mh-file-command-p): Move here from mh-utils, since | ||
| 15 | mh-variant-*-info are the only functions to use it. | ||
| 16 | (mh-variant-set, mh-variant-set-variant, mh-variant-p): Use | ||
| 17 | function mh-variants instead of variable. More robust. | ||
| 18 | (mh-find-path-run): Move here from mh-utils.el. Mention that | ||
| 19 | checking this variable is unnecessary. | ||
| 20 | (mh-find-path): Move here from mh-utils.el. With the advent of MH | ||
| 21 | variants and an mhparam command that doesn't work if there isn't | ||
| 22 | an MH profile, we can't get libdir for running install-mh. So | ||
| 23 | don't bother. If there's an issue with the environment, direct the | ||
| 24 | user to install MH and run install-mh (closes SF #835192). Don't | ||
| 25 | read ~/.mh_profile directly. Use mh-profile-component which uses | ||
| 26 | mhparam (closes SF #1016027). | ||
| 27 | |||
| 28 | * mh-utils.el (mh-get-profile-field): Rename to | ||
| 29 | mh-profile-component-value. Add colon to search removing | ||
| 30 | unnecessary addition of colon to field in mh-profile-component. | ||
| 31 | (mh-profile-component): Modify call to mh-profile-component-value | ||
| 32 | accordingly. Move next to mh-profile-component-value. | ||
| 33 | (mh-find-path-run, mh-find-path, mh-file-command-p): Move to | ||
| 34 | mh-init.el. It makes sense that code that is only run once per | ||
| 35 | session (more or less) is in mh-init.el rather than cluttering | ||
| 36 | mh-utils.el. | ||
| 37 | (mh-no-install, mh-install): Delete. | ||
| 38 | |||
| 39 | * mh-customize.el (mh-folder-msg-number): | ||
| 40 | * mh-mime.el (mh-file-mime-type): Removed trailing whitespace. | ||
| 41 | |||
| 1 | 2006-01-09 Bill Wohler <wohler@newt.com> | 42 | 2006-01-09 Bill Wohler <wohler@newt.com> |
| 2 | 43 | ||
| 3 | * mh-init.el (mh-variant-mu-mh-info, mh-variant-nmh-info): Applied | 44 | * mh-init.el (mh-variant-mu-mh-info, mh-variant-nmh-info): Applied |
diff --git a/lisp/mh-e/mh-index.el b/lisp/mh-e/mh-index.el index 73b30e54726..3d0aeba85a6 100644 --- a/lisp/mh-e/mh-index.el +++ b/lisp/mh-e/mh-index.el | |||
| @@ -443,7 +443,7 @@ search results." | |||
| 443 | (interactive | 443 | (interactive |
| 444 | (list current-prefix-arg | 444 | (list current-prefix-arg |
| 445 | (progn | 445 | (progn |
| 446 | (unless mh-find-path-run (mh-find-path)) | 446 | (mh-find-path) |
| 447 | (or (and current-prefix-arg mh-index-sequence-search-flag) | 447 | (or (and current-prefix-arg mh-index-sequence-search-flag) |
| 448 | (and current-prefix-arg (car mh-index-previous-search)) | 448 | (and current-prefix-arg (car mh-index-previous-search)) |
| 449 | (mh-prompt-for-folder "Search" "+" nil "all" t))) | 449 | (mh-prompt-for-folder "Search" "+" nil "all" t))) |
diff --git a/lisp/mh-e/mh-init.el b/lisp/mh-e/mh-init.el index f784a1d9d2c..3df0dee0115 100644 --- a/lisp/mh-e/mh-init.el +++ b/lisp/mh-e/mh-init.el | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | ;; Sets up the MH variant (currently nmh, MH, or GNU mailutils). | 29 | ;; Sets up the MH variant (currently nmh, MH, or GNU mailutils). |
| 30 | ;; | 30 | ;; |
| 31 | ;; Users may customize `mh-variant' to switch between available variants. | 31 | ;; Users may customize `mh-variant' to switch between available variants. |
| 32 | ;; Available MH variants are described in the variable `mh-variants'. | 32 | ;; Available MH variants are returned by the function `mh-variants'. |
| 33 | ;; Developers may check which variant is currently in use with the | 33 | ;; Developers may check which variant is currently in use with the |
| 34 | ;; variable `mh-variant-in-use' or the function `mh-variant-p'. | 34 | ;; variable `mh-variant-in-use' or the function `mh-variant-p'. |
| 35 | ;; | 35 | ;; |
| @@ -43,6 +43,22 @@ | |||
| 43 | (mh-require-cl) | 43 | (mh-require-cl) |
| 44 | (require 'mh-utils) | 44 | (require 'mh-utils) |
| 45 | 45 | ||
| 46 | (defvar mh-sys-path | ||
| 47 | '("/usr/local/nmh/bin" ; nmh default | ||
| 48 | "/usr/local/bin/mh/" | ||
| 49 | "/usr/local/mh/" | ||
| 50 | "/usr/bin/mh/" ; Ultrix 4.2, Linux | ||
| 51 | "/usr/new/mh/" ; Ultrix < 4.2 | ||
| 52 | "/usr/contrib/mh/bin/" ; BSDI | ||
| 53 | "/usr/pkg/bin/" ; NetBSD | ||
| 54 | "/usr/local/bin/" | ||
| 55 | "/usr/local/bin/mu-mh/" ; GNU mailutils - default | ||
| 56 | "/usr/bin/mu-mh/") ; GNU mailutils - packaged | ||
| 57 | "List of directories to search for variants of the MH variant. | ||
| 58 | The list `exec-path' is searched in addition to this list. | ||
| 59 | There's no need for users to modify this list. Instead add extra | ||
| 60 | directories to the customizable variable `mh-path'.") | ||
| 61 | |||
| 46 | ;; Set for local environment: | 62 | ;; Set for local environment: |
| 47 | ;; mh-progs and mh-lib used to be set in paths.el, which tried to | 63 | ;; mh-progs and mh-lib used to be set in paths.el, which tried to |
| 48 | ;; figure out at build time which of several possible directories MH | 64 | ;; figure out at build time which of several possible directories MH |
| @@ -72,7 +88,8 @@ This directory contains, among other things, the mhl program.") | |||
| 72 | 88 | ||
| 73 | (defvar mh-variants nil | 89 | (defvar mh-variants nil |
| 74 | "List describing known MH variants. | 90 | "List describing known MH variants. |
| 75 | Created by the function `mh-variants'") | 91 | Do not access this variable directly as it may not have yet been initialized. |
| 92 | Use the function `mh-variants' instead.") | ||
| 76 | 93 | ||
| 77 | ;;;###mh-autoload | 94 | ;;;###mh-autoload |
| 78 | (defun mh-variants () | 95 | (defun mh-variants () |
| @@ -95,6 +112,93 @@ is described by the variable `mh-variants'." | |||
| 95 | (add-to-list 'mh-variants variant))))) | 112 | (add-to-list 'mh-variants variant))))) |
| 96 | mh-variants))) | 113 | mh-variants))) |
| 97 | 114 | ||
| 115 | (defun mh-variant-info (dir) | ||
| 116 | "Return MH variant found in DIR, or nil if none present." | ||
| 117 | (save-excursion | ||
| 118 | (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) | ||
| 119 | (set-buffer tmp-buffer) | ||
| 120 | (cond | ||
| 121 | ((mh-variant-mh-info dir)) | ||
| 122 | ((mh-variant-nmh-info dir)) | ||
| 123 | ((mh-variant-mu-mh-info dir)))))) | ||
| 124 | |||
| 125 | (defun mh-variant-mh-info (dir) | ||
| 126 | "Return info for MH variant in DIR assuming a temporary buffer is setup." | ||
| 127 | ;; MH does not have the -version option. | ||
| 128 | ;; Its version number is included in the output of "-help" as: | ||
| 129 | ;; | ||
| 130 | ;; version: MH 6.8.4 #2[UCI] (burrito) of Fri Jan 15 20:01:39 EST 1999 | ||
| 131 | ;; options: [ATHENA] [BIND] [DUMB] [LIBLOCKFILE] [LOCALE] [MAILGROUP] [MHE] | ||
| 132 | ;; [MHRC] [MIME] [MORE='"/usr/bin/sensible-pager"'] [NLINK_HACK] | ||
| 133 | ;; [NORUSERPASS] [OVERHEAD] [POP] [POPSERVICE='"pop-3"'] [RENAME] | ||
| 134 | ;; [RFC1342] [RPATHS] [RPOP] [SENDMTS] [SMTP] [SOCKETS] | ||
| 135 | ;; [SPRINTFTYPE=int] [SVR4] [SYS5] [SYS5DIR] [TERMINFO] | ||
| 136 | ;; [TYPESIG=void] [UNISTD] [UTK] [VSPRINTF] | ||
| 137 | (let ((mhparam (expand-file-name "mhparam" dir))) | ||
| 138 | (when (mh-file-command-p mhparam) | ||
| 139 | (erase-buffer) | ||
| 140 | (call-process mhparam nil '(t nil) nil "-help") | ||
| 141 | (goto-char (point-min)) | ||
| 142 | (when (search-forward-regexp "version: MH \\(\\S +\\)" nil t) | ||
| 143 | (let ((version (format "MH %s" (match-string 1)))) | ||
| 144 | (erase-buffer) | ||
| 145 | (call-process mhparam nil '(t nil) nil "libdir") | ||
| 146 | (goto-char (point-min)) | ||
| 147 | (when (search-forward-regexp "^.*$" nil t) | ||
| 148 | (let ((libdir (match-string 0))) | ||
| 149 | `(,version | ||
| 150 | (variant mh) | ||
| 151 | (mh-lib-progs ,libdir) | ||
| 152 | (mh-lib ,libdir) | ||
| 153 | (mh-progs ,dir) | ||
| 154 | (flists nil))))))))) | ||
| 155 | |||
| 156 | (defun mh-variant-mu-mh-info (dir) | ||
| 157 | "Return info for GNU mailutils variant in DIR. | ||
| 158 | This assumes that a temporary buffer is setup." | ||
| 159 | ;; 'mhparam -version' output: | ||
| 160 | ;; mhparam (GNU mailutils 0.3.2) | ||
| 161 | (let ((mhparam (expand-file-name "mhparam" dir))) | ||
| 162 | (when (mh-file-command-p mhparam) | ||
| 163 | (erase-buffer) | ||
| 164 | (call-process mhparam nil '(t nil) nil "-version") | ||
| 165 | (goto-char (point-min)) | ||
| 166 | (when (search-forward-regexp "mhparam (\\(GNU [Mm]ailutils \\S +\\))" | ||
| 167 | nil t) | ||
| 168 | (let ((version (match-string 1)) | ||
| 169 | (mh-progs dir)) | ||
| 170 | `(,version | ||
| 171 | (variant mu-mh) | ||
| 172 | (mh-lib-progs ,(mh-profile-component "libdir")) | ||
| 173 | (mh-lib ,(mh-profile-component "etcdir")) | ||
| 174 | (mh-progs ,dir) | ||
| 175 | (flists ,(file-exists-p | ||
| 176 | (expand-file-name "flists" dir))))))))) | ||
| 177 | |||
| 178 | (defun mh-variant-nmh-info (dir) | ||
| 179 | "Return info for nmh variant in DIR assuming a temporary buffer is setup." | ||
| 180 | ;; `mhparam -version' outputs: | ||
| 181 | ;; mhparam -- nmh-1.1-RC1 [compiled on chaak at Fri Jun 20 11:03:28 PDT 2003] | ||
| 182 | (let ((mhparam (expand-file-name "mhparam" dir))) | ||
| 183 | (when (mh-file-command-p mhparam) | ||
| 184 | (erase-buffer) | ||
| 185 | (call-process mhparam nil '(t nil) nil "-version") | ||
| 186 | (goto-char (point-min)) | ||
| 187 | (when (search-forward-regexp "mhparam -- nmh-\\(\\S +\\)" nil t) | ||
| 188 | (let ((version (format "nmh %s" (match-string 1))) | ||
| 189 | (mh-progs dir)) | ||
| 190 | `(,version | ||
| 191 | (variant nmh) | ||
| 192 | (mh-lib-progs ,(mh-profile-component "libdir")) | ||
| 193 | (mh-lib ,(mh-profile-component "etcdir")) | ||
| 194 | (mh-progs ,dir) | ||
| 195 | (flists ,(file-exists-p | ||
| 196 | (expand-file-name "flists" dir))))))))) | ||
| 197 | |||
| 198 | (defun mh-file-command-p (file) | ||
| 199 | "Return t if file FILE is the name of a executable regular file." | ||
| 200 | (and (file-regular-p file) (file-executable-p file))) | ||
| 201 | |||
| 98 | (defvar mh-variant-in-use nil | 202 | (defvar mh-variant-in-use nil |
| 99 | "The MH variant currently in use; a string with variant and version number. | 203 | "The MH variant currently in use; a string with variant and version number. |
| 100 | This differs from `mh-variant' when the latter is set to | 204 | This differs from `mh-variant' when the latter is set to |
| @@ -109,7 +213,7 @@ If the VARIANT is \"autodetect\", then first try nmh, then MH and | |||
| 109 | finally GNU mailutils." | 213 | finally GNU mailutils." |
| 110 | (interactive | 214 | (interactive |
| 111 | (list (completing-read | 215 | (list (completing-read |
| 112 | "MH Variant: " | 216 | "MH variant: " |
| 113 | (mapcar (lambda (x) (list (car x))) (mh-variants)) | 217 | (mapcar (lambda (x) (list (car x))) (mh-variants)) |
| 114 | nil t))) | 218 | nil t))) |
| 115 | (let ((valid-list (mapcar (lambda (x) (car x)) (mh-variants)))) | 219 | (let ((valid-list (mapcar (lambda (x) (car x)) (mh-variants)))) |
| @@ -132,17 +236,18 @@ finally GNU mailutils." | |||
| 132 | (t | 236 | (t |
| 133 | (message "Unknown variant; use %s" | 237 | (message "Unknown variant; use %s" |
| 134 | (mapconcat '(lambda (x) (format "%s" (car x))) | 238 | (mapconcat '(lambda (x) (format "%s" (car x))) |
| 135 | mh-variants " or ")))))) | 239 | (mh-variants) " or ")))))) |
| 136 | 240 | ||
| 137 | (defun mh-variant-set-variant (variant) | 241 | (defun mh-variant-set-variant (variant) |
| 138 | "Setup the system variables for the MH variant named VARIANT. | 242 | "Setup the system variables for the MH variant named VARIANT. |
| 139 | If VARIANT is a string, use that key in the variable `mh-variants'. | 243 | If VARIANT is a string, use that key in the alist returned by the |
| 244 | function `mh-variants'. | ||
| 140 | If VARIANT is a symbol, select the first entry that matches that | 245 | If VARIANT is a symbol, select the first entry that matches that |
| 141 | variant." | 246 | variant." |
| 142 | (cond | 247 | (cond |
| 143 | ((stringp variant) ;e.g. "nmh 1.1-RC1" | 248 | ((stringp variant) ;e.g. "nmh 1.1-RC1" |
| 144 | (when (assoc variant mh-variants) | 249 | (when (assoc variant (mh-variants)) |
| 145 | (let* ((alist (cdr (assoc variant mh-variants))) | 250 | (let* ((alist (cdr (assoc variant (mh-variants)))) |
| 146 | (lib-progs (cadr (assoc 'mh-lib-progs alist))) | 251 | (lib-progs (cadr (assoc 'mh-lib-progs alist))) |
| 147 | (lib (cadr (assoc 'mh-lib alist))) | 252 | (lib (cadr (assoc 'mh-lib alist))) |
| 148 | (progs (cadr (assoc 'mh-progs alist))) | 253 | (progs (cadr (assoc 'mh-progs alist))) |
| @@ -155,7 +260,7 @@ variant." | |||
| 155 | mh-progs progs | 260 | mh-progs progs |
| 156 | mh-variant-in-use variant)))) | 261 | mh-variant-in-use variant)))) |
| 157 | ((symbolp variant) ;e.g. 'nmh (pick the first match) | 262 | ((symbolp variant) ;e.g. 'nmh (pick the first match) |
| 158 | (loop for variant-list in mh-variants | 263 | (loop for variant-list in (mh-variants) |
| 159 | when (eq variant (cadr (assoc 'variant (cdr variant-list)))) | 264 | when (eq variant (cadr (assoc 'variant (cdr variant-list)))) |
| 160 | return (let* ((version (car variant-list)) | 265 | return (let* ((version (car variant-list)) |
| 161 | (alist (cdr variant-list)) | 266 | (alist (cdr variant-list)) |
| @@ -177,107 +282,77 @@ variant." | |||
| 177 | "Return t if variant is any of VARIANTS. | 282 | "Return t if variant is any of VARIANTS. |
| 178 | Currently known variants are 'MH, 'nmh, and 'mu-mh." | 283 | Currently known variants are 'MH, 'nmh, and 'mu-mh." |
| 179 | (let ((variant-in-use | 284 | (let ((variant-in-use |
| 180 | (cadr (assoc 'variant (assoc mh-variant-in-use mh-variants))))) | 285 | (cadr (assoc 'variant (assoc mh-variant-in-use (mh-variants)))))) |
| 181 | (not (null (member variant-in-use variants))))) | 286 | (not (null (member variant-in-use variants))))) |
| 182 | 287 | ||
| 183 | (defvar mh-sys-path | 288 | |
| 184 | '("/usr/local/nmh/bin" ; nmh default | ||
| 185 | "/usr/local/bin/mh/" | ||
| 186 | "/usr/local/mh/" | ||
| 187 | "/usr/bin/mh/" ; Ultrix 4.2, Linux | ||
| 188 | "/usr/new/mh/" ; Ultrix < 4.2 | ||
| 189 | "/usr/contrib/mh/bin/" ; BSDI | ||
| 190 | "/usr/pkg/bin/" ; NetBSD | ||
| 191 | "/usr/local/bin/" | ||
| 192 | "/usr/local/bin/mu-mh/" ; GNU mailutils - default | ||
| 193 | "/usr/bin/mu-mh/") ; GNU mailutils - packaged | ||
| 194 | "List of directories to search for variants of the MH variant. | ||
| 195 | The list `exec-path' is searched in addition to this list. | ||
| 196 | There's no need for users to modify this list. Instead add extra | ||
| 197 | directories to the customizable variable `mh-path'.") | ||
| 198 | |||
| 199 | (defun mh-variant-mh-info (dir) | ||
| 200 | "Return info for MH variant in DIR assuming a temporary buffer is setup." | ||
| 201 | ;; MH does not have the -version option. | ||
| 202 | ;; Its version number is included in the output of "-help" as: | ||
| 203 | ;; | ||
| 204 | ;; version: MH 6.8.4 #2[UCI] (burrito) of Fri Jan 15 20:01:39 EST 1999 | ||
| 205 | ;; options: [ATHENA] [BIND] [DUMB] [LIBLOCKFILE] [LOCALE] [MAILGROUP] [MHE] | ||
| 206 | ;; [MHRC] [MIME] [MORE='"/usr/bin/sensible-pager"'] [NLINK_HACK] | ||
| 207 | ;; [NORUSERPASS] [OVERHEAD] [POP] [POPSERVICE='"pop-3"'] [RENAME] | ||
| 208 | ;; [RFC1342] [RPATHS] [RPOP] [SENDMTS] [SMTP] [SOCKETS] | ||
| 209 | ;; [SPRINTFTYPE=int] [SVR4] [SYS5] [SYS5DIR] [TERMINFO] | ||
| 210 | ;; [TYPESIG=void] [UNISTD] [UTK] [VSPRINTF] | ||
| 211 | (let ((mhparam (expand-file-name "mhparam" dir))) | ||
| 212 | (when (and (file-exists-p mhparam) (file-executable-p mhparam)) | ||
| 213 | (erase-buffer) | ||
| 214 | (call-process mhparam nil '(t nil) nil "-help") | ||
| 215 | (goto-char (point-min)) | ||
| 216 | (when (search-forward-regexp "version: MH \\(\\S +\\)" nil t) | ||
| 217 | (let ((version (format "MH %s" (match-string 1)))) | ||
| 218 | (erase-buffer) | ||
| 219 | (call-process mhparam nil '(t nil) nil "libdir") | ||
| 220 | (goto-char (point-min)) | ||
| 221 | (when (search-forward-regexp "^.*$" nil t) | ||
| 222 | (let ((libdir (match-string 0))) | ||
| 223 | `(,version | ||
| 224 | (variant mh) | ||
| 225 | (mh-lib-progs ,libdir) | ||
| 226 | (mh-lib ,libdir) | ||
| 227 | (mh-progs ,dir) | ||
| 228 | (flists nil))))))))) | ||
| 229 | |||
| 230 | (defun mh-variant-mu-mh-info (dir) | ||
| 231 | "Return info for GNU mailutils variant in DIR. | ||
| 232 | This assumes that a temporary buffer is setup." | ||
| 233 | ;; 'mhparam -version' output: | ||
| 234 | ;; mhparam (GNU mailutils 0.3.2) | ||
| 235 | (let ((mhparam (expand-file-name "mhparam" dir))) | ||
| 236 | (when (and (file-exists-p mhparam) (file-executable-p mhparam)) | ||
| 237 | (erase-buffer) | ||
| 238 | (call-process mhparam nil '(t nil) nil "-version") | ||
| 239 | (goto-char (point-min)) | ||
| 240 | (when (search-forward-regexp "mhparam (\\(GNU [Mm]ailutils \\S +\\))" | ||
| 241 | nil t) | ||
| 242 | (let ((version (match-string 1)) | ||
| 243 | (mh-progs dir)) | ||
| 244 | `(,version | ||
| 245 | (variant mu-mh) | ||
| 246 | (mh-lib-progs ,(mh-profile-component "libdir")) | ||
| 247 | (mh-lib ,(mh-profile-component "etcdir")) | ||
| 248 | (mh-progs ,dir) | ||
| 249 | (flists ,(file-exists-p | ||
| 250 | (expand-file-name "flists" dir))))))))) | ||
| 251 | |||
| 252 | (defun mh-variant-nmh-info (dir) | ||
| 253 | "Return info for nmh variant in DIR assuming a temporary buffer is setup." | ||
| 254 | ;; `mhparam -version' outputs: | ||
| 255 | ;; mhparam -- nmh-1.1-RC1 [compiled on chaak at Fri Jun 20 11:03:28 PDT 2003] | ||
| 256 | (let ((mhparam (expand-file-name "mhparam" dir))) | ||
| 257 | (when (and (file-exists-p mhparam) (file-executable-p mhparam)) | ||
| 258 | (erase-buffer) | ||
| 259 | (call-process mhparam nil '(t nil) nil "-version") | ||
| 260 | (goto-char (point-min)) | ||
| 261 | (when (search-forward-regexp "mhparam -- nmh-\\(\\S +\\)" nil t) | ||
| 262 | (let ((version (format "nmh %s" (match-string 1))) | ||
| 263 | (mh-progs dir)) | ||
| 264 | `(,version | ||
| 265 | (variant nmh) | ||
| 266 | (mh-lib-progs ,(mh-profile-component "libdir")) | ||
| 267 | (mh-lib ,(mh-profile-component "etcdir")) | ||
| 268 | (mh-progs ,dir) | ||
| 269 | (flists ,(file-exists-p | ||
| 270 | (expand-file-name "flists" dir))))))))) | ||
| 271 | 289 | ||
| 272 | (defun mh-variant-info (dir) | 290 | ;;; Read MH Profile |
| 273 | "Return MH variant found in DIR, or nil if none present." | 291 | |
| 274 | (save-excursion | 292 | (defvar mh-find-path-run nil |
| 275 | (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) | 293 | "Non-nil if `mh-find-path' has been run already. |
| 276 | (set-buffer tmp-buffer) | 294 | Do not access this variable; `mh-find-path' already uses it to |
| 277 | (cond | 295 | avoid running more than once.") |
| 278 | ((mh-variant-mh-info dir)) | 296 | |
| 279 | ((mh-variant-nmh-info dir)) | 297 | (defun mh-find-path () |
| 280 | ((mh-variant-mu-mh-info dir)))))) | 298 | "Set variables from user's MH profile. |
| 299 | |||
| 300 | This function sets `mh-user-path' from your \"Path:\" MH profile | ||
| 301 | component (but defaults to \"Mail\" if one isn't present), | ||
| 302 | `mh-draft-folder' from \"Draft-Folder:\", `mh-unseen-seq' from | ||
| 303 | \"Unseen-Sequence:\", `mh-previous-seq' from | ||
| 304 | \"Previous-Sequence:\", and `mh-inbox' from \"Inbox:\" (defaults | ||
| 305 | to \"+inbox\"). | ||
| 306 | |||
| 307 | The hook `mh-find-path-hook' is run after these variables have | ||
| 308 | been set. This hook can be used the change the value of these | ||
| 309 | variables if you need to run with different values between MH and | ||
| 310 | MH-E." | ||
| 311 | (unless mh-find-path-run | ||
| 312 | ;; Sanity checks. | ||
| 313 | (if (and (getenv "MH") | ||
| 314 | (not (file-readable-p (getenv "MH")))) | ||
| 315 | (error "MH environment variable contains unreadable file %s" | ||
| 316 | (getenv "MH"))) | ||
| 317 | (if (null (mh-variants)) | ||
| 318 | (error "Install MH and run install-mh before running MH-E")) | ||
| 319 | (let ((profile "~/.mh_profile")) | ||
| 320 | (if (not (file-readable-p profile)) | ||
| 321 | (error "Run install-mh before running MH-E"))) | ||
| 322 | ;; Read MH profile. | ||
| 323 | (setq mh-user-path (mh-profile-component "Path")) | ||
| 324 | (if (not mh-user-path) | ||
| 325 | (setq mh-user-path "Mail")) | ||
| 326 | (setq mh-user-path | ||
| 327 | (file-name-as-directory | ||
| 328 | (expand-file-name mh-user-path (expand-file-name "~")))) | ||
| 329 | (unless mh-x-image-cache-directory | ||
| 330 | (setq mh-x-image-cache-directory | ||
| 331 | (expand-file-name ".mhe-x-image-cache" mh-user-path))) | ||
| 332 | (setq mh-draft-folder (mh-profile-component "Draft-Folder")) | ||
| 333 | (if mh-draft-folder | ||
| 334 | (progn | ||
| 335 | (if (not (mh-folder-name-p mh-draft-folder)) | ||
| 336 | (setq mh-draft-folder (format "+%s" mh-draft-folder))) | ||
| 337 | (if (not (file-exists-p (mh-expand-file-name mh-draft-folder))) | ||
| 338 | (error | ||
| 339 | "Draft folder \"%s\" not found; create it and try again" | ||
| 340 | (mh-expand-file-name mh-draft-folder))))) | ||
| 341 | (setq mh-inbox (mh-profile-component "Inbox")) | ||
| 342 | (cond ((not mh-inbox) | ||
| 343 | (setq mh-inbox "+inbox")) | ||
| 344 | ((not (mh-folder-name-p mh-inbox)) | ||
| 345 | (setq mh-inbox (format "+%s" mh-inbox)))) | ||
| 346 | (setq mh-unseen-seq (mh-profile-component "Unseen-Sequence")) | ||
| 347 | (if mh-unseen-seq | ||
| 348 | (setq mh-unseen-seq (intern mh-unseen-seq)) | ||
| 349 | (setq mh-unseen-seq 'unseen)) ;old MH default? | ||
| 350 | (setq mh-previous-seq (mh-profile-component "Previous-Sequence")) | ||
| 351 | (if mh-previous-seq | ||
| 352 | (setq mh-previous-seq (intern mh-previous-seq))) | ||
| 353 | (run-hooks 'mh-find-path-hook) | ||
| 354 | (mh-collect-folder-names) | ||
| 355 | (setq mh-find-path-run t))) | ||
| 281 | 356 | ||
| 282 | 357 | ||
| 283 | 358 | ||
diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el index bc1b59f661c..b600a432735 100644 --- a/lisp/mh-e/mh-utils.el +++ b/lisp/mh-e/mh-utils.el | |||
| @@ -1950,12 +1950,18 @@ the message." | |||
| 1950 | (or dont-show (not return-value) (mh-maybe-show number)) | 1950 | (or dont-show (not return-value) (mh-maybe-show number)) |
| 1951 | return-value)) | 1951 | return-value)) |
| 1952 | 1952 | ||
| 1953 | (defun mh-get-profile-field (field) | 1953 | (defun mh-profile-component (component) |
| 1954 | "Find and return the value of FIELD in the current buffer. | 1954 | "Return COMPONENT value from mhparam, or nil if unset." |
| 1955 | Returns nil if the field is not in the buffer." | 1955 | (save-excursion |
| 1956 | (mh-exec-cmd-quiet nil "mhparam" "-components" component) | ||
| 1957 | (mh-profile-component-value component))) | ||
| 1958 | |||
| 1959 | (defun mh-profile-component-value (component) | ||
| 1960 | "Find and return the value of COMPONENT in the current buffer. | ||
| 1961 | Returns nil if the component is not in the buffer." | ||
| 1956 | (let ((case-fold-search t)) | 1962 | (let ((case-fold-search t)) |
| 1957 | (goto-char (point-min)) | 1963 | (goto-char (point-min)) |
| 1958 | (cond ((not (re-search-forward (format "^%s" field) nil t)) nil) | 1964 | (cond ((not (re-search-forward (format "^%s:" component) nil t)) nil) |
| 1959 | ((looking-at "[\t ]*$") nil) | 1965 | ((looking-at "[\t ]*$") nil) |
| 1960 | (t | 1966 | (t |
| 1961 | (re-search-forward "[\t ]*\\([^\t \n].*\\)$" nil t) | 1967 | (re-search-forward "[\t ]*\\([^\t \n].*\\)$" nil t) |
| @@ -1963,99 +1969,6 @@ Returns nil if the field is not in the buffer." | |||
| 1963 | (end-of-line) | 1969 | (end-of-line) |
| 1964 | (buffer-substring start (point))))))) | 1970 | (buffer-substring start (point))))))) |
| 1965 | 1971 | ||
| 1966 | (defvar mh-find-path-run nil | ||
| 1967 | "Non-nil if `mh-find-path' has been run already.") | ||
| 1968 | |||
| 1969 | (defun mh-find-path () | ||
| 1970 | "Set variables from user's MH profile. | ||
| 1971 | |||
| 1972 | This function sets `mh-user-path' from your \"Path:\" MH profile | ||
| 1973 | component (but defaults to \"Mail\" if one isn't present), | ||
| 1974 | `mh-draft-folder' from \"Draft-Folder:\", `mh-unseen-seq' from | ||
| 1975 | \"Unseen-Sequence:\", `mh-previous-seq' from | ||
| 1976 | \"Previous-Sequence:\", and `mh-inbox' from \"Inbox:\" (defaults | ||
| 1977 | to \"+inbox\"). | ||
| 1978 | |||
| 1979 | The hook `mh-find-path-hook' is run after these variables have | ||
| 1980 | been set. This hook can be used the change the value of these | ||
| 1981 | variables if you need to run with different values between MH and | ||
| 1982 | MH-E." | ||
| 1983 | (mh-variants) | ||
| 1984 | (unless mh-find-path-run | ||
| 1985 | (setq mh-find-path-run t) | ||
| 1986 | (save-excursion | ||
| 1987 | ;; Be sure profile is fully expanded before switching buffers | ||
| 1988 | (let ((profile (expand-file-name (or (getenv "MH") "~/.mh_profile")))) | ||
| 1989 | (set-buffer (get-buffer-create mh-temp-buffer)) | ||
| 1990 | (setq buffer-offer-save nil) ;for people who set default to t | ||
| 1991 | (erase-buffer) | ||
| 1992 | (condition-case err | ||
| 1993 | (insert-file-contents profile) | ||
| 1994 | (file-error | ||
| 1995 | (mh-install profile err))) | ||
| 1996 | (setq mh-user-path (mh-get-profile-field "Path:")) | ||
| 1997 | (if (not mh-user-path) | ||
| 1998 | (setq mh-user-path "Mail")) | ||
| 1999 | (setq mh-user-path | ||
| 2000 | (file-name-as-directory | ||
| 2001 | (expand-file-name mh-user-path (expand-file-name "~")))) | ||
| 2002 | (unless mh-x-image-cache-directory | ||
| 2003 | (setq mh-x-image-cache-directory | ||
| 2004 | (expand-file-name ".mhe-x-image-cache" mh-user-path))) | ||
| 2005 | (setq mh-draft-folder (mh-get-profile-field "Draft-Folder:")) | ||
| 2006 | (if mh-draft-folder | ||
| 2007 | (progn | ||
| 2008 | (if (not (mh-folder-name-p mh-draft-folder)) | ||
| 2009 | (setq mh-draft-folder (format "+%s" mh-draft-folder))) | ||
| 2010 | (if (not (file-exists-p (mh-expand-file-name mh-draft-folder))) | ||
| 2011 | (error | ||
| 2012 | "Draft folder \"%s\" not found. Create it and try again" | ||
| 2013 | (mh-expand-file-name mh-draft-folder))))) | ||
| 2014 | (setq mh-inbox (mh-get-profile-field "Inbox:")) | ||
| 2015 | (cond ((not mh-inbox) | ||
| 2016 | (setq mh-inbox "+inbox")) | ||
| 2017 | ((not (mh-folder-name-p mh-inbox)) | ||
| 2018 | (setq mh-inbox (format "+%s" mh-inbox)))) | ||
| 2019 | (setq mh-unseen-seq (mh-get-profile-field "Unseen-Sequence:")) | ||
| 2020 | (if mh-unseen-seq | ||
| 2021 | (setq mh-unseen-seq (intern mh-unseen-seq)) | ||
| 2022 | (setq mh-unseen-seq 'unseen)) ;old MH default? | ||
| 2023 | (setq mh-previous-seq (mh-get-profile-field "Previous-Sequence:")) | ||
| 2024 | (if mh-previous-seq | ||
| 2025 | (setq mh-previous-seq (intern mh-previous-seq))) | ||
| 2026 | (run-hooks 'mh-find-path-hook) | ||
| 2027 | (mh-collect-folder-names))))) | ||
| 2028 | |||
| 2029 | (defun mh-file-command-p (file) | ||
| 2030 | "Return t if file FILE is the name of a executable regular file." | ||
| 2031 | (and (file-regular-p file) (file-executable-p file))) | ||
| 2032 | |||
| 2033 | (defvar mh-no-install nil) ;do not run install-mh | ||
| 2034 | |||
| 2035 | (defun mh-install (profile error-val) | ||
| 2036 | "Initialize the MH environment. | ||
| 2037 | This is called if we fail to read the PROFILE file. ERROR-VAL is | ||
| 2038 | the error that made this call necessary." | ||
| 2039 | (if (or (getenv "MH") | ||
| 2040 | (file-exists-p profile) | ||
| 2041 | mh-no-install) | ||
| 2042 | (signal (car error-val) | ||
| 2043 | (list (format "Cannot read MH profile \"%s\"" profile) | ||
| 2044 | (car (cdr (cdr error-val)))))) | ||
| 2045 | ;; The "install-mh" command will output a short note which | ||
| 2046 | ;; mh-exec-cmd will display to the user. | ||
| 2047 | ;; The MH 5 version of install-mh might try prompt the user | ||
| 2048 | ;; for information, which would fail here. | ||
| 2049 | (mh-exec-cmd (expand-file-name "install-mh" mh-lib-progs) "-auto") | ||
| 2050 | ;; now try again to read the profile file | ||
| 2051 | (erase-buffer) | ||
| 2052 | (condition-case err | ||
| 2053 | (insert-file-contents profile) | ||
| 2054 | (file-error | ||
| 2055 | (signal (car err) ;re-signal with more specific msg | ||
| 2056 | (list (format "Cannot read MH profile \"%s\"" profile) | ||
| 2057 | (car (cdr (cdr err)))))))) | ||
| 2058 | |||
| 2059 | (defun mh-set-folder-modified-p (flag) | 1972 | (defun mh-set-folder-modified-p (flag) |
| 2060 | "Mark current folder as modified or unmodified according to FLAG." | 1973 | "Mark current folder as modified or unmodified according to FLAG." |
| 2061 | (set-buffer-modified-p flag)) | 1974 | (set-buffer-modified-p flag)) |
| @@ -2594,12 +2507,6 @@ RAISE-ERROR is non-nil, in which case an error is signaled if | |||
| 2594 | (mh-handle-process-error command value) | 2507 | (mh-handle-process-error command value) |
| 2595 | value))) | 2508 | value))) |
| 2596 | 2509 | ||
| 2597 | (defun mh-profile-component (component) | ||
| 2598 | "Return COMPONENT value from mhparam, or nil if unset." | ||
| 2599 | (save-excursion | ||
| 2600 | (mh-exec-cmd-quiet nil "mhparam" "-components" component) | ||
| 2601 | (mh-get-profile-field (concat component ":")))) | ||
| 2602 | |||
| 2603 | ;; Shush compiler. | 2510 | ;; Shush compiler. |
| 2604 | (eval-when-compile (defvar mark-active)) | 2511 | (eval-when-compile (defvar mark-active)) |
| 2605 | 2512 | ||