branch: externals/bufferlo commit 62acb6a36e63b65243e719354aa328f006945f95 Author: Florian Rommel <m...@florommel.de> Commit: Flo Rommel <m...@florommel.de>
Restore tab groups and explicit tab names in frame/tab bookmarks - New user option 'bufferlo-bookmark-tab-restore-explicit-name'. - New user option 'bufferlo-bookmark-restore-tab-groups'. - Updated documentation. --- README.org | 16 ++++++++++++++++ bufferlo.el | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 479cf9b024..d98ec7ac9c 100644 --- a/README.org +++ b/README.org @@ -582,6 +582,12 @@ Note: 'raise is considered to act as 'clear by bookmark set loading. ;; store frame names in their bookmarks, and restore them when loading (setq bufferlo-bookmark-frame-persist-frame-name t) ; default nil #+end_src +#+begin_src emacs-lisp + ;; control the restoration of tab groups + (setq bufferlo-bookmark-restore-tab-groups nil) ; do not restore tab groups, the default + (setq bufferlo-bookmark-restore-tab-groups t) ; restore tab groups + (setq bufferlo-bookmark-restore-tab-groups 'frames) ; restore tab groups only for frame bookmarks +#+end_src *** Tab bookmark options @@ -624,6 +630,16 @@ Note: 'raise is considered to act as 'clear by bookmark set loading. (setq bufferlo-bookmark-tab-failed-buffer-policy "*scratch*") ; default to a specific buffer (setq bufferlo-bookmark-tab-failed-buffer-policy #'my/failed-bookmark-handler) ; function to call that returns a buffer #+end_src +#+begin_src emacs-lisp + ;; restore the tab's explicit name (if set) + (setq bufferlo-bookmark-tab-restore-explicit-name t) ; default +#+end_src +#+begin_src emacs-lisp + ;; control the restoration of tab groups + (setq bufferlo-bookmark-restore-tab-groups nil) ; do not restore tab groups, the default + (setq bufferlo-bookmark-restore-tab-groups t) ; restore tab groups + (setq bufferlo-bookmark-restore-tab-groups 'tabs) ; restore tab groups only for tab bookmarks +#+end_src *** Bookmark set options diff --git a/bufferlo.el b/bufferlo.el index 6a5e3aa456..e37ae9b44c 100644 --- a/bufferlo.el +++ b/bufferlo.el @@ -327,12 +327,33 @@ Note: \\='raise is considered \\='clear during `bookmark-set' loading." :package-version '(bufferlo . "1.2") :type 'boolean) +(defcustom bufferlo-bookmark-tab-restore-explicit-name t + "If non-nil, restore the tab's explicit name when loading a tab bookmark." + :package-version '(bufferlo . "1.2") + :type 'boolean) + (defcustom bufferlo-bookmarks-load-tabs-make-frame nil "If non-nil, make a new frame for tabs loaded by `bufferlo-bookmarks-load'. If nil, tab bookmarks are loaded into the current frame." :package-version '(bufferlo . "1.1") :type 'boolean) +(defcustom bufferlo-bookmark-restore-tab-groups nil + "Control the restoration of tab groups in frame and tab bookmarks + +nil never restores tab groups. + +t always restores tab groups. + +\\='tabs only restores tab groups for tab bookmarks. + +\\='frames only restores tab groups for frame bookmarks." + :package-version '(bufferlo . "1.2") + :type '(radio (const :tag "Never" nil) + (const :tag "Always" t) + (const :tag "Only for tab bookmarks" tabs) + (const :tag "Only for frame bookmarks" frames))) + (defcustom bufferlo-bookmark-tab-replace-policy 'replace "Control whether loaded tabs replace current tabs or occupy new tabs. @@ -2802,6 +2823,18 @@ Returns nil on success, non-nil on abort." ;; `window-state-put' accepts this. (bufferlo--ws-replace-buffer-names ws renamed) + ;; Restore tab name + (when (or embedded-tab bufferlo-bookmark-tab-restore-explicit-name) + (when-let* ((tab-name (alist-get 'tab-explicit-name bookmark))) + (tab-bar-rename-tab tab-name))) + + ;; Restore tab group + (when (or (eq bufferlo-bookmark-restore-tab-groups t) + (and embedded-tab (eq bufferlo-bookmark-restore-tab-groups 'frames)) + (and (not embedded-tab) (eq bufferlo-bookmark-restore-tab-groups 'tabs))) + (when-let* ((tab-group (alist-get 'tab-group bookmark))) + (tab-bar-change-tab-group tab-group))) + ;; We do the following to work around two problems with ;; bookmark--jump-via. In older versions, when called ;; interactively and not through bufferlo commands, it calls a @@ -3019,9 +3052,7 @@ Returns nil on success, non-nil on abort." (switch-to-buffer orig-buffer 'no-record 'force-same-window)) (let (tab-bar-tab-prevent-close-functions) - (tab-bar-close-tab))) - (when-let* ((tab-name (alist-get 'tab-name tbm))) - (tab-bar-rename-tab tab-name))) + (tab-bar-close-tab)))) (setq first nil))) (alist-get 'tabs bookmark))) ;; NOTE: We might not find a 'current tab if the tab handler aborts