]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-bar.el: Avoid micro-steps in tab-bar-history-back/forward.
authorJuri Linkov <juri@linkov.net>
Thu, 18 Nov 2021 17:24:35 +0000 (19:24 +0200)
committerJuri Linkov <juri@linkov.net>
Thu, 18 Nov 2021 17:28:32 +0000 (19:28 +0200)
* lisp/tab-bar.el (tab-bar-history-pre-command)
(tab-bar-history-done-command): New variables.
(tab-bar--history-pre-change): Set 'tab-bar-history-omit' and
'tab-bar-history-pre-command'.
(tab-bar--history-change): Use 'tab-bar-history-done-command' and
'tab-bar-history-pre-command' (bug#51370).

lisp/tab-bar.el

index 871ed1c9817dae54922d34b85033fd9d22a9a3f9..9e554f718f32dd8c14e8f67debb45655dd2f86fc 100644 (file)
@@ -1802,10 +1802,19 @@ Interactively, prompt for GROUP-NAME."
 (defvar tab-bar-history-old nil
   "Window configuration before the current command.")
 
+(defvar tab-bar-history-pre-command nil
+  "Command set to `this-command' by `pre-command-hook'.")
+
+(defvar tab-bar-history-done-command nil
+  "Command handled by `window-configuration-change-hook'.")
+
 (defvar tab-bar-history-old-minibuffer-depth 0
   "Minibuffer depth before the current command.")
 
 (defun tab-bar--history-pre-change ()
+  ;; Reset before the command could set it
+  (setq tab-bar-history-omit nil)
+  (setq tab-bar-history-pre-command this-command)
   (setq tab-bar-history-old-minibuffer-depth (minibuffer-depth))
   ;; Store window-configuration before possibly entering the minibuffer.
   (when (zerop tab-bar-history-old-minibuffer-depth)
@@ -1814,8 +1823,10 @@ Interactively, prompt for GROUP-NAME."
             (wc-point . ,(point-marker))))))
 
 (defun tab-bar--history-change ()
-  (when (and (not tab-bar-history-omit)
-             tab-bar-history-old
+  (when (and (not tab-bar-history-omit) tab-bar-history-old
+             ;; Don't register changes performed by the same command
+             ;; repeated in sequence, such as incremental window resizing.
+             (not (eq tab-bar-history-done-command tab-bar-history-pre-command))
              ;; Store window-configuration before possibly entering
              ;; the minibuffer.
              (zerop tab-bar-history-old-minibuffer-depth))
@@ -1824,8 +1835,8 @@ Interactively, prompt for GROUP-NAME."
                              (gethash (selected-frame) tab-bar-history-back))
                        tab-bar-history-limit)
              tab-bar-history-back))
-  (when tab-bar-history-omit
-    (setq tab-bar-history-omit nil)))
+  (setq tab-bar-history-old nil)
+  (setq tab-bar-history-done-command tab-bar-history-pre-command))
 
 (defun tab-bar-history-back ()
   "Restore a previous window configuration used in the current tab.