unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* tab-bar-switch-to-tab removes custom tab data?
@ 2021-09-19 22:40 Adam Porter
  2021-09-20  6:45 ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Porter @ 2021-09-19 22:40 UTC (permalink / raw)
  To: emacs-devel

Hi Juri, et al,

I'm not sure if this is intended, or if what I'm doing is allowed, but I
noticed that after I add an association to the current tab and then use
tab-switch twice, to change tab and then change back, the association I
added is gone.

Here's the function I'm using to add the association:

  (defun burly-tab--windows-set-after-advice (&rest _ignore)
    "Set current tab's `burly-bookmark-name' to BOOKMARK-NAME.
  To be used as advice to `burly--windows-set'."
    (tab-rename burly-opened-bookmark-name)
    (let ((current-tab (tab-bar--current-tab-find)))
      (setf (alist-get 'burly-bookmark-name (cdr current-tab))
            burly-opened-bookmark-name)))

After that function is run, this:

  (tab-bar--current-tab-find)

Evaluates to:

  (current-tab
   (burly-bookmark-name .
    #("Burly: Burly.el" 0 15
      (face nil)))
   (name .
    #("Burly: Burly.el" 0 15
      (face nil)))
   (explicit-name . t))

Then after switching tabs and back, it evaluates to:

  (current-tab
   (name .
    #("Burly: Burly.el" 0 15
      (face nil)))
   (explicit-name . t))

I assumed that, since the tab is an alist, I could add my own data to
it, but maybe this is not intended.  If not, could it become so?  :)  I
could work around it by using the tab's name, but that would be less
flexible and robust.  I'd also like to store other data to tabs in the
future, and that wouldn't work as well with relying on the tab name.

--
Thanks,
Adam




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tab-bar-switch-to-tab removes custom tab data?
  2021-09-19 22:40 tab-bar-switch-to-tab removes custom tab data? Adam Porter
@ 2021-09-20  6:45 ` Juri Linkov
  2021-09-20 15:28   ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2021-09-20  6:45 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-devel

> I'm not sure if this is intended, or if what I'm doing is allowed, but I
> noticed that after I add an association to the current tab and then use
> tab-switch twice, to change tab and then change back, the association I
> added is gone.

So you want to add more metadata to a tab?
Once in the past I proposed such a feature,
but no one needed it :)  Now this could be added.

> Here's the function I'm using to add the association:
>
>   (defun burly-tab--windows-set-after-advice (&rest _ignore)
>     "Set current tab's `burly-bookmark-name' to BOOKMARK-NAME.
>   To be used as advice to `burly--windows-set'."
>     (tab-rename burly-opened-bookmark-name)
>     (let ((current-tab (tab-bar--current-tab-find)))
>       (setf (alist-get 'burly-bookmark-name (cdr current-tab))
>             burly-opened-bookmark-name)))
>
> After that function is run, this:
>
>   (tab-bar--current-tab-find)
>
> Evaluates to:
>
>   (current-tab
>    (burly-bookmark-name .
>     #("Burly: Burly.el" 0 15
>       (face nil)))
>    (name .
>     #("Burly: Burly.el" 0 15
>       (face nil)))
>    (explicit-name . t))
>
> Then after switching tabs and back, it evaluates to:
>
>   (current-tab
>    (name .
>     #("Burly: Burly.el" 0 15
>       (face nil)))
>    (explicit-name . t))
>
> I assumed that, since the tab is an alist, I could add my own data to
> it, but maybe this is not intended.  If not, could it become so?  :)  I
> could work around it by using the tab's name, but that would be less
> flexible and robust.  I'd also like to store other data to tabs in the
> future, and that wouldn't work as well with relying on the tab name.

I completely agree, this should be supported asap.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tab-bar-switch-to-tab removes custom tab data?
  2021-09-20  6:45 ` Juri Linkov
@ 2021-09-20 15:28   ` Juri Linkov
  2021-09-20 23:20     ` Adam Porter
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2021-09-20 15:28 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 489 bytes --]

>> I'm not sure if this is intended, or if what I'm doing is allowed, but I
>> noticed that after I add an association to the current tab and then use
>> tab-switch twice, to change tab and then change back, the association I
>> added is gone.
>
> So you want to add more metadata to a tab?
> Once in the past I proposed such a feature,
> but no one needed it :)  Now this could be added.

Here is a patch that implements this, but it's still 100% untested,
so use it at your own risk :)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: custom-tab-data.patch --]
[-- Type: text/x-diff, Size: 1804 bytes --]

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index c19b754543..7f9b56c7d2 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -931,7 +931,15 @@ tab-bar--tab
       (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)))))
+      (wc-history-forward . ,(gethash (or frame (selected-frame)) tab-bar-history-forward))
+      ;; Copy other possible parameters
+      ,@(mapcan (lambda (param)
+                  (unless (memq (car param)
+                                '(name explicit-name group time
+                                  ws wc wc-point wc-bl wc-bbl
+                                  wc-history-back wc-history-forward))
+                    (list param)))
+                (cdr tab)))))
 
 (defun tab-bar--current-tab (&optional tab frame)
   (tab-bar--current-tab-make (or tab (tab-bar--current-tab-find nil frame))))
@@ -951,7 +959,15 @@ tab-bar--current-tab-make
                    (alist-get 'name tab)
                  (funcall tab-bar-tab-name-function)))
       (explicit-name . ,tab-explicit-name)
-      ,@(if tab-group `((group . ,tab-group))))))
+      ,@(if tab-group `((group . ,tab-group)))
+      ;; Copy other possible parameters
+      ,@(mapcan (lambda (param)
+                  (unless (memq (car param)
+                                '(name explicit-name group time
+                                  ws wc wc-point wc-bl wc-bbl
+                                  wc-history-back wc-history-forward))
+                    (list param)))
+                (cdr tab)))))
 
 (defun tab-bar--current-tab-find (&optional tabs frame)
   (assq 'current-tab (or tabs (funcall tab-bar-tabs-function frame))))

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: tab-bar-switch-to-tab removes custom tab data?
  2021-09-20 15:28   ` Juri Linkov
@ 2021-09-20 23:20     ` Adam Porter
  2021-09-21 17:46       ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Porter @ 2021-09-20 23:20 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@linkov.net> writes:

> Here is a patch that implements this, but it's still 100% untested,
> so use it at your own risk :)

Thanks, Juri, that seems to work well.  If this makes it into Emacs 28,
I'll be able to use this in Burly.el soon.  :)




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tab-bar-switch-to-tab removes custom tab data?
  2021-09-20 23:20     ` Adam Porter
@ 2021-09-21 17:46       ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2021-09-21 17:46 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-devel

>> Here is a patch that implements this, but it's still 100% untested,
>> so use it at your own risk :)
>
> Thanks, Juri, that seems to work well.  If this makes it into Emacs 28,
> I'll be able to use this in Burly.el soon.  :)

Thanks for confirming, now it's pushed to what will become Emacs 28.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-21 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-19 22:40 tab-bar-switch-to-tab removes custom tab data? Adam Porter
2021-09-20  6:45 ` Juri Linkov
2021-09-20 15:28   ` Juri Linkov
2021-09-20 23:20     ` Adam Porter
2021-09-21 17:46       ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).