* lisp/window.el (display-buffer-override-next-command): Add ECHO arg.

* lisp/frame.el (other-frame-prefix):
* lisp/tab-bar.el (other-tab-prefix):
* lisp/windmove.el (windmove-display-in-direction):
* lisp/window.el (other-window-prefix, same-window-prefix):
Use new ECHO arg of display-buffer-override-next-command.

https://lists.gnu.org/archive/html/emacs-devel/2020-06/msg00819.html
This commit is contained in:
Juri Linkov 2020-07-19 02:43:18 +03:00
parent 77d35f28e5
commit 8d05f21946
4 changed files with 18 additions and 8 deletions

View file

@ -1083,7 +1083,8 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
(cons (display-buffer-pop-up-frame
buffer (append '((inhibit-same-window . t))
alist))
'frame)))
'frame))
nil "[other-frame]")
(message "Display next command buffer in a new frame..."))
(defun iconify-or-deiconify-frame ()

View file

@ -1581,7 +1581,8 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
(display-buffer-in-tab
buffer (append alist '((inhibit-same-window . nil))))
(selected-window))
'tab)))
'tab))
nil "[other-tab]")
(message "Display next command buffer in a new tab..."))
(define-key tab-prefix-map "2" 'tab-new)

View file

@ -491,8 +491,8 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
(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))
(select-window (if no-select old-window new-window))))
(format "[display-%s]" dir))))
;;;###autoload
(defun windmove-display-left (&optional arg)

View file

@ -4021,7 +4021,8 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
(setq type 'window)
(setq window (display-buffer-use-some-window buffer alist)
type 'reuse))
(cons window type))))
(cons window type)))
nil "[other-window]")
(message "Display next command buffer in a new window..."))
(defun same-window-prefix ()
@ -4039,7 +4040,8 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
(cons (or
(display-buffer-same-window buffer alist)
(display-buffer-use-some-window buffer alist))
'reuse)))
'reuse))
nil "[same-window]")
(message "Display next command buffer in the same window..."))
;; This should probably return non-nil when the selected window is part
@ -8616,14 +8618,16 @@ documentation for additional customization information."
(list (read-buffer-to-switch "Switch to buffer in other frame: ")))
(pop-to-buffer buffer-or-name display-buffer--other-frame-action norecord))
(defun display-buffer-override-next-command (pre-function &optional post-function)
(defun display-buffer-override-next-command (pre-function &optional post-function echo)
"Set `display-buffer-overriding-action' for the next command.
`pre-function' is called to prepare the window where the buffer should be
displayed. This function takes two arguments `buffer' and `alist', and
should return a cons with the displayed window and its type. See the
meaning of these values in `window--display-buffer'.
Optional `post-function' is called after the buffer is displayed in the
window; the function takes two arguments: an old and new window."
window; the function takes two arguments: an old and new window.
Optional string argument `echo' can be used to add a prefix to the
command echo keystrokes that should describe the current prefix state."
(let* ((old-window (or (minibuffer-selected-window) (selected-window)))
(new-window nil)
(minibuffer-depth (minibuffer-depth))
@ -8641,11 +8645,13 @@ window; the function takes two arguments: an old and new window."
(setq post-function nil)
new-window))))
(command this-command)
(echofun (when echo (lambda () echo)))
(exitfun
(lambda ()
(setcar display-buffer-overriding-action
(delq action (car display-buffer-overriding-action)))
(remove-hook 'post-command-hook clearfun)
(remove-hook 'prefix-command-echo-keystrokes-functions echofun)
(when (functionp post-function)
(funcall post-function old-window new-window)))))
(fset clearfun
@ -8661,6 +8667,8 @@ window; the function takes two arguments: an old and new window."
;; Reset display-buffer-overriding-action
;; after the next command finishes
(add-hook 'post-command-hook clearfun)
(when echofun
(add-hook 'prefix-command-echo-keystrokes-functions echofun))
(push action (car display-buffer-overriding-action))))