diff options
author | Juri Linkov <juri@linkov.net> | 2020-06-07 02:42:24 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2020-06-07 02:42:24 +0300 |
commit | 788cd6d8b98c0e7750e478ae84e580f29576b5ff (patch) | |
tree | 46c566e2e9e89003d4ba2555c3c8e6c56151cdcf /lisp/windmove.el | |
parent | 7ac79872aed63110c0d26c1e62e1838d6101c9bd (diff) | |
download | emacs-788cd6d8b98c0e7750e478ae84e580f29576b5ff.tar.gz |
The key prefix 'C-x t t' displays next command buffer in a new tab (bug#41691)
* lisp/tab-bar.el (other-tab-prefix): New command.
(tab-prefix-map): Bind key 'C-x t t' to other-tab-prefix.
* lisp/windmove.el (windmove-display-in-direction):
Use display-buffer-override-next-command.
* lisp/window.el (display-buffer-override-next-command):
New function refactored from windmove-display-in-direction.
Diffstat (limited to 'lisp/windmove.el')
-rw-r--r-- | lisp/windmove.el | 86 |
1 files changed, 32 insertions, 54 deletions
diff --git a/lisp/windmove.el b/lisp/windmove.el index f96383197bd..341c739d924 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -461,60 +461,38 @@ select the window with a displayed buffer, and the meaning of the prefix argument is reversed. When `switch-to-buffer-obey-display-actions' is non-nil, `switch-to-buffer' commands are also supported." - (let* ((no-select (xor (consp arg) windmove-display-no-select)) - (old-window (or (minibuffer-selected-window) (selected-window))) - (new-window) - (minibuffer-depth (minibuffer-depth)) - (action (lambda (buffer alist) - (unless (> (minibuffer-depth) minibuffer-depth) - (let* ((type 'reuse) - (window (cond - ((eq dir 'new-tab) - (let ((tab-bar-new-tab-choice t)) - (tab-bar-new-tab)) - (setq type 'tab) - (selected-window)) - ((eq dir 'new-frame) - (let* ((params (cdr (assq 'pop-up-frame-parameters alist))) - (pop-up-frame-alist (append params pop-up-frame-alist)) - (frame (make-frame-on-current-monitor - pop-up-frame-alist))) - (unless (cdr (assq 'inhibit-switch-frame alist)) - (window--maybe-raise-frame frame)) - (setq type 'frame) - (frame-selected-window frame))) - ((eq dir 'same-window) - (selected-window)) - (t (window-in-direction - dir nil nil - (and arg (prefix-numeric-value arg)) - windmove-wrap-around))))) - (unless window - (setq window (split-window nil nil dir) type 'window)) - (setq new-window (window--display-buffer buffer window - type alist)))))) - (command this-command) - (clearfun (make-symbol "clear-display-buffer-overriding-action")) - (exitfun - (lambda () - (setq display-buffer-overriding-action - (delq action display-buffer-overriding-action)) - (when (window-live-p (if no-select old-window new-window)) - (select-window (if no-select old-window new-window))) - (remove-hook 'post-command-hook clearfun)))) - (fset clearfun - (lambda () - (unless (or - ;; Remove the hook immediately - ;; after exiting the minibuffer. - (> (minibuffer-depth) minibuffer-depth) - ;; But don't remove immediately after - ;; adding the hook by the same command below. - (eq this-command command)) - (funcall exitfun)))) - (add-hook 'post-command-hook clearfun) - (push action display-buffer-overriding-action) - (message "[display-%s]" dir))) + (let ((no-select (xor (consp arg) windmove-display-no-select))) + (display-buffer-override-next-command + (lambda (_buffer alist) + (let* ((type 'reuse) + (window (cond + ((eq dir 'new-tab) + (let ((tab-bar-new-tab-choice t)) + (tab-bar-new-tab)) + (setq type 'tab) + (selected-window)) + ((eq dir 'new-frame) + (let* ((params (cdr (assq 'pop-up-frame-parameters alist))) + (pop-up-frame-alist (append params pop-up-frame-alist)) + (frame (make-frame-on-current-monitor + pop-up-frame-alist))) + (unless (cdr (assq 'inhibit-switch-frame alist)) + (window--maybe-raise-frame frame)) + (setq type 'frame) + (frame-selected-window frame))) + ((eq dir 'same-window) + (selected-window)) + (t (window-in-direction + dir nil nil + (and arg (prefix-numeric-value arg)) + windmove-wrap-around))))) + (unless window + (setq window (split-window nil nil dir) type 'window)) + (cons window type))) + (lambda (old-window new-window) + (when (window-live-p (if no-select old-window new-window)) + (select-window (if no-select old-window new-window)))))) + (message "[display-%s]" dir)) ;;;###autoload (defun windmove-display-left (&optional arg) |