Initial Commit
[packages] / xemacs-packages / hyperbole / hvar.el
1 ;;; hvar.el --- Variable manipulation routines for Hyperbole.
2
3 ;; Copyright (C) 1991-1995, Free Software Foundation, Inc.
4 ;; Developed with support from Motorola Inc.
5
6 ;; Author: Bob Weiner, Brown U.
7 ;; Maintainer: Mats Lidell <matsl@contactor.se>
8 ;; Keywords: extensions, hypermedia
9
10 ;; This file is part of GNU Hyperbole.
11
12 ;; GNU Hyperbole is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 3, or (at
15 ;; your option) any later version.
16
17 ;; GNU Hyperbole 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 GNU
20 ;; 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
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;;; Code:
30
31 ;;;
32 ;;; Other required Elisp libraries
33 ;;;
34
35 (require 'set)
36
37 ;;;
38 ;;; Public functions
39 ;;;
40
41 ;;;###autoload
42 (defun var:append (var-symbol-name list-to-add)
43   "Appends to value held by VAR-SYMBOL-NAME, LIST-TO-ADD.  Returns new value.
44 If VAR-SYMBOL-NAME is unbound, it is set to LIST-TO-ADD.
45 Often used to append to 'hook' variables."
46   (let ((val))
47     (if (and (boundp var-symbol-name)
48              (setq val (symbol-value var-symbol-name))
49              (or (if (symbolp val) (setq val (cons val nil)))
50                  (listp val)))
51         ;; Don't add if list elts are already there.
52         (if (memq nil (mapcar (function
53                                 (lambda (elt) (set:member elt val)))
54                               list-to-add))
55             (set-variable var-symbol-name
56                           (if (eq (car val) 'lambda)
57                               (apply 'list val list-to-add)
58                             (append val list-to-add)))
59           val)
60       (set-variable var-symbol-name list-to-add))))
61
62 (provide 'hvar)
63
64
65 ;;; hvar.el ends here