From cc2be23ea3c3b4edd1512d519f29491b8dced026 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 4 Jul 2013 15:40:32 +0100 Subject: [PATCH] el/dot-emacs.el: Inhibit raising frames. Emacs has an annoying tendency to raise frames just because it wants to focus them. The two /do not go together/. --- el/dot-emacs.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index e4660ed..db3be62 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -190,6 +190,29 @@ fringes is not taken out of the allowance for WIDTH, unlike (other-window 1)) (select-window win))) +;; Don't raise windows unless I say so. + +(defvar mdw-inhibit-raise-frame nil + "*Whether `raise-frame' should do nothing when the frame is mapped.") + +(defadvice raise-frame + (around mdw-inhibit (&optional frame) activate compile) + "Don't actually do anything if `mdw-inhibit-raise-frame' is true, and the +frame is actually mapped on the screen." + (if mdw-inhibit-raise-frame + (make-frame-visible frame) + ad-do-it)) + +(defmacro mdw-advise-to-inhibit-raise-frame (function) + "Advise the FUNCTION not to raise frames, even if it wants to." + `(defadvice ,function + (around mdw-inhibit-raise (&rest hunoz) activate compile) + "Don't raise the window unless you have to." + (let ((mdw-inhibit-raise-frame t)) + ad-do-it))) + +(mdw-advise-to-inhibit-raise-frame select-frame-set-input-focus) + ;; Transient mark mode hacks. (defadvice exchange-point-and-mark -- 2.11.0