diff options
author | Sean Allred <code@seanallred.com> | 2014-11-07 18:51:23 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-07 18:51:23 -0500 |
commit | 1207f47bd2340922268a1340601d45e6c336c11a (patch) | |
tree | d4ff02bcfcf8ce1f2d7ccb46998dff647c4b3cd7 /sx.el | |
parent | e9277af61fe725ef70769add9c050bfed4509a22 (diff) |
Introduce initialization logic and hooks
Diffstat (limited to 'sx.el')
-rw-r--r-- | sx.el | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -112,6 +112,33 @@ is equivalent to `(let ,(mapcar (lambda (x) `(,x (cdr (assoc ',x ,alist)))) symbols) ,@body))) +(defcustom sx-init-hook nil + "Hook run when stack-mode initializes. + +Run after `sx-init--internal-hook'.") + +(defvar sx-init--internal-hook nil + "Hook run when stack-mode initializes. + +This is used internally to set initial values for variables such +as filters.") + +(defmacro sx-init-variable (variable value &optional setter) + "Set VARIABLE to VALUE using SETTER. +SETTER should be a function of two arguments. If SETTER is nil, +`set' is used." + (eval + `(add-hook + 'sx-init--internal-hook + (lambda () + (,(or setter #'setq) ,variable ,value)))) + nil) + +(defun stack-initialize () + (run-hooks + 'sx-init--internal-hook + 'sx-init-hook)) + (provide 'sx) ;;; sx.el ends here |