returning nil from a hook immediately blocks the event."
(setq hook1-var 0)
(setq hook2-var 0)
+ (setq types '())
(let ((orig-vars (snitch-test--save-vars t))
- (hook1 (lambda (type event) (setq hook1-var (+ hook1-var 1)) t))
+ (hook1 (lambda (type event)
+ (add-to-list 'types type)
+ (setq hook1-var (+ hook1-var 1)) t))
(hook2 (lambda (type event) (setq hook2-var (+ hook2-var 1)) t))
(hook3 (lambda (type event) nil)))
(snitch-test--clear-vars 'allow 'allow t)
(should (equal hook1-var 4))
(should (equal hook2-var 4))
+ (should (eq 1 (length types)))
+ (should (memq 'event types))
+
;; cleanup
(snitch-test--restore-vars orig-vars)
(snitch-test--cleanup)))
event, and that returning nil from the hooks blocks the event."
(setq hook1-var 0)
(setq hook2-var 0)
+ (setq types '())
(let ((orig-vars (snitch-test--save-vars t))
- (hook1 (lambda (type event) (setq hook1-var (+ hook1-var 1)) t))
+ (hook1 (lambda (type event)
+ (add-to-list 'types type)
+ (setq hook1-var (+ hook1-var 1)) t))
(hook2 (lambda (type event) (setq hook2-var (+ hook2-var 1)) t))
(hook3 (lambda (type event) nil)))
(snitch-test--clear-vars 'allow 'allow t)
(should (equal hook1-var 8))
(should (equal hook2-var 8))
+ (should (eq 2 (length types)))
+ (should (memq 'event types))
+ (should (memq 'allow types))
+
;; cleanup
(snitch-test--restore-vars orig-vars)
(snitch-test--cleanup)))
event, and that returning nil causes snitch to accept the event."
(setq hook1-var 0)
(setq hook2-var 0)
+ (setq types '())
(let ((orig-vars (snitch-test--save-vars t))
- (hook1 (lambda (type event) (setq hook1-var (+ hook1-var 1)) t))
+ (hook1 (lambda (type event)
+ (add-to-list 'types type)
+ (setq hook1-var (+ hook1-var 1)) t))
(hook2 (lambda (type event) (setq hook2-var (+ hook2-var 1)) t))
(hook3 (lambda (type event) nil)))
(snitch-test--clear-vars 'deny 'deny t)
(should (equal hook1-var 8))
(should (equal hook2-var 8))
+ (should (eq 2 (length types)))
+ (should (memq 'event types))
+ (should (memq 'block types))
+
;; cleanup
(snitch-test--restore-vars orig-vars)
(snitch-test--cleanup)))
snitch to block it."
(setq hook1-var 0)
(setq hook2-var 0)
+ (setq types '())
(let ((orig-vars (snitch-test--save-vars t))
- (hook1 (lambda (type event) (setq hook1-var (+ hook1-var 1)) t))
+ (hook1 (lambda (type event)
+ (add-to-list 'types type)
+ (setq hook1-var (+ hook1-var 1)) t))
(hook2 (lambda (type event) (setq hook2-var (+ hook2-var 1)) t))
(hook3 (lambda (type event) nil)))
(snitch-test--clear-vars 'deny 'deny t)
(should (equal hook1-var 8))
(should (equal hook2-var 8))
+ (should (eq 2 (length types)))
+ (should (memq 'event types))
+ (should (memq 'whitelist types))
+
;; cleanup
(snitch-test--restore-vars orig-vars)
(snitch-test--cleanup)))
snitch to accept it."
(setq hook1-var 0)
(setq hook2-var 0)
+ (setq types '())
(let ((orig-vars (snitch-test--save-vars t))
- (hook1 (lambda (type event) (setq hook1-var (+ hook1-var 1)) t))
+ (hook1 (lambda (type event)
+ (add-to-list 'types type)
+ (setq hook1-var (+ hook1-var 1)) t))
(hook2 (lambda (type event) (setq hook2-var (+ hook2-var 1)) t))
(hook3 (lambda (type event) nil)))
(snitch-test--clear-vars 'allow 'allow t)
(should (equal hook1-var 8))
(should (equal hook2-var 8))
+ (should (eq 2 (length types)))
+ (should (memq 'event types))
+ (should (memq 'blacklist types))
+
;; cleanup
(snitch-test--restore-vars orig-vars)
(snitch-test--cleanup)))
;; hooks override the list, return t.
when (apply f-fn (cons event f-args))
return (run-hook-with-args-until-failure list-hook-fns
- 'list-evt-type
+ list-evt-type
event)
;; otherwise fall back on default policy
finally return