File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,28 @@ PROP is the name of a text property."
212
212
(when more-text (insert more-text))
213
213
(when break (insert " \n " )))
214
214
215
+
216
+ ; ;; Hooks
217
+
218
+ (defun cider-run-chained-hook (hook arg )
219
+ " Like `run-hook-with-args' but pass intermediate return values through.
220
+ HOOK is a name of a hook (a symbol). You can use `add-hook' or
221
+ `remove-hook' to add functions to this variable. ARG is passed to first
222
+ function. Its return value is passed to the second function and so forth
223
+ till all functions are called or one of them returns nil. Return the value
224
+ return by the last called function."
225
+ (let ((functions (copy-sequence (symbol-value hook))))
226
+ (while (and functions arg)
227
+ (if (eq (car functions) t )
228
+ ; ; global value of the hook
229
+ (let ((functions (default-value hook)))
230
+ (while (and functions arg)
231
+ (setq arg (funcall (car functions) arg))
232
+ (setq functions (cdr functions))))
233
+ (setq arg (funcall (car functions) arg)))
234
+ (setq functions (cdr functions)))
235
+ arg))
236
+
215
237
216
238
; ;; Font lock
217
239
Original file line number Diff line number Diff line change 54
54
cider-codename " Victory" )
55
55
(expect (cider--version) :to-equal " 0.11.0snapshot (package: 20160301.2217)" )))
56
56
57
+ (defvar some-cider-hook )
58
+
59
+ (describe " cider-run-chained-hook"
60
+ :var (some-cider-hook)
61
+
62
+ (it " chains correctly"
63
+ (setq some-cider-hook (list #'upcase (lambda (x ) (substring x 2 5 ))))
64
+ (expect (cider-run-chained-hook 'some-cider-hook " abcdefg" )
65
+ :to-equal " CDE" ))
66
+
67
+ (it " exits on first nil"
68
+ (let (here)
69
+ (setq some-cider-hook (list #'upcase (lambda (x ) nil ) (lambda (x ) (setq here t ))))
70
+ (cider-run-chained-hook 'some-cider-hook " A" )
71
+ (expect here :to-be nil ))))
72
+
57
73
(describe " cider-symbol-at-point"
58
74
(it " doesn't move the cursor"
59
75
(with-temp-buffer
You can’t perform that action at this time.
0 commit comments