diff --git a/core/core-editor.el b/core/core-editor.el index 316ed27a2..2e03f0f35 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -58,6 +58,19 @@ enable multiple minor modes for the same regexp.") (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 ;;;;;;;;;;;;;;;;;;; (associate! sh-mode :match "/\\.?z\\(profile\\|login\\|logout\\|shrc\\|shenv\\)?$")