chiark / gitweb /
el/dot-emacs.el: Window placement hacking.
authorMark Wooding <mwooding@good.com>
Thu, 29 Jan 2015 14:06:04 +0000 (14:06 +0000)
committerMark Wooding <mwooding@good.com>
Thu, 29 Jan 2015 14:06:16 +0000 (14:06 +0000)
  * `mdw-clobber-other-windows-showing-buffer': Proper command for
    making sure no other frames are showing a particular buffer.

  * Some advice for buffer displaying functions so that they don't do
    ridiculous things like trying to show me buffers in frames on other
    displays which I can't see.

el/dot-emacs.el

index eb301414c3362eeb6cae763f4545491e53ec0bd8..c042a8cb1f4d433d2a4594e44228007986c88bc3 100644 (file)
@@ -321,6 +321,43 @@ (setq org-export-docbook-xslt-proc-command "xsltproc --output %o %s %i"
       org-export-docbook-xslt-stylesheet
       "/usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl")
 
+;; Some hacks to do with window placement.
+
+(defun mdw-clobber-other-windows-showing-buffer (buffer-or-name)
+  "Arrange that no windows on other frames are showing BUFFER-OR-NAME."
+  (interactive "bBuffer: ")
+  (let ((home-frame (selected-frame))
+       (buffer (get-buffer buffer-or-name))
+       (safe-buffer (get-buffer "*scratch*")))
+    (mapc (lambda (frame)
+           (or (eq frame home-frame)
+               (mapc (lambda (window)
+                       (and (eq (window-buffer window) buffer)
+                            (set-window-buffer window safe-buffer)))
+                     (window-list frame))))
+         (frame-list))))
+
+(defvar mdw-inhibit-walk-windows nil
+  "If non-nil, then `walk-windows' does nothing.
+This is used by advice on `switch-to-buffer-other-frame' to inhibit finding
+buffers in random frames.")
+
+(defadvice walk-windows (around mdw-inhibit activate)
+  "If `mdw-inhibit-walk-windows' is non-nil, then do nothing."
+  (and (not mdw-inhibit-walk-windows)
+       ad-do-it))
+
+(defadvice switch-to-buffer-other-frame
+    (around mdw-always-new-frame activate)
+  "Always make a new frame.
+Even if an existing window in some random frame looks tempting."
+  (let ((mdw-inhibit-walk-windows t)) ad-do-it))
+
+(defadvice display-buffer (before mdw-inhibit-other-frames activate)
+  "Don't try to do anything fancy with other frames.
+Pretend they don't exist.  They might be on other display devices."
+  (ad-set-arg 2 nil))
+
 ;;;--------------------------------------------------------------------------
 ;;; Mail and news hacking.