home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3327 / add-hook.el
Encoding:
Text File  |  1991-05-14  |  625 b   |  17 lines

  1. ;; add-hook function by Dan LaLiberte <liberte@cs.uiuc.edu>
  2. (defun add-hook (hook-var hook-function)
  3.   "Prepend to the value of HOOK-VAR the function HOOK-FUNCTION, if it
  4. is not already an element.
  5. hook-var's value may be a single function or a list of functions."
  6.   (if (boundp hook-var)
  7.       (let ((value (symbol-value hook-var)))
  8.     (if (and (listp value) (not (eq (car value) 'lambda)))
  9.         (and (not (memq hook-function value))
  10.          (set hook-var
  11.               (cons hook-function value)))
  12.       (and (not (eq hook-function value))
  13.            (set hook-var
  14.             (list hook-function value)))))
  15.     (set hook-var hook-function)
  16.     ))
  17.