Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer tree! #1593

Closed
wants to merge 5 commits into from
Closed

Buffer tree! #1593

wants to merge 5 commits into from

Conversation

Ambrevar
Copy link
Member

@Ambrevar Ambrevar commented Jul 5, 2021

This addresses #854 as well as some points mentioned in #1573 and in #565.

This changes the logic of switch-buffer-previous and switch-buffer-next to finally fix the long-standing issue of "jumping-around buffer last-access".

Now to go to the last visited buffer, use the new switch-buffer-last.

switch-buffer-previous visits the previous siblings (siblings are sorted by ID), switch-buffer-next to the next.

Questions before we can merge: can we browse the whole tree (including children and parents) with just switch-buffer-previous and switch-buffer-next?
To do so with just 2 commands we'd need to keep track of the visited parents (this is OK, can store it as a buffer slot). Is this what we want?

Example:

  • root
    • childA
      • subchildA1
      • subchildA2
    • childB
      • subchildB1
      • subchildB2

If we are on childA, successive calls to switch-buffer-next should visit, in order:

  • subchildA1
  • subchildA2
  • childB
  • subchildB1
  • subchildB2
  • root
  • childA

and we loop.

Does that make the most sense?

@jmercouris
Copy link
Member

Looks great. I would like to make some tweaks to the appearance of this and list-buffers. When the tree depth gets too great, it can become visually hard to read.

@jmercouris
Copy link
Member

I'll push some stylistic changes to this branch and then merge.

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 5, 2021 via email

@jmercouris
Copy link
Member

OK!

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021

When the tree depth gets too great, it can become visually hard to read.

What about making the roots collapsable?

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021

Also what's your take on my question in the original post about the tree traversal?
Shall we add more commands or just have 2 commands that traverse the whole tree in a depth-first fashion?

@jmercouris
Copy link
Member

I believe few people have the sufficient mental model to keep in mind the tree structure. I think they will be very surprised by switch-buffer-next and switch-buffer-previous if we make it utilize the tree.

I suggest keeping this model as simple as possible and leaving it the way it is.

@jmercouris
Copy link
Member

With regards to adding two more commands, I don't see the advantage it provides over simply utilizing switch-buffer.

@jmercouris
Copy link
Member

Lastly, with regards to making roots collapsible; I will work on that CSS, it might be a little bit tricky though.

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021

I believe few people have the sufficient mental model to keep in mind the tree structure. I think they will be very surprised by switch-buffer-next and switch-buffer-previous if we make it utilize the tree.

I suggest keeping this model as simple as possible and leaving it the way it is.

I think there is a misunderstanding. I believe that the current implement is confusing, because switch-buffer-previous and switch-buffer-next does cycle through all buffers!

So what I'm suggesting instead is to flatten the tree in a reproducible way and have the commands rotate over the result. This way the commands will behave like C-tab and C-shift-tab in other browsers.

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021

To clarify: I'm precisely trying to abstract the tree away from the user.

@jmercouris
Copy link
Member

I am trying to say this:

I believe a list sorted by last access is more intuitive than a flattened tree.

@jmercouris
Copy link
Member

Now, why does our C-tab equivalent not work as in other browsers? I believe it does not work because we treat each keypress as an individual command and update the access time on EACH press for EACH buffer. In a traditional browser or GUI system, the last access for a program does not get updated until you release control and select your new program or tab.

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021

Now, why does our C-tab equivalent not work as in other browsers? I believe it does not work because we treat each keypress as an individual command and update the access time on EACH press for EACH buffer. In a traditional browser or GUI system, the last access for a program does not get updated until you release control and select your new program or tab.

I don't think that's correct: in other browsers, tabs are ordered, so C-tab can trivially cycle across all tabs. Last access is not used. This is essentially what I'm trying to do by flattening the tree.

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021

I believe a list sorted by last access is more intuitive than a flattened tree.

This is the implementation on master, and it does not work as you've indicated in your other answer. As soon as we switch to the next buffer, the last access time is updated, thus preventing the user from cycling through all buffers. This is not the right approach.

@jmercouris
Copy link
Member

OK, so we wish to emulate a traditional browser and NOT a WM application switcher. Then your flattened tree approach is appropriate.

@jmercouris
Copy link
Member

My confusion arises from the fact that you wanted C-tab and C-shift-tab to cycle in the past, which is the behavior one expects from a WM application switcher, and not a browser. Now I see that you would like to switch it to the behavior of a traditional browser. That is fine with me!

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021 via email

@jmercouris
Copy link
Member

jmercouris commented Jul 6, 2021

Pressing Cmd + Tab in macOS uses most recency to sort applications.

Pressing Control + Tab in Safari presents the list in a fixed order.

@jmercouris
Copy link
Member

Please let me know when I can make changes to this branch. (The style/collapsing functionality).

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021 via email

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 6, 2021 via email

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 7, 2021

@aartaka Thoughts on this?

@aartaka
Copy link
Contributor

aartaka commented Jul 7, 2021

Looks right! I haven't digged deep enough into the code, though.

@Ambrevar
Copy link
Member Author

I've just pushed the full implementation of the buffer tree traversal.

So now if you've got a tree as in the original post, say you are on ChildA, pressing switch-buffer-next will always bring you to subchildA1, and switch-buffer-previous will always bring you to ChildA, regardless of the last access time.

This essentially emulates "fixed tab positions" from popular browsers.

Ready to merge for me, let me know what you think.

@jmercouris
Copy link
Member

I suggest: Let's first merge the spinneret changes, then we convert this to spinneret, and then merge it.

@Ambrevar
Copy link
Member Author

Ambrevar commented Jul 19, 2021 via email

@Ambrevar
Copy link
Member Author

Merged with b1e2443.

@Ambrevar Ambrevar closed this Jul 21, 2021
@Ambrevar Ambrevar deleted the buffer-tree branch July 28, 2021 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants