emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c472df8: * lisp/tab-bar.el: Filter out non-persistent tab paramet


From: Juri Linkov
Subject: master c472df8: * lisp/tab-bar.el: Filter out non-persistent tab parameters from frameset.
Date: Sun, 3 Nov 2019 16:44:52 -0500 (EST)

branch: master
commit c472df8ad30741a9585fb591db3189812b66e8c9
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    * lisp/tab-bar.el: Filter out non-persistent tab parameters from frameset.
    
    * 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 |  1 +
 lisp/tab-bar.el        | 36 +++++++++++++++++++++++-------------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 810b479..2fd7356 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -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.
 
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index ef58e90..1a0ac26 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -436,6 +436,25 @@ Return its existing value or a new value."
                   :help "New tab"))))))
 
 
+;; 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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]