From b649a257550f37ff7b0f96d417d4b80613141977 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 2 Apr 2021 13:07:24 -0500 Subject: Add `defun-with-hooks' --- lisp/acdw.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lisp/acdw.el') diff --git a/lisp/acdw.el b/lisp/acdw.el index 0203f3b..b127827 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -58,6 +58,16 @@ Ready for use with `after-focus-change-function'." (run-at-time sunset-time (* 60 60 24) sunset-command) (run-at-time "12:00am" (* 60 60 24) sunset-command))) +;;;; Define a function and add it to hooks +(defun defun-with-hooks (hooks function-def) + "Add FUNCTION-DEF to HOOKS. + +FUNCTION-DEF should be a `defun' form. This function is just to + put functions that only exist for hooks closer to the hooks + they bind to." + (let ((func function-def)) + (dolist (hook hooks) + (add-hook hook func)))) ;;; Garbage collection hacks (defconst acdw/gc-cons-threshold-basis (* 800 1024) -- cgit 1.4.1-21-gabe81