0
|
1 ;;!emacs
|
|
2 ;;
|
|
3 ;; FILE: hvar.el
|
|
4 ;; SUMMARY: Variable manipulation routines for Hyperbole.
|
|
5 ;; USAGE: GNU Emacs Lisp Library
|
|
6 ;; KEYWORDS: extensions, hypermedia
|
|
7 ;;
|
|
8 ;; AUTHOR: Bob Weiner
|
|
9 ;; ORG: Brown U.
|
|
10 ;;
|
|
11 ;; ORIG-DATE: 1-Oct-91 at 14:00:24
|
|
12 ;; LAST-MOD: 14-Apr-95 at 16:13:46 by Bob Weiner
|
|
13 ;;
|
|
14 ;; This file is part of Hyperbole.
|
|
15 ;; Available for use and distribution under the same terms as GNU Emacs.
|
|
16 ;;
|
|
17 ;; Copyright (C) 1991-1995, Free Software Foundation, Inc.
|
|
18 ;; Developed with support from Motorola Inc.
|
|
19 ;;
|
|
20 ;; DESCRIPTION:
|
|
21 ;; DESCRIP-END.
|
|
22
|
|
23 ;;; ************************************************************************
|
|
24 ;;; Other required Elisp libraries
|
|
25 ;;; ************************************************************************
|
|
26
|
|
27 (require 'set)
|
|
28
|
|
29 ;;; ************************************************************************
|
|
30 ;;; Public functions
|
|
31 ;;; ************************************************************************
|
|
32
|
|
33 ;;;###autoload
|
|
34 (defun var:append (var-symbol-name list-to-add)
|
|
35 "Appends to value held by VAR-SYMBOL-NAME, LIST-TO-ADD. Returns new value.
|
|
36 If VAR-SYMBOL-NAME is unbound, it is set to LIST-TO-ADD.
|
|
37 Often used to append to 'hook' variables."
|
|
38 (let ((val))
|
|
39 (if (and (boundp var-symbol-name)
|
|
40 (setq val (symbol-value var-symbol-name))
|
|
41 (or (if (symbolp val) (setq val (cons val nil)))
|
|
42 (listp val)))
|
|
43 ;; Don't add if list elts are already there.
|
|
44 (if (memq nil (mapcar (function
|
|
45 (lambda (elt) (set:member elt val)))
|
|
46 list-to-add))
|
|
47 (set-variable var-symbol-name
|
|
48 (if (eq (car val) 'lambda)
|
|
49 (apply 'list val list-to-add)
|
|
50 (append val list-to-add)))
|
|
51 val)
|
|
52 (set-variable var-symbol-name list-to-add))))
|
|
53
|
|
54 (provide 'hvar)
|
|
55
|