]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-bar.el: Filter out non-persistent tab parameters from frameset.
authorJuri Linkov <juri@linkov.net>
Sun, 3 Nov 2019 21:44:44 +0000 (23:44 +0200)
committerJuri Linkov <juri@linkov.net>
Sun, 3 Nov 2019 21:44:44 +0000 (23:44 +0200)
* lisp/tab-bar.el (frameset-filter-tabs): New function
added to 'frameset-filter-alist' for frame parameter 'tabs'.
(tab-bar--tab): Remove ws-bl/ws-bbl that are not needed because
frameset doesn't save frame buffer-list to desktop anyway.
(tab-bar-select-tab): Remove ws-bl/ws-bbl related code.

* lisp/emacs-lisp/seq.el (seq-reduce): Add autoload cookie.

lisp/emacs-lisp/seq.el
lisp/tab-bar.el

index 810b4792b2b30816bd002da6485968ac2e5c157f..2fd735617ba197d3099b2de12b9ba879a1b98e02 100644 (file)
@@ -323,6 +323,7 @@ list."
   (seq-filter (lambda (elt) (not (funcall pred elt)))
               sequence))
 
+;;;###autoload
 (cl-defgeneric seq-reduce (function sequence initial-value)
   "Reduce the function FUNCTION across SEQUENCE, starting with INITIAL-VALUE.
 
index ef58e9060b4f493b1f9dba8ad0a16939ac508ffc..1a0ac26f6879a9fd36ccd4ad64dc7751002ca403 100644 (file)
@@ -436,6 +436,25 @@ Return its existing value or a new value."
                   :help "New tab"))))))
 
 \f
+;; Some window-configuration parameters don't need to be persistent.
+;; Don't save to the desktop file such tab parameters that are saved
+;; as "Unprintable entity" so can't be used after restoring the desktop.
+;; Actually tab-bar-select-tab already can handle unprintable entities,
+;; but it's better not to waste the desktop file with useless data.
+(defun frameset-filter-tabs (current _filtered _parameters saving)
+  (if saving
+      (mapcar (lambda (current)
+                (if (consp current)
+                    (seq-reduce (lambda (current param)
+                                  (assq-delete-all param current))
+                                '(wc wc-point wc-bl wc-bbl wc-history-back wc-history-forward)
+                                (copy-sequence current))
+                  current))
+              current)
+    current))
+
+(push '(tabs . frameset-filter-tabs) frameset-filter-alist)
+
 (defun tab-bar--tab ()
   (let* ((tab (assq 'current-tab (frame-parameter nil 'tabs)))
          (tab-explicit-name (cdr (assq 'explicit-name tab)))
@@ -447,16 +466,14 @@ Return its existing value or a new value."
                  (funcall tab-bar-tab-name-function)))
       (explicit-name . ,tab-explicit-name)
       (time . ,(time-convert nil 'integer))
+      (ws . ,(window-state-get
+              (frame-root-window (selected-frame)) 'writable))
       (wc . ,(current-window-configuration))
       (wc-point . ,(point-marker))
       (wc-bl . ,bl)
       (wc-bbl . ,bbl)
       (wc-history-back . ,(gethash (selected-frame) tab-bar-history-back))
-      (wc-history-forward . ,(gethash (selected-frame) tab-bar-history-forward))
-      (ws . ,(window-state-get
-              (frame-root-window (selected-frame)) 'writable))
-      (ws-bl . ,(mapcar #'buffer-name bl))
-      (ws-bbl . ,(mapcar #'buffer-name bbl)))))
+      (wc-history-forward . ,(gethash (selected-frame) tab-bar-history-forward)))))
 
 (defun tab-bar--current-tab (&optional tab)
   ;; `tab` here is an argument meaning 'use tab as template'. This is
@@ -555,14 +572,7 @@ to the numeric argument.  ARG counts from 1."
                      tab-bar-history-forward)))
 
          (ws
-          (window-state-put ws (frame-root-window (selected-frame)) 'safe)
-
-          (let ((ws-bl (seq-filter #'buffer-live-p
-                                   (mapcar #'get-buffer (cdr (assq 'ws-bl to-tab)))))
-                (ws-bbl (seq-filter #'buffer-live-p
-                                    (mapcar #'get-buffer (cdr (assq 'ws-bbl to-tab))))))
-            (when ws-bl  (set-frame-parameter nil 'buffer-list ws-bl))
-            (when ws-bbl (set-frame-parameter nil 'buried-buffer-list ws-bbl)))))
+          (window-state-put ws (frame-root-window (selected-frame)) 'safe)))
 
         (setq tab-bar-history-omit t)