From 946a2b3c2cdd7353c6340925734e1801712d0778 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 23 Nov 2015 21:44:44 -0500 Subject: [PATCH] Add narf.window-switch-hook --- core/core-editor.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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\\)?$")