diff options
| -rw-r--r-- | lisp/window.el | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/lisp/window.el b/lisp/window.el index 6f7e730bad4..81d35cef894 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -71,13 +71,50 @@ Anything else means restrict to the selected frame." | |||
| 71 | (save-selected-window | 71 | (save-selected-window |
| 72 | (if (framep all-frames) | 72 | (if (framep all-frames) |
| 73 | (select-window (frame-first-window all-frames))) | 73 | (select-window (frame-first-window all-frames))) |
| 74 | (let* ((walk-windows-start (selected-window)) | 74 | (let* (walk-windows-already-seen |
| 75 | (walk-windows-current walk-windows-start)) | 75 | (walk-windows-current (selected-window))) |
| 76 | (while (progn | 76 | (while (progn |
| 77 | (setq walk-windows-current | 77 | (setq walk-windows-current |
| 78 | (next-window walk-windows-current minibuf all-frames)) | 78 | (next-window walk-windows-current minibuf all-frames)) |
| 79 | (funcall proc walk-windows-current) | 79 | (not (memq walk-windows-current walk-windows-already-seen))) |
| 80 | (not (eq walk-windows-current walk-windows-start))))))) | 80 | (setq walk-windows-already-seen |
| 81 | (cons walk-windows-current walk-windows-already-seen)) | ||
| 82 | (funcall proc walk-windows-current))))) | ||
| 83 | |||
| 84 | (defun some-window (predicate &optional minibuf all-frames default) | ||
| 85 | "Return a window satisfying PREDICATE. | ||
| 86 | |||
| 87 | This function cycles through all visible windows using `walk-windows', | ||
| 88 | calling PREDICATE on each one. PREDICATE is called with a window as | ||
| 89 | argument. The first window for which PREDICATE returns a non-nil | ||
| 90 | value is returned. If no window satisfies PREDICATE, DEFAULT is | ||
| 91 | returned. | ||
| 92 | |||
| 93 | Optional second arg MINIBUF t means count the minibuffer window even | ||
| 94 | if not active. MINIBUF nil or omitted means count the minibuffer iff | ||
| 95 | it is active. MINIBUF neither t nor nil means not to count the | ||
| 96 | minibuffer even if it is active. | ||
| 97 | |||
| 98 | Several frames may share a single minibuffer; if the minibuffer | ||
| 99 | counts, all windows on all frames that share that minibuffer count | ||
| 100 | too. Therefore, if you are using a separate minibuffer frame | ||
| 101 | and the minibuffer is active and MINIBUF says it counts, | ||
| 102 | `walk-windows' includes the windows in the frame from which you | ||
| 103 | entered the minibuffer, as well as the minibuffer window. | ||
| 104 | |||
| 105 | ALL-FRAMES is the optional third argument. | ||
| 106 | ALL-FRAMES nil or omitted means cycle within the frames as specified above. | ||
| 107 | ALL-FRAMES = `visible' means include windows on all visible frames. | ||
| 108 | ALL-FRAMES = 0 means include windows on all visible and iconified frames. | ||
| 109 | ALL-FRAMES = t means include windows on all frames including invisible frames. | ||
| 110 | If ALL-FRAMES is a frame, it means include windows on that frame. | ||
| 111 | Anything else means restrict to the selected frame." | ||
| 112 | (catch 'found | ||
| 113 | (walk-windows #'(lambda (window) | ||
| 114 | (when (funcall predicate window) | ||
| 115 | (throw 'found window))) | ||
| 116 | minibuf all-frames) | ||
| 117 | default)) | ||
| 81 | 118 | ||
| 82 | (defun minibuffer-window-active-p (window) | 119 | (defun minibuffer-window-active-p (window) |
| 83 | "Return t if WINDOW (a minibuffer window) is now active." | 120 | "Return t if WINDOW (a minibuffer window) is now active." |