Add threading macros to the utils module
This commit is contained in:
parent
e11e132a59
commit
149d9c6b00
|
@ -129,5 +129,34 @@ or
|
|||
(last paths))))
|
||||
|
||||
|
||||
(defmacro -> (x &optional form &rest more)
|
||||
"Thread the expr through the forms FORM and rest of form in MORE.
|
||||
Insert X as the second item in the first form, making a list of
|
||||
it if it is not a list already. If there are more forms, insert
|
||||
the first form as the second item in second form, etc."
|
||||
(declare (debug (form &rest [&or symbolp (sexp &rest form)])))
|
||||
(cond
|
||||
((null form) x)
|
||||
((null more) (if (listp form)
|
||||
`(,(car form) ,x ,@(cdr form))
|
||||
(list form x)))
|
||||
(:else `(-> (-> ,x ,form) ,@more))))
|
||||
|
||||
|
||||
(defmacro ->> (x &optional form &rest more)
|
||||
"Thread the expr through the forms FORM and the rest at MORE.
|
||||
Insert X as the last item in the first form, making a list of
|
||||
it if it is not a list already. If there are more forms, insert
|
||||
the first form as the
|
||||
last item in second form, etc."
|
||||
(declare (debug ->))
|
||||
(cond
|
||||
((null form) x)
|
||||
((null more) (if (listp form)
|
||||
`(,@form ,x)
|
||||
(list form x)))
|
||||
(:else `(->> (->> ,x ,form) ,@more))))
|
||||
|
||||
|
||||
(provide 'fg42/utils)
|
||||
;;; utils.el ends here
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
;; Bind "s-r" to exit char-mode and fullscreen mode.
|
||||
([?\s-r] . exwm-reset)
|
||||
([?\s-g] . keyboard-quit)
|
||||
([8388640] . other-window)
|
||||
;; Bind "s-w" to switch workspace interactively.
|
||||
([?\s-w] . exwm-workspace-switch)
|
||||
;; Bind "s-0" to "s-9" to switch to a workspace by its index.
|
||||
|
|
Loading…
Reference in New Issue