[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tab-bar-mode new tab hook?
Re: tab-bar-mode new tab hook?
Tue, 26 Apr 2022 05:48:07 -0400
On Tue, Apr 26, 2022 at 3:29 AM Juri Linkov <email@example.com> wrote:
> tab-bar-new-tab-choice prepares the window configuration for the new tab,
> so it's a suitable place to modify frame parameters, e.g.
> (setq tab-bar-new-tab-choice
> (lambda ()
> (set-frame-parameter nil 'name "tab-2")
> > function would apply to the previous tab, rather than the about to be
> > created tab.
> This detail is relevant only when you want to modify tab parameters.
> And tab parameters already include frame buffer-list and buried-buffer-list.
> So not only after creating a new tab, but also after switching between tabs
> these frame parameters get updated.
Ok, thank you. It does seem like I can use `tab-bar-new-tab-choice' to
set the buffer list, but it only works in a subset of situations. Any
command that sets it like `tab-bar-move-tab-to-window' would not be
able to use it.
> >> > Alternatively (or in addition) is the behavior to isolate buffer lists
> >> > in tabs one that would make sense for Emacs to support out-of-the-box?
> >> There is already project-based buffer isolation that works nicely
> >> with tabs, so in a new tab you can set a tab group name, and just
> >> use project buffer commands: 'C-x p b' (project-switch-to-buffer),
> >> 'C-x p k' (project-kill-buffers), etc. Switching to a project buffer
> >> in a new tab is also supported with 'C-x t p b'.
> > Yes, I used that before, but I like to be able to bring buffers in
> > from other projects and have them in my buffer list. Sort of reference
> > files from one project to another, so it is nice for them to actually
> > have their own buffer lists entirely that is not limited to those in
> > the project.
> Don't you think that a feature of limiting a list of buffers
> has only distant connection to tabs? Isn't it the purpose
> of project.el to define a list of buffers? So maybe it would be
> easier to add a new backend to project.el with a list of predefined
> files/buffers? There are also other packages that do something
> like this such as lisp/filesets.el and lisp/filecache.el.
I (and others I have seen) are using tabs as a way to replace
persp-mode/perspective.el, i.e. workspaces. I know some in other text
editors that use our equivalent of frames for this purpose. The intent
is that each workspace is relatively isolated from one another. Each
has its own window configuration and I think it's natural for each
workspace to have its own buffer list. I think that project.el works
great when there is a direct 1:1 mapping between a project and its
workspace. I even use a combination of project.el and tabs (new tab
from known project, for example). From there, `project-find-file' is
useful for finding files in the project that would then get added to
the buffer list. It's just every once in a while that I may want a
custom scratch buffer or to pull a file in that is outside of a
project to be in the current project's workspace, but it does happen.
And when it does happen, I want the buffer list to be separate from
the project specific buffer list. I want a "workspace buffer list". A
project is a physical and "permanent" workspace but I am using tabs as
a logical and transient workspace, which often (but not always) maps
1:1 with a project.
I looked at filesets and filecache and I don't think they would work
here without hooking into all of the buffer management machinery. I
imagine you didn't intend for it, but the fact that tab-bar-mode
manages its own buffer-list frame-parameter per tab makes it perfectly
suited for the purpose of tabs being used as workspaces.
> But if you want to plug such a feature into tabs, we could add
> more hooks to tab-bar-mode to make it easier to do this.
> So please help to identify these points for more customization.
I just found `tab-bar-tab-post-open-functions', which should do
exactly what I need.