diff options
| author | pillule | 2021-06-16 02:31:58 +0300 |
|---|---|---|
| committer | Juri Linkov | 2021-06-16 02:31:58 +0300 |
| commit | db106ea88b41e7b293f18a587cbe43685cb769a6 (patch) | |
| tree | a5a425bbf048f5f138770097d3f7d8b4c633f9c1 | |
| parent | 0367d17482804cd4a47d6fcf0201cdded7fc88dc (diff) | |
| download | emacs-db106ea88b41e7b293f18a587cbe43685cb769a6.tar.gz emacs-db106ea88b41e7b293f18a587cbe43685cb769a6.zip | |
User option to choose a function triggered by windmove-create (bug#48917)
* lisp/windmove.el (windmove-create-window): Add a defcustom choice.
(windmove-do-window-select): Trigger custom functions, update the docstring.
| -rw-r--r-- | lisp/windmove.el | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lisp/windmove.el b/lisp/windmove.el index ac146ab2dc7..3c1f20aa260 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el | |||
| @@ -144,9 +144,18 @@ is inactive." | |||
| 144 | "Whether movement off the edge of the frame creates a new window. | 144 | "Whether movement off the edge of the frame creates a new window. |
| 145 | If this variable is set to t, moving left from the leftmost window in | 145 | If this variable is set to t, moving left from the leftmost window in |
| 146 | a frame will create a new window on the left, and similarly for the other | 146 | a frame will create a new window on the left, and similarly for the other |
| 147 | directions." | 147 | directions. |
| 148 | :type 'boolean | 148 | This variable may also be a function to be called in this circumstance |
| 149 | :version "27.1") | 149 | by `windmove-do-window-select'. The function should accept then as |
| 150 | argument the DIRECTION targeted, an interactive ARG and a WINDOW | ||
| 151 | corresponding to the currently selected window. It should also return | ||
| 152 | a valid window that `windmove-do-window-select' will select, | ||
| 153 | or the symbol `no-select' to ignore that final selection." | ||
| 154 | :type '(choice | ||
| 155 | (const :tag "Don't create new windows" nil) | ||
| 156 | (const :tag "Create new windows" t) | ||
| 157 | (function :tag "Provide a function")) | ||
| 158 | :version "28.1") | ||
| 150 | 159 | ||
| 151 | ;; If your Emacs sometimes places an empty column between two adjacent | 160 | ;; If your Emacs sometimes places an empty column between two adjacent |
| 152 | ;; windows, you may wish to set this delta to 2. | 161 | ;; windows, you may wish to set this delta to 2. |
| @@ -356,19 +365,23 @@ use the left or top edge of WINDOW as reference point." | |||
| 356 | "Move to the window at direction DIR as seen from WINDOW. | 365 | "Move to the window at direction DIR as seen from WINDOW. |
| 357 | DIR, ARG, and WINDOW are handled as by `windmove-find-other-window'. | 366 | DIR, ARG, and WINDOW are handled as by `windmove-find-other-window'. |
| 358 | If no window is at direction DIR, an error is signaled. | 367 | If no window is at direction DIR, an error is signaled. |
| 359 | If `windmove-create-window' is non-nil, try to create a new window | 368 | If `windmove-create-window' is a function, call that function with |
| 369 | DIR, ARG and WINDOW. If it is non-nil, try to create a new window | ||
| 360 | in direction DIR instead." | 370 | in direction DIR instead." |
| 361 | (let ((other-window (windmove-find-other-window dir arg window))) | 371 | (let ((other-window (windmove-find-other-window dir arg window))) |
| 362 | (when (and windmove-create-window | 372 | (when (and windmove-create-window |
| 363 | (or (null other-window) | 373 | (or (null other-window) |
| 364 | (and (window-minibuffer-p other-window) | 374 | (and (window-minibuffer-p other-window) |
| 365 | (not (minibuffer-window-active-p other-window))))) | 375 | (not (minibuffer-window-active-p other-window))))) |
| 366 | (setq other-window (split-window window nil dir))) | 376 | (setq other-window (if (functionp windmove-create-window) |
| 377 | (funcall windmove-create-window dir arg window) | ||
| 378 | (split-window window nil dir)))) | ||
| 367 | (cond ((null other-window) | 379 | (cond ((null other-window) |
| 368 | (user-error "No window %s from selected window" dir)) | 380 | (user-error "No window %s from selected window" dir)) |
| 369 | ((and (window-minibuffer-p other-window) | 381 | ((and (window-minibuffer-p other-window) |
| 370 | (not (minibuffer-window-active-p other-window))) | 382 | (not (minibuffer-window-active-p other-window))) |
| 371 | (user-error "Minibuffer is inactive")) | 383 | (user-error "Minibuffer is inactive")) |
| 384 | ((eq other-window 'no-select)) | ||
| 372 | (t | 385 | (t |
| 373 | (select-window other-window))))) | 386 | (select-window other-window))))) |
| 374 | 387 | ||