Add narf.window-switch-hook

This commit is contained in:
Henrik Lissner 2015-11-23 21:44:44 -05:00
parent 8598eb87cd
commit 946a2b3c2c

View File

@ -58,6 +58,19 @@ enable multiple minor modes for the same regexp.")
(add-hook! find-file 'narf|enable-minor-mode-maybe) (add-hook! find-file 'narf|enable-minor-mode-maybe)
;; Hook for window switching ;;;;;;;
(defvar narf.window-switch-hook '()
"Hooks run before switching windows. Hooks take two arguments (one is
optional): WINDOW and NORECORD. WINDOW is the window being switched to. Use
`current-buffer' to get the buffer being switched from. See `select-window' for
details on NORECORD.")
(defun narf*run-window-switch-hooks (window &optional norecord)
(run-hook-with-args 'narf.window-switch-hook window norecord))
(advice-add 'select-window :before 'narf*run-window-switch-hooks)
;; Modes 'n hooks ;;;;;;;;;;;;;;;;;;; ;; Modes 'n hooks ;;;;;;;;;;;;;;;;;;;
(associate! sh-mode :match "/\\.?z\\(profile\\|login\\|logout\\|shrc\\|shenv\\)?$") (associate! sh-mode :match "/\\.?z\\(profile\\|login\\|logout\\|shrc\\|shenv\\)?$")