From ce4ec1793041ae0f013234ef7189ed855b5227a3 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 22 Jun 2020 02:36:16 +0300 Subject: [PATCH] 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. --- lisp/tab-bar.el | 6 ++---- lisp/vc/vc-dir.el | 5 +++-- lisp/window.el | 11 +++++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index b54258a4e4a..0a336e41658 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -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...")) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index a86c37c24ae..cdf8ab984e8 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -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))))) diff --git a/lisp/window.el b/lisp/window.el index f6f30ad6f49..a84ca05daac 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -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))) -- 2.39.5