annotate lisp/config.el @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents d44af0c54775
children 3b3709405255
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1 ;;; config.el --- access configuration parameters
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 Sun Microsystems, Inc.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
4
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
5 ;; Author: Martin Buchholz
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
6 ;; Keywords: configure
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
7
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
9
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
13 ;; any later version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
14
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
19
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
24
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
25 ;;; Synched up with: not in FSF.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
26
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
27 ;;; Commentary:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
28
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
29 ;;; Code:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
30
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
31
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
32 (defvar config-value-file (expand-file-name "config.values" exec-directory)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
33 "File containing configuration parameters and their values.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
34
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
35 (defvar config-value-hash-table nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
36 "Hashtable to store configuration parameters and their values.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
37
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
38 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
39 (defun config-value-hash-table ()
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 217
diff changeset
40 "Return hashtable of configuration parameters and their values."
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
41 (when (null config-value-hash-table)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
42 (setq config-value-hash-table (make-hashtable 300))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
43 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
44 (let ((buf (get-buffer-create " *Config*")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
45 (set-buffer buf)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
46 (erase-buffer)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
47 (insert-file-contents config-value-file)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
48 (goto-char (point-min))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
49 (condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
50 (while t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
51 (let* ((key (read buf))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
52 (value (read buf))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
53 (prev (gethash key config-value-hash-table)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
54 (cond ((null prev)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
55 (puthash key value config-value-hash-table))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
56 ((atom prev)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
57 (puthash key (list prev value) config-value-hash-table))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
58 (t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
59 (nconc prev (list value))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
60 (end-of-file nil)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
61 (kill-buffer " *Config*")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
62 config-value-hash-table)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
63
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
64 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
65 (defun config-value (config-symbol)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
66 "Return the value of the configuration parameter CONFIG_SYMBOL."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
67 (gethash config-symbol (config-value-hash-table)))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 217
diff changeset
68
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
69 (provide 'config)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
70 ;;; config.el ends here