[emacs] focus follows mouse, except in gnus-summary-mode buffers
authorAmin Bandali <bandali@gnu.org>
Wed, 12 Dec 2018 20:26:26 +0000 (15:26 -0500)
committerAmin Bandali <bandali@gnu.org>
Wed, 12 Dec 2018 20:26:26 +0000 (15:26 -0500)
init.org

index 7c12ad5..9c64204 100644 (file)
--- a/init.org
+++ b/init.org
@@ -419,6 +419,24 @@ Font stack with better unicode support, around =Ubuntu Mono= and
 (setq text-scale-mode-step 1.05)
 #+end_src
 
 (setq text-scale-mode-step 1.05)
 #+end_src
 
+** Focus follows mouse
+
+I’d like focus to follow the mouse when I move the cursor from one
+window to the next.
+
+#+begin_src emacs-lisp
+(setq mouse-autoselect-window t)
+#+end_src
+
+Let’s define a function to conveniently disable this for certain
+buffers and/or modes.
+
+#+begin_src emacs-lisp
+(defun amin--no-mouse-autoselect-window ()
+  (make-local-variable 'mouse-autoselect-window)
+  (setq mouse-autoselect-window nil))
+#+end_src
+
 ** Libraries
 
 #+begin_src emacs-lisp
 ** Libraries
 
 #+begin_src emacs-lisp
@@ -2243,7 +2261,8 @@ For when I /have to/ use GH.
    :map gnus-summary-mode-map
    ("r"   . gnus-summary-reply-with-original)
    ("R"   . gnus-summary-wide-reply-with-original)
    :map gnus-summary-mode-map
    ("r"   . gnus-summary-reply-with-original)
    ("R"   . gnus-summary-wide-reply-with-original)
-   ("M-L" . org-store-link)))
+   ("M-L" . org-store-link))
+  :hook (gnus-summary-mode . amin--no-mouse-autoselect-window))
 
 (use-package gnus-msg
   :config
 
 (use-package gnus-msg
   :config