centaur-tabs icon indicating copy to clipboard operation
centaur-tabs copied to clipboard

Possibility of manual grouping and reordering

Open Abdillah opened this issue 3 years ago • 7 comments

Hello, I'm not actually asking for feature because it might be out of scope (is it?). Instead, I want to ask about this.

On the technical side, is it possible to have manual grouping and reordering on centaur tabs current architecture?

If you would be so kind as to where I can try to experiment this kind of behavior.

Abdillah avatar Apr 26 '21 03:04 Abdillah

I'm not sure what you mean by 'manual grouping', since the grouping behavior is pre-determined by centaur-tabs' config. Why would you want to change this on the fly?

I assume manual reordering means it is possible to 'drag' a tab left or right. Could you specify a little more clearly what exact behavior you're looking for?

nebhrajani-a avatar May 02 '21 08:05 nebhrajani-a

I'm not sure what you mean by 'manual grouping', since the grouping behavior is pre-determined by centaur-tabs' config. Why would you want to change this on the fly?

I re-thought this and it seems a bit complex. I imagine a command like "Move to Group..." then providing available groups to move the tab to.

Could you specify a little more clearly what exact behavior you're looking for?

The practical example is by providing command like "Move Tab to the Left" or "Move Tab to the Right". After which, the displayed tabs and navigation order will be changed accordingly.

I want to experiment on these features on top of centaur tabs, so I need a bit of guidance.

Abdillah avatar May 02 '21 11:05 Abdillah

This is a good feature to have. I joined as collaborator only recently, so give me some time to go through the source to figure out the cleanest way to do this.

Moving tabs left and right is already available: see functions centaur-tabs-move-current-tab-to-left and centaur-tabs-move-current-tab-to-right.

Group switching seems to be a more complex issue, I’ll have to look into how centaur-tabs implements groups to figure out how to interactively shift tabs from one to the other.

This is a great feature to have. It’d also be nice to bind move-right and move-left to mouse drag events.

nebhrajani-a avatar May 02 '21 19:05 nebhrajani-a

This is a good feature to have. I joined as collaborator only recently, so give me some time to go through the source to figure out the cleanest way to do this.

Moving tabs left and right is already available: see functions centaur-tabs-move-current-tab-to-left and centaur-tabs-move-current-tab-to-right.

Oh missed that! Thank you.

This is a great feature to have. It’d also be nice to bind move-right and move-left to mouse drag events.

Right, I feel the same.

Abdillah avatar May 03 '21 07:05 Abdillah

For this feature to be implemented, a custom buffer grouping function has to be created (see centaur-tabs-functions.el line 110). Currently, two of these functions are implemented in centaur-tabs, the default centaur-tabs-buffer-groups function (line 1227 in centaur-tabs-functions.el) and centaur-tabs-projectile-buffer-groups (centaur-tabs-interactive.el line 265).

An idea would be to create a support function (centaur-tabs-create-tab-group or something like that) that interactively prompts the user to input a name for a new tab group to be created and then store this group somewhere (an alist or whatever is more convenient). Then, when the user is in a buffer, he could trigger a centaur-tabs-add-buffer-to-group function which prompts the user the currently available groups and when the user selects a group, the buffer should be added to a list or something related to that group. If the buffer doesn't belong to any group, then it should fall into one existing default group (such as the "Misc" or "Coding" groups inside the centaur-tabs-projectile-buffer-groups function.

What I think can be cumbersome is to handle corner cases such as when the user tries to add a buffer that is already in one group into another group.

This would be just a general idea. Feel free to propose or add anything you may think is relevant!

ema2159 avatar May 07 '21 16:05 ema2159

This would be definitely nice to have. I think being able to send a tab to the next or previous group as in the switching functions 'centaur-tabs-forward-group, 'centaur-tabs-backward-group would be already enough or at least a nice beginning.

This can be a real game changer for centaur-tabs. I hope this doesn't get forgotten.

matheusfillipe avatar Jul 24 '21 02:07 matheusfillipe

I'm just beginning to play with centaur tabs and buffer groups, but a use case I have for this (if I understand correctly) is having a different tab group per window. (eg, when using M-x split-window-right to work on files side-by-side) It can be confusing to have all of my buffers showing up as tabs in all of the windows.

Ideally, I could move to window 1, open a file/buffer and have it only show up in that window. For extra credit, I would like to be able to say "move this buffer to window 2", etc.

claytonrcarter avatar Nov 11 '22 14:11 claytonrcarter