Fix display-buffer-override-next-command to call action only once (bug#39722)

* lisp/vc/vc-dir.el (vc-dir-bookmark-jump): Don't use save-window-excursion.

* lisp/window.el (display-buffer-override-next-command): Reset
display-buffer-overriding-action after the first buffer display action.

* lisp/tab-bar.el (switch-to-buffer-other-tab): Don't reuse frame tabs.
(other-tab-prefix): Don't reuse frame tabs.
This commit is contained in:
Juri Linkov 2020-06-22 02:36:16 +03:00
parent ba8370bc38
commit ce4ec17930
3 changed files with 14 additions and 8 deletions

View file

@ -1543,8 +1543,7 @@ Like \\[switch-to-buffer-other-frame] (which see), but creates a new tab."
(list (read-buffer-to-switch "Switch to buffer in other tab: ")))
(display-buffer (window-normalize-buffer-to-switch-to buffer-or-name)
'((display-buffer-in-tab)
(inhibit-same-window . nil)
(reusable-frames . t))
(inhibit-same-window . nil))
norecord))
(defun find-file-other-tab (filename &optional wildcards)
@ -1575,8 +1574,7 @@ When `switch-to-buffer-obey-display-actions' is non-nil,
(lambda (buffer alist)
(cons (progn
(display-buffer-in-tab
buffer (append alist '((inhibit-same-window . nil)
(reusable-frames . t))))
buffer (append alist '((inhibit-same-window . nil))))
(selected-window))
'tab)))
(message "Display next command buffer in a new tab..."))

View file

@ -1496,8 +1496,9 @@ This implements the `bookmark-make-record-function' type for
This implements the `handler' function interface for the record
type returned by `vc-dir-bookmark-make-record'."
(let* ((file (bookmark-prop-get bmk 'filename))
(buf (save-window-excursion
(vc-dir file) (current-buffer))))
(buf (progn ;; Don't use save-window-excursion (bug#39722)
(vc-dir file)
(current-buffer))))
(bookmark-default-handler
`("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bmk)))))

View file

@ -8627,15 +8627,20 @@ window; the function takes two arguments: an old and new window."
(let* ((old-window (or (minibuffer-selected-window) (selected-window)))
(new-window nil)
(minibuffer-depth (minibuffer-depth))
(clearfun (make-symbol "clear-display-buffer-overriding-action"))
(action (lambda (buffer alist)
(unless (> (minibuffer-depth) minibuffer-depth)
(let* ((ret (funcall pre-function buffer alist))
(window (car ret))
(type (cdr ret)))
(setq new-window (window--display-buffer buffer window
type alist))))))
type alist))
;; Reset display-buffer-overriding-action
;; after the first buffer display action
(funcall clearfun)
(setq post-function nil)
new-window))))
(command this-command)
(clearfun (make-symbol "clear-display-buffer-overriding-action"))
(exitfun
(lambda ()
(setq display-buffer-overriding-action
@ -8653,6 +8658,8 @@ window; the function takes two arguments: an old and new window."
;; adding the hook by the same command below.
(eq this-command command))
(funcall exitfun))))
;; Reset display-buffer-overriding-action
;; after the next command finishes
(add-hook 'post-command-hook clearfun)
(push action display-buffer-overriding-action)))