Mercurial > emacs
annotate lisp/mh-e/mh-init.el @ 67868:478378ca909b
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 28 Dec 2005 02:09:45 +0000 |
parents | 9c3504ae6060 |
children | 3ca8b2234237 |
rev | line source |
---|---|
67681 | 1 ;;; mh-init.el --- MH-E initialization |
56676 | 2 |
67245
4b8cea82e2d9
(mh-defface-compat): Checkdoc fix.
Bill Wohler <wohler@newt.com>
parents:
66716
diff
changeset
|
3 ;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
56676 | 4 |
5 ;; Author: Peter S. Galbraith <psg@debian.org> | |
6 ;; Maintainer: Bill Wohler <wohler@newt.com> | |
7 ;; Keywords: mail | |
8 ;; See: mh-e.el | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
56676 | 26 |
27 ;;; Commentary: | |
28 | |
66716
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
29 ;; Sets up the MH variant (currently nmh, MH, or GNU mailutils). |
56676 | 30 ;; |
31 ;; Users may customize `mh-variant' to switch between available variants. | |
32 ;; Available MH variants are described in the variable `mh-variants'. | |
33 ;; Developers may check which variant is currently in use with the | |
34 ;; variable `mh-variant-in-use' or the function `mh-variant-p'. | |
66716
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
35 ;; |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
36 ;; Also contains code that is used at load or initialization time only. |
56676 | 37 |
38 ;;; Change Log: | |
39 | |
40 ;;; Code: | |
41 | |
42 (eval-when-compile (require 'mh-acros)) | |
43 (mh-require-cl) | |
44 (require 'mh-utils) | |
45 | |
67681 | 46 ;; Avoid compiler warnings. |
65980
4520ae2624f2
* mh-init.el (mh-image-load-path): New function that adds the path to
Bill Wohler <wohler@newt.com>
parents:
64085
diff
changeset
|
47 (eval-when-compile (defvar image-load-path)) |
4520ae2624f2
* mh-init.el (mh-image-load-path): New function that adds the path to
Bill Wohler <wohler@newt.com>
parents:
64085
diff
changeset
|
48 |
67681 | 49 ;; Set for local environment: |
50 ;; mh-progs and mh-lib used to be set in paths.el, which tried to | |
51 ;; figure out at build time which of several possible directories MH | |
52 ;; was installed into. But if you installed MH after building Emacs, | |
53 ;; this would almost certainly be wrong, so now we do it at run time. | |
56676 | 54 |
55 (defvar mh-progs nil | |
56 "Directory containing MH commands, such as inc, repl, and rmm.") | |
57 | |
58 (defvar mh-lib nil | |
59 "Directory containing the MH library. | |
60 This directory contains, among other things, the components file.") | |
61 | |
62 (defvar mh-lib-progs nil | |
63 "Directory containing MH helper programs. | |
64 This directory contains, among other things, the mhl program.") | |
65 | |
66 (defvar mh-flists-present-flag nil | |
67760
9c3504ae6060
Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents:
67758
diff
changeset
|
67 "Non-nil means that we have \"flists\".") |
56676 | 68 |
69 ;;;###autoload | |
70 (put 'mh-progs 'risky-local-variable t) | |
71 ;;;###autoload | |
72 (put 'mh-lib 'risky-local-variable t) | |
73 ;;;###autoload | |
74 (put 'mh-lib-progs 'risky-local-variable t) | |
75 | |
67449
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
76 (defvar mh-variants nil |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
77 "List describing known MH variants. |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
78 Created by the function `mh-variants'") |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
79 |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
80 ;;;###mh-autoload |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
81 (defun mh-variants () |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
82 "Return a list of installed variants of MH on the system. |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
83 This function looks for MH in `mh-sys-path', `mh-path' and |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
84 `exec-path'. The format of the list of variants that is returned |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
85 is described by the variable `mh-variants'." |
67449
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
86 (if mh-variants |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
87 mh-variants |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
88 (let ((list-unique)) |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
89 ;; Make a unique list of directories, keeping the given order. |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
90 ;; We don't want the same MH variant to be listed multiple times. |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
91 (loop for dir in (append mh-path mh-sys-path exec-path) do |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
92 (setq dir (file-chase-links (directory-file-name dir))) |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
93 (add-to-list 'list-unique dir)) |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
94 (loop for dir in (nreverse list-unique) do |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
95 (when (and dir (file-directory-p dir) (file-readable-p dir)) |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
96 (let ((variant (mh-variant-info dir))) |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
97 (if variant |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
98 (add-to-list 'mh-variants variant))))) |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
99 mh-variants))) |
315e71e95246
* mh-customize.el (mh-path): Move here from mh-init.el.
Bill Wohler <wohler@newt.com>
parents:
67245
diff
changeset
|
100 |
56676 | 101 (defvar mh-variant-in-use nil |
102 "The MH variant currently in use; a string with variant and version number. | |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
103 This differs from `mh-variant' when the latter is set to |
67760
9c3504ae6060
Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents:
67758
diff
changeset
|
104 \"autodetect\".") |
56676 | 105 |
106 ;;;###mh-autoload | |
107 (defun mh-variant-set (variant) | |
108 "Set the MH variant to VARIANT. | |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
109 Sets `mh-progs', `mh-lib', `mh-lib-progs' and |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
110 `mh-flists-present-flag'. |
67760
9c3504ae6060
Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents:
67758
diff
changeset
|
111 If the VARIANT is \"autodetect\", then first try nmh, then MH and |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
112 finally GNU mailutils." |
56676 | 113 (interactive |
114 (list (completing-read | |
115 "MH Variant: " | |
116 (mapcar (lambda (x) (list (car x))) (mh-variants)) | |
117 nil t))) | |
118 (let ((valid-list (mapcar (lambda (x) (car x)) (mh-variants)))) | |
119 (cond | |
120 ((eq variant 'none)) | |
121 ((eq variant 'autodetect) | |
122 (cond | |
123 ((mh-variant-set-variant 'nmh) | |
124 (message "%s installed as MH variant" mh-variant-in-use)) | |
56787
25da1d331c99
Upgraded to MH-E version 7.82.
Bill Wohler <wohler@newt.com>
parents:
56677
diff
changeset
|
125 ((mh-variant-set-variant 'mh) |
56676 | 126 (message "%s installed as MH variant" mh-variant-in-use)) |
127 ((mh-variant-set-variant 'mu-mh) | |
128 (message "%s installed as MH variant" mh-variant-in-use)) | |
129 (t | |
130 (message "No MH variant found on the system!")))) | |
131 ((member variant valid-list) | |
132 (when (not (mh-variant-set-variant variant)) | |
133 (message "Warning: %s variant not found. Autodetecting..." variant) | |
134 (mh-variant-set 'autodetect))) | |
135 (t | |
136 (message "Unknown variant. Use %s" | |
137 (mapconcat '(lambda (x) (format "%s" (car x))) | |
138 mh-variants " or ")))))) | |
139 | |
140 (defun mh-variant-set-variant (variant) | |
141 "Setup the system variables for the MH variant named VARIANT. | |
142 If VARIANT is a string, use that key in the variable `mh-variants'. | |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
143 If VARIANT is a symbol, select the first entry that matches that |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
144 variant." |
56676 | 145 (cond |
146 ((stringp variant) ;e.g. "nmh 1.1-RC1" | |
147 (when (assoc variant mh-variants) | |
148 (let* ((alist (cdr (assoc variant mh-variants))) | |
149 (lib-progs (cadr (assoc 'mh-lib-progs alist))) | |
150 (lib (cadr (assoc 'mh-lib alist))) | |
151 (progs (cadr (assoc 'mh-progs alist))) | |
152 (flists (cadr (assoc 'flists alist)))) | |
153 ;;(set-default mh-variant variant) | |
154 (setq mh-x-mailer-string nil | |
155 mh-flists-present-flag flists | |
156 mh-lib-progs lib-progs | |
157 mh-lib lib | |
158 mh-progs progs | |
159 mh-variant-in-use variant)))) | |
160 ((symbolp variant) ;e.g. 'nmh (pick the first match) | |
161 (loop for variant-list in mh-variants | |
162 when (eq variant (cadr (assoc 'variant (cdr variant-list)))) | |
163 return (let* ((version (car variant-list)) | |
164 (alist (cdr variant-list)) | |
165 (lib-progs (cadr (assoc 'mh-lib-progs alist))) | |
166 (lib (cadr (assoc 'mh-lib alist))) | |
167 (progs (cadr (assoc 'mh-progs alist))) | |
168 (flists (cadr (assoc 'flists alist)))) | |
169 ;;(set-default mh-variant flavor) | |
170 (setq mh-x-mailer-string nil | |
171 mh-flists-present-flag flists | |
172 mh-lib-progs lib-progs | |
173 mh-lib lib | |
174 mh-progs progs | |
175 mh-variant-in-use version) | |
176 t))))) | |
177 | |
178 ;;;###mh-autoload | |
179 (defun mh-variant-p (&rest variants) | |
180 "Return t if variant is any of VARIANTS. | |
56787
25da1d331c99
Upgraded to MH-E version 7.82.
Bill Wohler <wohler@newt.com>
parents:
56677
diff
changeset
|
181 Currently known variants are 'MH, 'nmh, and 'mu-mh." |
56676 | 182 (let ((variant-in-use |
183 (cadr (assoc 'variant (assoc mh-variant-in-use mh-variants))))) | |
184 (not (null (member variant-in-use variants))))) | |
185 | |
186 (defvar mh-sys-path | |
187 '("/usr/local/nmh/bin" ; nmh default | |
188 "/usr/local/bin/mh/" | |
189 "/usr/local/mh/" | |
190 "/usr/bin/mh/" ; Ultrix 4.2, Linux | |
191 "/usr/new/mh/" ; Ultrix < 4.2 | |
192 "/usr/contrib/mh/bin/" ; BSDI | |
193 "/usr/pkg/bin/" ; NetBSD | |
194 "/usr/local/bin/" | |
195 "/usr/local/bin/mu-mh/" ; GNU mailutils - default | |
196 "/usr/bin/mu-mh/") ; GNU mailutils - packaged | |
197 "List of directories to search for variants of the MH variant. | |
198 The list `exec-path' is searched in addition to this list. | |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
199 There's no need for users to modify this list. Instead add extra |
56676 | 200 directories to the customizable variable `mh-path'.") |
201 | |
202 (defun mh-variant-mh-info (dir) | |
203 "Return info for MH variant in DIR assuming a temporary buffer is setup." | |
204 ;; MH does not have the -version option. | |
67760
9c3504ae6060
Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents:
67758
diff
changeset
|
205 ;; Its version number is included in the output of "-help" as: |
56676 | 206 ;; |
207 ;; version: MH 6.8.4 #2[UCI] (burrito) of Fri Jan 15 20:01:39 EST 1999 | |
208 ;; options: [ATHENA] [BIND] [DUMB] [LIBLOCKFILE] [LOCALE] [MAILGROUP] [MHE] | |
209 ;; [MHRC] [MIME] [MORE='"/usr/bin/sensible-pager"'] [NLINK_HACK] | |
210 ;; [NORUSERPASS] [OVERHEAD] [POP] [POPSERVICE='"pop-3"'] [RENAME] | |
211 ;; [RFC1342] [RPATHS] [RPOP] [SENDMTS] [SMTP] [SOCKETS] | |
212 ;; [SPRINTFTYPE=int] [SVR4] [SYS5] [SYS5DIR] [TERMINFO] | |
213 ;; [TYPESIG=void] [UNISTD] [UTK] [VSPRINTF] | |
214 (let ((mhparam (expand-file-name "mhparam" dir))) | |
215 (when (and (file-exists-p mhparam) (file-executable-p mhparam)) | |
216 (erase-buffer) | |
217 (call-process mhparam nil '(t nil) nil "-help") | |
218 (goto-char (point-min)) | |
219 (when (search-forward-regexp "version: MH \\(\\S +\\)" nil t) | |
220 (let ((version (format "MH %s" (match-string 1)))) | |
221 (erase-buffer) | |
222 (call-process mhparam nil '(t nil) nil "libdir") | |
223 (goto-char (point-min)) | |
224 (when (search-forward-regexp "^.*$" nil t) | |
225 (let ((libdir (match-string 0))) | |
226 `(,version | |
227 (variant mh) | |
228 (mh-lib-progs ,libdir) | |
229 (mh-lib ,libdir) | |
230 (mh-progs ,dir) | |
231 (flists nil))))))))) | |
232 | |
233 (defun mh-variant-mu-mh-info (dir) | |
234 "Return info for GNU mailutils variant in DIR. | |
235 This assumes that a temporary buffer is setup." | |
236 ;; 'mhparam -version' output: | |
237 ;; mhparam (GNU mailutils 0.3.2) | |
238 (let ((mhparam (expand-file-name "mhparam" dir))) | |
239 (when (and (file-exists-p mhparam) (file-executable-p mhparam)) | |
240 (erase-buffer) | |
241 (call-process mhparam nil '(t nil) nil "-version") | |
242 (goto-char (point-min)) | |
243 (when (search-forward-regexp "mhparam (\\(GNU [Mm]ailutils \\S +\\))" | |
244 nil t) | |
245 (let ((version (match-string 1))) | |
246 (erase-buffer) | |
247 (call-process mhparam nil '(t nil) nil "libdir" "etcdir") | |
248 (goto-char (point-min)) | |
249 (when (search-forward-regexp "^libdir:\\s-\\(\\S-+\\)\\s-*$" nil t) | |
250 (let ((libdir (match-string 1))) | |
251 (goto-char (point-min)) | |
252 (when (search-forward-regexp | |
253 "^etcdir:\\s-\\(\\S-+\\)\\s-*$" nil t) | |
254 (let ((etcdir (match-string 1)) | |
255 (flists (file-exists-p (expand-file-name "flists" dir)))) | |
256 `(,version | |
257 (variant mu-mh) | |
258 (mh-lib-progs ,libdir) | |
259 (mh-lib ,etcdir) | |
260 (mh-progs ,dir) | |
261 (flists ,flists))))))))))) | |
262 | |
263 (defun mh-variant-nmh-info (dir) | |
264 "Return info for nmh variant in DIR assuming a temporary buffer is setup." | |
265 ;; `mhparam -version' outputs: | |
266 ;; mhparam -- nmh-1.1-RC1 [compiled on chaak at Fri Jun 20 11:03:28 PDT 2003] | |
267 (let ((mhparam (expand-file-name "mhparam" dir))) | |
268 (when (and (file-exists-p mhparam) (file-executable-p mhparam)) | |
269 (erase-buffer) | |
270 (call-process mhparam nil '(t nil) nil "-version") | |
271 (goto-char (point-min)) | |
272 (when (search-forward-regexp "mhparam -- nmh-\\(\\S +\\)" nil t) | |
273 (let ((version (format "nmh %s" (match-string 1)))) | |
274 (erase-buffer) | |
275 (call-process mhparam nil '(t nil) nil "libdir" "etcdir") | |
276 (goto-char (point-min)) | |
277 (when (search-forward-regexp "^libdir:\\s-\\(\\S-+\\)\\s-*$" nil t) | |
278 (let ((libdir (match-string 1))) | |
279 (goto-char (point-min)) | |
280 (when (search-forward-regexp | |
281 "^etcdir:\\s-\\(\\S-+\\)\\s-*$" nil t) | |
282 (let ((etcdir (match-string 1)) | |
283 (flists (file-exists-p (expand-file-name "flists" dir)))) | |
284 `(,version | |
285 (variant nmh) | |
286 (mh-lib-progs ,libdir) | |
287 (mh-lib ,etcdir) | |
288 (mh-progs ,dir) | |
289 (flists ,flists))))))))))) | |
290 | |
291 (defun mh-variant-info (dir) | |
292 "Return MH variant found in DIR, or nil if none present." | |
293 (save-excursion | |
294 (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) | |
295 (set-buffer tmp-buffer) | |
296 (cond | |
297 ((mh-variant-mh-info dir)) | |
298 ((mh-variant-nmh-info dir)) | |
299 ((mh-variant-mu-mh-info dir)))))) | |
300 | |
66716
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
301 |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
302 |
66113
bfb1c3364c23
* mh-init.el (mh-image-load-path-called-flag): New variable which
Satyaki Das <satyaki@theforce.stanford.edu>
parents:
66087
diff
changeset
|
303 (defvar mh-image-load-path-called-flag nil) |
bfb1c3364c23
* mh-init.el (mh-image-load-path-called-flag): New variable which
Satyaki Das <satyaki@theforce.stanford.edu>
parents:
66087
diff
changeset
|
304 |
65980
4520ae2624f2
* mh-init.el (mh-image-load-path): New function that adds the path to
Bill Wohler <wohler@newt.com>
parents:
64085
diff
changeset
|
305 ;;;###mh-autoload |
4520ae2624f2
* mh-init.el (mh-image-load-path): New function that adds the path to
Bill Wohler <wohler@newt.com>
parents:
64085
diff
changeset
|
306 (defun mh-image-load-path () |
4520ae2624f2
* mh-init.el (mh-image-load-path): New function that adds the path to
Bill Wohler <wohler@newt.com>
parents:
64085
diff
changeset
|
307 "Ensure that the MH-E images are accessible by `find-image'. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
308 Images for MH-E are found in ../../etc/images relative to the |
67760
9c3504ae6060
Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents:
67758
diff
changeset
|
309 files in \"lisp/mh-e\". If `image-load-path' exists (since Emacs |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
310 22), then the images directory is added to it if isn't already |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
311 there. Otherwise, the images directory is added to the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
312 `load-path' if it isn't already there." |
66113
bfb1c3364c23
* mh-init.el (mh-image-load-path-called-flag): New variable which
Satyaki Das <satyaki@theforce.stanford.edu>
parents:
66087
diff
changeset
|
313 (unless mh-image-load-path-called-flag |
66136
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
314 (let (mh-library-name mh-image-load-path) |
66113
bfb1c3364c23
* mh-init.el (mh-image-load-path-called-flag): New variable which
Satyaki Das <satyaki@theforce.stanford.edu>
parents:
66087
diff
changeset
|
315 ;; First, find mh-e in the load-path. |
66136
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
316 (setq mh-library-name (locate-library "mh-e")) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
317 (if (not mh-library-name) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
318 (error "Can not find MH-E in load-path")) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
319 (setq mh-image-load-path |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
320 (expand-file-name (concat (file-name-directory mh-library-name) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
321 "../../etc/images"))) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
322 (if (not (file-exists-p mh-image-load-path)) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
323 (error "Can not find image directory %s" mh-image-load-path)) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
324 (if (boundp 'image-load-path) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
325 (add-to-list 'image-load-path mh-image-load-path) |
aacff8293f4b
(mh-image-load-path): Use locate-library to find MH-E. This simplified
Bill Wohler <wohler@newt.com>
parents:
66128
diff
changeset
|
326 (add-to-list 'load-path mh-image-load-path))) |
66113
bfb1c3364c23
* mh-init.el (mh-image-load-path-called-flag): New variable which
Satyaki Das <satyaki@theforce.stanford.edu>
parents:
66087
diff
changeset
|
327 (setq mh-image-load-path-called-flag t))) |
65980
4520ae2624f2
* mh-init.el (mh-image-load-path): New function that adds the path to
Bill Wohler <wohler@newt.com>
parents:
64085
diff
changeset
|
328 |
66716
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
329 |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
330 |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
331 (defvar mh-min-colors-defined-flag (and (not mh-xemacs-flag) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
332 (>= emacs-major-version 22)) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
333 "Non-nil means defface supports min-colors display requirement.") |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
334 |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
335 (defun mh-defface-compat (spec) |
67245
4b8cea82e2d9
(mh-defface-compat): Checkdoc fix.
Bill Wohler <wohler@newt.com>
parents:
66716
diff
changeset
|
336 "Convert SPEC for defface if necessary to run on older platforms. |
66716
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
337 See `defface' for the spec definition. |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
338 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
339 When `mh-min-colors-defined-flag' is nil, this function finds a |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
340 display with a single \"class\" requirement with a \"color\" |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
341 item, renames the requirement to \"tty\" and moves it to the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
342 beginning of the list. It then strips any \"min-colors\" |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
343 requirements." |
66716
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
344 (when (not mh-min-colors-defined-flag) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
345 ;; Insert ((class tty)) display with ((class color)) attributes. |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
346 (let ((attributes (cdr (assoc '((class color)) spec)))) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
347 (cons (cons '((class tty)) attributes) spec)) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
348 ;; Delete ((class color)) display. |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
349 (delq (assoc '((class color)) spec) spec) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
350 ;; Strip min-colors. |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
351 (loop for entry in spec do |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
352 (when (not (eq (car entry) t)) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
353 (if (assoc 'min-colors (car entry)) |
25ad3e63f2a1
* mh-customize.el (mh-min-colors-defined-flag, mh-defface-compat):
Bill Wohler <wohler@newt.com>
parents:
66136
diff
changeset
|
354 (delq (assoc 'min-colors (car entry)) (car entry))))))) |
67245
4b8cea82e2d9
(mh-defface-compat): Checkdoc fix.
Bill Wohler <wohler@newt.com>
parents:
66716
diff
changeset
|
355 |
56676 | 356 (provide 'mh-init) |
357 | |
67681 | 358 ;; Local Variables: |
359 ;; indent-tabs-mode: nil | |
360 ;; sentence-end-double-space: nil | |
361 ;; End: | |
56676 | 362 |
56677 | 363 ;; arch-tag: e8372aeb-d803-42b1-9c95-3c93ad22f63c |
56676 | 364 ;;; mh-init.el ends here |