chiark / gitweb /
el/dot-emacs.el: Inhibit raising frames.
authorMark Wooding <mwooding@good.com>
Thu, 4 Jul 2013 14:40:32 +0000 (15:40 +0100)
committerMark Wooding <mwooding@good.com>
Thu, 4 Jul 2013 14:40:45 +0000 (15:40 +0100)
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

index e4660ed7de5b634fa37c12dfc3828446b1040881..db3be62217dae9da2fcbab7e9d8461aa7e94871a 100644 (file)
@@ -190,6 +190,29 @@ (defun mdw-divvy-window (&optional width)
       (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