Created
August 4, 2019 20:25
-
-
Save wpcarro/a6650d0a43933627add311aa57413ec7 to your computer and use it in GitHub Desktop.
More ergonomic way to add before-save-hook in ELisp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; This macro hopefully provides a more ergonomic way to add mode-specific hooks before buffer save events. | |
| ;; | |
| ;; In ELisp you might see docs that tell you to write the following: | |
| ;; (add-hook 'reason-mode-hook (lambda () (add-hook 'before-save-hook #'refmt-before-save))) | |
| ;; | |
| ;; Instead of writing this, use this macro to write: | |
| ;; (add-hook-before-save 'reason-mode-hook #'refmt-before-save) | |
| (defmacro add-hook-before-save | |
| (mode f) | |
| `(add-hook ,mode | |
| (lambda () | |
| (add-hook 'before-save-hook ,f)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment