]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-bar.el: Optimize data usage for nil tab-bar-history-mode.
authorJuri Linkov <juri@linkov.net>
Thu, 18 Nov 2021 17:27:46 +0000 (19:27 +0200)
committerJuri Linkov <juri@linkov.net>
Thu, 18 Nov 2021 17:28:32 +0000 (19:28 +0200)
* lisp/tab-bar.el (tab-bar--tab): Add wc-history-back and
wc-history-forward only when tab-bar-history-mode is non-nil.
(tab-bar-select-tab): Use wc-history-back and
wc-history-forward only when tab-bar-history-mode is non-nil.
(tab-bar-new-tab-to): Reset tab-bar-history-back and
tab-bar-history-forward to nil.

lisp/tab-bar.el

index 9e554f718f32dd8c14e8f67debb45655dd2f86fc..c2bf3021b087af66f02f5fbd840e6d2e153eee23 100644 (file)
@@ -980,10 +980,11 @@ on the tab bar instead."
       (wc-point . ,(point-marker))
       (wc-bl . ,bl)
       (wc-bbl . ,bbl)
-      (wc-history-back . ,(gethash (or frame (selected-frame))
-                                   tab-bar-history-back))
-      (wc-history-forward . ,(gethash (or frame (selected-frame))
-                                      tab-bar-history-forward))
+      ,@(when tab-bar-history-mode
+          `((wc-history-back . ,(gethash (or frame (selected-frame))
+                                         tab-bar-history-back))
+            (wc-history-forward . ,(gethash (or frame (selected-frame))
+                                            tab-bar-history-forward))))
       ;; Copy other possible parameters
       ,@(mapcan (lambda (param)
                   (unless (memq (car param)
@@ -1124,19 +1125,21 @@ Negative TAB-NUMBER counts tabs from the end of the tab bar."
             (when wc-bl  (set-frame-parameter nil 'buffer-list wc-bl))
             (when wc-bbl (set-frame-parameter nil 'buried-buffer-list wc-bbl))
 
-            (puthash (selected-frame)
-                     (and (window-configuration-p (alist-get 'wc (car wc-history-back)))
-                          wc-history-back)
-                     tab-bar-history-back)
-            (puthash (selected-frame)
-                     (and (window-configuration-p (alist-get 'wc (car wc-history-forward)))
-                          wc-history-forward)
-                     tab-bar-history-forward)))
+            (when tab-bar-history-mode
+              (puthash (selected-frame)
+                       (and (window-configuration-p (alist-get 'wc (car wc-history-back)))
+                            wc-history-back)
+                       tab-bar-history-back)
+              (puthash (selected-frame)
+                       (and (window-configuration-p (alist-get 'wc (car wc-history-forward)))
+                            wc-history-forward)
+                       tab-bar-history-forward))))
 
          (ws
           (window-state-put ws nil 'safe)))
 
-        (setq tab-bar-history-omit t)
+        (when tab-bar-history-mode
+          (setq tab-bar-history-omit t))
 
         (when from-index
           (setf (nth from-index tabs) from-tab))
@@ -1386,6 +1389,11 @@ After the tab is created, the hooks in
         ;; `pushnew' handles the head of tabs but not frame-parameter
         (tab-bar-tabs-set tabs))
 
+      (when tab-bar-history-mode
+        (puthash (selected-frame) nil tab-bar-history-back)
+        (puthash (selected-frame) nil tab-bar-history-forward)
+        (setq tab-bar-history-omit t))
+
       (run-hook-with-args 'tab-bar-tab-post-open-functions
                           (nth to-index tabs)))