diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-09 13:38:37 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-04-09 13:39:58 -0700 |
commit | 8de5b50b25d637acd4ecf6a7fd92fa90236d14bc (patch) | |
tree | b320da5a76e39dae33506ed03380c5ab7931fd25 | |
parent | a235b35a0c71dae2edfbc129b0fff5d8b4852e0b (diff) | |
download | dotfiles-8de5b50b25d637acd4ecf6a7fd92fa90236d14bc.tar.gz |
add spw/add-once-advice
-rw-r--r-- | .emacs.d/init-spw.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/.emacs.d/init-spw.el b/.emacs.d/init-spw.el index d8357826..8ccb025a 100644 --- a/.emacs.d/init-spw.el +++ b/.emacs.d/init-spw.el @@ -153,6 +153,16 @@ which should happen just once." (apply ,function args))) (add-hook ,hook ',sym ,depth ,local)))) +(defmacro spw/add-once-advice (where place function &optional props) + "Add a piece of advice which removes itself when called. For +something which should happen just once." + (let ((sym (cl-gensym))) + `(progn + (fset ',sym (lambda (&rest args) + (advice-remove ,place #',sym) + (apply ,function args))) + (advice-add ,place ,where #',sym ,props)))) + ;;;; Startup & basic preferences |