[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109744: Let walk-window-tree and win
From: |
martin rudalics |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109744: Let walk-window-tree and window-with-parameter operate on minibuffer windows too. |
Date: |
Wed, 22 Aug 2012 10:30:54 +0200 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109744
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Wed 2012-08-22 10:30:54 +0200
message:
Let walk-window-tree and window-with-parameter operate on minibuffer windows
too.
* window.el (walk-window-tree, window-with-parameter): New
optional argument MINIBUF to control whether these functions
should run on the minibuffer window.
(window-at-side-list): Don't operate on minibuffer window.
(window-in-direction): Simplify and rewrite doc-string.
modified:
lisp/ChangeLog
lisp/window.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-08-22 07:02:15 +0000
+++ b/lisp/ChangeLog 2012-08-22 08:30:54 +0000
@@ -1,3 +1,11 @@
+2012-08-22 Martin Rudalics <address@hidden>
+
+ * window.el (walk-window-tree, window-with-parameter): New
+ optional argument MINIBUF to control whether these functions
+ should run on the minibuffer window.
+ (window-at-side-list): Don't operate on minibuffer window.
+ (window-in-direction): Simplify and rewrite doc-string.
+
2012-08-22 Christopher Schmidt <address@hidden>
* help-fns.el (help-fns--key-bindings):
=== modified file 'lisp/window.el'
--- a/lisp/window.el 2012-08-21 09:27:07 +0000
+++ b/lisp/window.el 2012-08-22 08:30:54 +0000
@@ -271,19 +271,32 @@
(setq walk-window-tree-window
(window-right walk-window-tree-window))))))
-(defun walk-window-tree (fun &optional frame any)
+(defun walk-window-tree (fun &optional frame any minibuf)
"Run function FUN on each live window of FRAME.
FUN must be a function with one argument - a window. FRAME must
be a live frame and defaults to the selected one. ANY, if
-non-nil means to run FUN on all live and internal windows of
+non-nil, means to run FUN on all live and internal windows of
FRAME.
+Optional argument MINIBUF t means run FUN on FRAME's minibuffer
+window even if it isn't active. MINIBUF nil or omitted means run
+FUN on FRAME's minibuffer window only if it's active. In both
+cases the minibuffer window must be part of FRAME. MINIBUF
+neither nil nor t means never run FUN on the minibuffer window.
+
This function performs a pre-order, depth-first traversal of the
window tree. If FUN changes the window tree, the result is
unpredictable."
- (let ((walk-window-tree-frame (window-normalize-frame frame)))
- (walk-window-tree-1
- fun (frame-root-window walk-window-tree-frame) any)))
+ (setq frame (window-normalize-frame frame))
+ (walk-window-tree-1 fun (frame-root-window frame) any)
+ (when (memq minibuf '(nil t))
+ ;; Run FUN on FRAME's minibuffer window if requested.
+ (let ((minibuffer-window (minibuffer-window frame)))
+ (when (and (window-live-p minibuffer-window)
+ (eq (window-frame minibuffer-window) frame)
+ (or (eq minibuf t)
+ (minibuffer-window-active-p minibuffer-window)))
+ (funcall fun minibuffer-window)))))
(defun walk-window-subtree (fun &optional window any)
"Run function FUN on the subtree of windows rooted at WINDOW.
@@ -299,13 +312,19 @@
(setq window (window-normalize-window window))
(walk-window-tree-1 fun window any t))
-(defun window-with-parameter (parameter &optional value frame any)
+(defun window-with-parameter (parameter &optional value frame any minibuf)
"Return first window on FRAME with PARAMETER non-nil.
FRAME defaults to the selected frame. Optional argument VALUE
non-nil means only return a window whose window-parameter value
for PARAMETER equals VALUE (comparison is done with `equal').
Optional argument ANY non-nil means consider internal windows
-too."
+too.
+
+Optional argument MINIBUF t means consider FRAME's minibuffer
+window even if it isn't active. MINIBUF nil or omitted means
+consider FRAME's minibuffer window only if it's active. In both
+cases the minibuffer window must be part of FRAME. MINIBUF
+neither nil nor t means never consider the minibuffer window."
(let (this-value)
(catch 'found
(walk-window-tree
@@ -313,7 +332,7 @@
(when (and (setq this-value (window-parameter window parameter))
(or (not value) (equal value this-value)))
(throw 'found window)))
- frame any))))
+ frame any minibuf))))
;;; Atomic windows.
(defun window-atom-root (&optional window)
@@ -1088,7 +1107,7 @@
(lambda (window)
(when (window-at-side-p window side)
(setq windows (cons window windows))))
- frame)
+ frame nil 'nomini)
(nreverse windows)))
(defun window--in-direction-2 (window posn &optional horizontal)
@@ -1103,12 +1122,25 @@
(- left posn)
(- posn left (window-total-width window))))))
+;; Predecessors to the below have been devised by Julian Assange in
+;; change-windows-intuitively.el and Hovav Shacham in windmove.el.
+;; Neither of these allow to selectively ignore specific windows
+;; (windows whose `no-other-window' parameter is non-nil) as targets of
+;; the movement.
(defun window-in-direction (direction &optional window ignore)
"Return window in DIRECTION as seen from WINDOW.
+More precisely, return the nearest window in direction DIRECTION
+as seen from the position of `window-point' in window WINDOW.
DIRECTION must be one of `above', `below', `left' or `right'.
WINDOW must be a live window and defaults to the selected one.
-IGNORE non-nil means a window can be returned even if its
-`no-other-window' parameter is non-nil."
+
+Do not return a window whose `no-other-window' parameter is
+non-nil. If the nearest window's `no-other-window' parameter is
+non-nil, try to find another window in the indicated direction.
+If, however, the optional argument IGNORE is non-nil, return that
+window even if its `no-other-window' parameter is non-nil.
+
+Return nil if no suitable window can be found."
(setq window (window-normalize-window window t))
(unless (memq direction '(above below left right))
(error "Wrong direction %s" direction))
@@ -1195,7 +1227,7 @@
(setq best-edge-2 w-top)
(setq best-diff-2 best-diff-2-new)
(setq best-2 w)))))))
- (window-frame window))
+ frame)
(or best best-2)))
(defun get-window-with-predicate (predicate &optional minibuf all-frames
default)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109744: Let walk-window-tree and window-with-parameter operate on minibuffer windows too.,
martin rudalics <=