diff options
| author | Martin Rudalics | 2021-06-11 09:55:02 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2021-06-11 09:55:02 +0200 |
| commit | 00140ca6bfceda53eb4f504b859e283d04c2c67f (patch) | |
| tree | 20d97baef6b3e8e67b66c03aa292231004b04145 | |
| parent | 0088cf4f938de6335904fffc54793cde3ddfc13c (diff) | |
| download | emacs-00140ca6bfceda53eb4f504b859e283d04c2c67f.tar.gz emacs-00140ca6bfceda53eb4f504b859e283d04c2c67f.zip | |
Rename/rewrite recently added option and function in window.el
* lisp/window.el (window-at-x-y): Rename from `window-at-pos'.
Fix doc-string.
(delete-window-choose-selected): Rename from
`delete-window-set-selected'. Fix doc-string.
(delete-window): Adjust to above renaming.
* doc/emacs/windows.texi (Change Window): Mention new option
`delete-window-choose-selected'.
* etc/NEWS:
* doc/lispref/windows.texi (Deleting Windows): Follow up on
above renamings.
| -rw-r--r-- | doc/emacs/windows.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 26 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/window.el | 37 |
4 files changed, 42 insertions, 27 deletions
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi index c66deb77487..5e07e83ee53 100644 --- a/doc/emacs/windows.texi +++ b/doc/emacs/windows.texi | |||
| @@ -310,6 +310,8 @@ the space that it occupied is given to an adjacent window (but not the | |||
| 310 | minibuffer window, even if that is active at the time). Deleting the | 310 | minibuffer window, even if that is active at the time). Deleting the |
| 311 | window has no effect on the buffer it used to display; the buffer | 311 | window has no effect on the buffer it used to display; the buffer |
| 312 | continues to exist, and you can still switch to it with @kbd{C-x b}. | 312 | continues to exist, and you can still switch to it with @kbd{C-x b}. |
| 313 | The option @code{delete-window-choose-selected} allows to choose which | ||
| 314 | window becomes the new selected window instead. | ||
| 313 | 315 | ||
| 314 | @findex kill-buffer-and-window | 316 | @findex kill-buffer-and-window |
| 315 | @kindex C-x 4 0 | 317 | @kindex C-x 4 0 |
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index bcb492d68f7..6792d1b2d2f 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -1322,17 +1322,27 @@ When @code{delete-window} deletes the selected window of its frame, it | |||
| 1322 | has to make another window the new selected window of that frame. The | 1322 | has to make another window the new selected window of that frame. The |
| 1323 | following option allows to choose which window gets selected instead. | 1323 | following option allows to choose which window gets selected instead. |
| 1324 | 1324 | ||
| 1325 | @defopt delete-window-set-selected | 1325 | @defopt delete-window-choose-selected |
| 1326 | This option allows to specify which window should become a frame's | 1326 | This option allows to specify which window should become a frame's |
| 1327 | selected window after @code{delete-window} has deleted the previously | 1327 | selected window after @code{delete-window} has deleted the previously |
| 1328 | selected one. | 1328 | selected one. Possible choices are |
| 1329 | |||
| 1330 | @itemize | ||
| 1331 | @item @code{mru} | ||
| 1332 | (the default) to choose the most recently used window on that frame. | ||
| 1333 | |||
| 1334 | @item @code{pos} | ||
| 1335 | to choose the window comprising the frame coordinates of point of the | ||
| 1336 | previously selected window on that frame. | ||
| 1337 | |||
| 1338 | @item @code{nil} | ||
| 1339 | to choose the first window (the window returned by | ||
| 1340 | @code{frame-first-window}) on that frame. | ||
| 1341 | @end itemize | ||
| 1329 | 1342 | ||
| 1330 | Possible choices are @code{mru} (the default) to select the most | 1343 | A window with a non-@code{nil} @code{no-other-window} parameter is |
| 1331 | recently used window on that frame and @code{pos} to choose the window | 1344 | chosen only if all other windows on that frame have that parameter set |
| 1332 | at the position of point of the previously selected window. If this | 1345 | to a non-@code{nil} value too. |
| 1333 | option is @code{nil}, it means to choose the frame's first window | ||
| 1334 | instead. Note that a window with a non-@code{nil} | ||
| 1335 | @code{no-other-window} parameter is never chosen. | ||
| 1336 | @end defopt | 1346 | @end defopt |
| 1337 | 1347 | ||
| 1338 | @deffn Command delete-other-windows &optional window | 1348 | @deffn Command delete-other-windows &optional window |
| @@ -605,14 +605,14 @@ These options include 'windmove-default-keybindings', | |||
| 605 | ** Windows | 605 | ** Windows |
| 606 | 606 | ||
| 607 | +++ | 607 | +++ |
| 608 | *** New option 'delete-window-set-selected'. | 608 | *** New option 'delete-window-choose-selected'. |
| 609 | This allows to choose a frame's selected window after deleting the | 609 | This allows to choose a frame's selected window after deleting the |
| 610 | previously selected one. | 610 | previously selected one. |
| 611 | 611 | ||
| 612 | +++ | 612 | +++ |
| 613 | *** New argument NO-OTHER for some window functions. | 613 | *** New argument NO-OTHER for some window functions. |
| 614 | 'get-lru-window', ‘get-mru-window’ and 'get-largest-window' now accept a | 614 | 'get-lru-window', ‘get-mru-window’ and 'get-largest-window' now accept a |
| 615 | new optional argument NO-OTHER which if non-nil avoids returning a | 615 | new optional argument NO-OTHER which, if non-nil, avoids returning a |
| 616 | window whose 'no-other-window' parameter is non-nil. | 616 | window whose 'no-other-window' parameter is non-nil. |
| 617 | 617 | ||
| 618 | +++ | 618 | +++ |
diff --git a/lisp/window.el b/lisp/window.el index e7551f30c32..ff4a39a2a0a 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -4142,16 +4142,16 @@ frame can be safely deleted." | |||
| 4142 | ;; of its frame. | 4142 | ;; of its frame. |
| 4143 | t)))) | 4143 | t)))) |
| 4144 | 4144 | ||
| 4145 | (defun window-at-pos (x y &optional frame no-other) | 4145 | (defun window-at-x-y (x y &optional frame no-other) |
| 4146 | "Return live window at coordinates X, Y on specified FRAME. | 4146 | "Return live window at coordinates X, Y on specified FRAME. |
| 4147 | X and Y are counted in pixels from an origin at 0, 0 of FRAME's | 4147 | X and Y are FRAME-relative pixel coordinates. A coordinate on an |
| 4148 | native frame. A coordinate on an edge shared by two windows is | 4148 | edge shared by two windows is attributed to the window on the |
| 4149 | attributed to the window on the right (or below). Return nil if | 4149 | right (or below). Return nil if no such window can be found. |
| 4150 | no such window can be found. | ||
| 4151 | 4150 | ||
| 4152 | Optional argument FRAME must specify a live frame and defaults to | 4151 | Optional argument FRAME must specify a live frame and defaults to |
| 4153 | the selected one. Optional argument NO-OTHER non-nil means to | 4152 | the selected one. Optional argument NO-OTHER non-nil means to |
| 4154 | not return a window with a non-nil 'no-other-window' parameter." | 4153 | return nil if the window located at the specified coordinates has |
| 4154 | a non-nil `no-other-window' parameter." | ||
| 4155 | (setq frame (window-normalize-frame frame)) | 4155 | (setq frame (window-normalize-frame frame)) |
| 4156 | (let* ((root-edges (window-edges (frame-root-window frame) nil nil t)) | 4156 | (let* ((root-edges (window-edges (frame-root-window frame) nil nil t)) |
| 4157 | (root-left (nth 2 root-edges)) | 4157 | (root-left (nth 2 root-edges)) |
| @@ -4169,7 +4169,7 @@ not return a window with a non-nil 'no-other-window' parameter." | |||
| 4169 | (throw 'window window))))) | 4169 | (throw 'window window))))) |
| 4170 | frame)))) | 4170 | frame)))) |
| 4171 | 4171 | ||
| 4172 | (defcustom delete-window-set-selected 'mru | 4172 | (defcustom delete-window-choose-selected 'mru |
| 4173 | "How to choose a frame's selected window after window deletion. | 4173 | "How to choose a frame's selected window after window deletion. |
| 4174 | When a frame's selected window gets deleted, Emacs has to choose | 4174 | When a frame's selected window gets deleted, Emacs has to choose |
| 4175 | another live window on that frame to serve as its selected | 4175 | another live window on that frame to serve as its selected |
| @@ -4177,14 +4177,17 @@ window. This option allows to control which window gets selected | |||
| 4177 | instead. | 4177 | instead. |
| 4178 | 4178 | ||
| 4179 | The possible choices are 'mru' (the default) to select the most | 4179 | The possible choices are 'mru' (the default) to select the most |
| 4180 | recently used window on that frame and 'pos' to choose the window | 4180 | recently used window on that frame, and 'pos' to choose the |
| 4181 | at the position of point of the previously selected window. If | 4181 | window at the frame coordinates of point of the previously |
| 4182 | this is nil, choose the frame's first window instead. A window | 4182 | selected window. If this is nil, choose the frame's first window |
| 4183 | with a non-nil 'no-other-window' parameter is never chosen." | 4183 | instead. A window with a non-nil `no-other-window' parameter is |
| 4184 | chosen only if all windows on that frame have that parameter set | ||
| 4185 | to a non-nil value." | ||
| 4184 | :type '(choice (const :tag "Most recently used" mru) | 4186 | :type '(choice (const :tag "Most recently used" mru) |
| 4185 | (const :tag "At position of deleted" pos) | 4187 | (const :tag "At position of deleted" pos) |
| 4186 | (const :tag "Frame's first " nil)) | 4188 | (const :tag "Frame's first " nil)) |
| 4187 | :group 'windows | 4189 | :group 'windows |
| 4190 | :group 'frames | ||
| 4188 | :version "28.1") | 4191 | :version "28.1") |
| 4189 | 4192 | ||
| 4190 | (defun delete-window (&optional window) | 4193 | (defun delete-window (&optional window) |
| @@ -4207,7 +4210,7 @@ that is its frame's root window. | |||
| 4207 | 4210 | ||
| 4208 | If WINDOW is the selected window on its frame, choose some other | 4211 | If WINDOW is the selected window on its frame, choose some other |
| 4209 | window as that frame's selected window according to the value of | 4212 | window as that frame's selected window according to the value of |
| 4210 | the option `delete-window-set-selected'." | 4213 | the option `delete-window-choose-selected'." |
| 4211 | (interactive) | 4214 | (interactive) |
| 4212 | (setq window (window-normalize-window window)) | 4215 | (setq window (window-normalize-window window)) |
| 4213 | (let* ((frame (window-frame window)) | 4216 | (let* ((frame (window-frame window)) |
| @@ -4263,7 +4266,7 @@ the option `delete-window-set-selected'." | |||
| 4263 | ;; Can't do without resizing fixed-size windows. | 4266 | ;; Can't do without resizing fixed-size windows. |
| 4264 | (window--resize-siblings window (- size) horizontal t))) | 4267 | (window--resize-siblings window (- size) horizontal t))) |
| 4265 | 4268 | ||
| 4266 | (when (eq delete-window-set-selected 'pos) | 4269 | (when (eq delete-window-choose-selected 'pos) |
| 4267 | ;; Remember edges and position of point of the selected window | 4270 | ;; Remember edges and position of point of the selected window |
| 4268 | ;; of WINDOW'S frame. | 4271 | ;; of WINDOW'S frame. |
| 4269 | (setq frame-selected-window-edges | 4272 | (setq frame-selected-window-edges |
| @@ -4276,8 +4279,8 @@ the option `delete-window-set-selected'." | |||
| 4276 | (window--pixel-to-total frame horizontal) | 4279 | (window--pixel-to-total frame horizontal) |
| 4277 | 4280 | ||
| 4278 | ;; If we deleted the selected window of WINDOW's frame, choose | 4281 | ;; If we deleted the selected window of WINDOW's frame, choose |
| 4279 | ;; another one based on `delete-window-set-selected'. Note | 4282 | ;; another one based on `delete-window-choose-selected'. Note |
| 4280 | ;; that both `window-at-pos' and `get-mru-window' may fail to | 4283 | ;; that both `window-at-x-y' and `get-mru-window' may fail to |
| 4281 | ;; produce a suitable window in which case we will fall back on | 4284 | ;; produce a suitable window in which case we will fall back on |
| 4282 | ;; its frame's first window, chosen by `delete-window-internal'. | 4285 | ;; its frame's first window, chosen by `delete-window-internal'. |
| 4283 | (cond | 4286 | (cond |
| @@ -4287,7 +4290,7 @@ the option `delete-window-set-selected'." | |||
| 4287 | ;; selected window. Try to find the window that is now | 4290 | ;; selected window. Try to find the window that is now |
| 4288 | ;; at that position. | 4291 | ;; at that position. |
| 4289 | (let ((new-frame-selected-window | 4292 | (let ((new-frame-selected-window |
| 4290 | (window-at-pos | 4293 | (window-at-x-y |
| 4291 | (+ (nth 0 frame-selected-window-edges) | 4294 | (+ (nth 0 frame-selected-window-edges) |
| 4292 | (car frame-selected-window-pos)) | 4295 | (car frame-selected-window-pos)) |
| 4293 | (+ (nth 1 frame-selected-window-edges) | 4296 | (+ (nth 1 frame-selected-window-edges) |
| @@ -4297,7 +4300,7 @@ the option `delete-window-set-selected'." | |||
| 4297 | ;; Select window at WINDOW's position at point. | 4300 | ;; Select window at WINDOW's position at point. |
| 4298 | (set-frame-selected-window | 4301 | (set-frame-selected-window |
| 4299 | frame new-frame-selected-window))))) | 4302 | frame new-frame-selected-window))))) |
| 4300 | ((and (eq delete-window-set-selected 'mru) | 4303 | ((and (eq delete-window-choose-selected 'mru) |
| 4301 | ;; Try to use the most recently used window. | 4304 | ;; Try to use the most recently used window. |
| 4302 | (let ((mru-window (get-mru-window frame nil nil t))) | 4305 | (let ((mru-window (get-mru-window frame nil nil t))) |
| 4303 | (and mru-window | 4306 | (and mru-window |