File size: 1,636 Bytes
43203b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;;; protocol.lisp ---  Protocol for the cl-hooks system.
;;;;
;;;; Copyright (C) 2012, 2013, 2014 Jan Moringen
;;;;
;;;; Author: Jan Moringen <jmoringe@techfak.uni-bielefeld.de>

(cl:in-package #:hooks)

;;; Hook Protocol

(defgeneric hook-name (hook)
  (:documentation
   "Return the name of HOOK (a symbol)."))

(defgeneric hook-combination (hook)
  (:documentation
   "Return the hook combination used by HOOK."))

(defgeneric (setf hook-combination) (new-value hook)
  (:documentation
   "Install NEW-VALUE as the hook combination used by HOOK."))

(defgeneric hook-handlers (hook)
  (:documentation
   "Return a list of handlers attached to HOOK."))

(defgeneric (setf hook-handlers) (new-value hook)
  (:documentation
   "Replace list of handlers attached to HOOK with NEW-VALUE."))

(defgeneric add-to-hook (hook handler &key duplicate-policy)
  (:documentation
   "Add HANDLER to HOOK."))

(defgeneric remove-from-hook (hook handler)
  (:documentation
   "Remove HANDLER from HOOK."))

(defgeneric clear-hook (hook)
  (:documentation
   "Remove all handlers from HOOK."))

(defgeneric run-hook (hook &rest args)
  (:documentation
   "Run HOOK passing extra args ARGS to all handlers."))

(defgeneric combine-results (hook combination results)
  (:documentation
   "Combine RESULTS of running HOOK's handlers according to COMBINATION."))

;;; Hook documentation
;;;
;;; Implementations of hook kinds should define methods on
;;; `cl:documentation' for documentation type `hooks:hook'.

(intern "HOOK")

;; + documentation ((hook TYPE) (type (eql 'hook)))
;; + (setf documentation) ((new-value t) (hook TYPE) (type (eql 'hook)))