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

Allow multiple workspaces per buffer #53

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gagbo
Copy link

@gagbo gagbo commented Dec 13, 2020

Hello again,

I hope this time I'll be clear enough, I tend to over-complicate things and I try to work on that :(

Rescoping the previous messy PR I made. The point is that here, we do not need non-consuming groups in order to allow multiple workspaces for a single buffer.

Feature summary

The workflow I want to cover is :

  • Set the frame to a given workspace context (let's say "Bufler") with bufler-workspace-frame-set
  • Whenever I find a file in the frame, I add "Bufler" to its list of workspaces. So find-file on "bufler.el" will (through hooks) call (bufler-workspace-buffer-name-workspace "Bufler")
  • Change context (starting to work on my Emacs config instead)
  • Set the frame to the new workspace ("Emacs Config") with bufler-workspace-frame-set
  • Find the same "bufler.el" file. Now the hook will call (bufler-workspace-buffer-name-workspace "Emacs Config")

Then, if I list buffers with M-x bufler, I want to see the bufler.el buffer under 2 different named workspaces.
image

Change summary

  • Rename bufler-workspace-name to bufler-workspace-names to show it
    can hold multiple values
  • Add prefix to workspace names in the groups
  • Make bufler-workspace-buffer-name-workspace add to list of
    buffer-local workspace value instead of replacing it
  • Use another version of seq-group-by in bufler-group-tree that adds
    an element in multiple groups if the grouping function returns a list.

For the last point, it would be better to use cl-defmethod to override
the seq-group-by function only when grouping workspaces but currently
no version tried work. Last try :

(cl-defmethod seq-group-by ((function (eql 'bufler-group-auto-workspace)) sequence)
  "Specialization of `seq-group-by' that puts elements of SEQUENCES in each of
the workspaces returned by FUNCTION."
  (seq-reduce
   (lambda (acc elt)
     (let ((keys (funcall function elt))
           (add-to-groups (lambda (key)
                            (let ((cell (assoc key acc)))
                              (if cell
                                  (setcdr cell (push elt (cdr cell)))
                                (push (list key elt) acc))))))
       (mapc add-to-groups keys)
       acc))
   (seq-reverse sequence)
   nil))

@gagbo gagbo force-pushed the feature/multiple_workspaces branch from 37b4a04 to fad3c20 Compare January 2, 2021 23:30
@alphapapa
Copy link
Owner

FYI, I probably won't have time to look at this soon. Thanks for your patience.

@alphapapa
Copy link
Owner

FYI, due to some IRL issues and computer problems, I haven't had time to work on Emacs stuff. It will probably be a while longer before I can look at this carefully.

@gagbo gagbo force-pushed the feature/multiple_workspaces branch from 71a32f5 to fdb8193 Compare March 28, 2021 13:02
@gagbo
Copy link
Author

gagbo commented Mar 28, 2021

Don't worry, living comes first.

Actually I think I'll move the PR back to draft as I'm only starting using the features I'd like to add and I'm seeing a few bugs/usability issues that I'm fixing

@gagbo gagbo marked this pull request as draft March 28, 2021 13:05
@gagbo gagbo force-pushed the feature/multiple_workspaces branch 2 times, most recently from c8bb2a8 to 5fda7f5 Compare March 29, 2021 22:04
@alphapapa
Copy link
Owner

Ok, thanks. Let me know when you're ready for it to be looked at again.

@alphapapa
Copy link
Owner

For reference, this PR's ideas were previously discussed at #49.

Thinking about this a bit more, I think what's needed is:

  1. Allow groups to be specified with a plist for options, e.g. a :no-consume t one.
  2. The grouping function (i.e. the equivalent of seq-group-by, assuming we have to reimplement one like it with our changes) should use that plist to control what it does with the grouped values. So if non-consuming is specified, a buffer would not be consumed, and it would be eligible for also being matched by other predicates. It might be necessary to distinguish between "match into this group, but don't consume this, and allow other predicates in this chain to match it" and "match into this group, but don't consume this, but don't allow other predicates in this chain to match it, only ones in a parallel tree"...which starts to feel a little complicated, so we'll have to see.

@alphapapa
Copy link
Owner

We should probably discuss these ideas in an issue rather than a PR, so: #69

@gagbo gagbo force-pushed the feature/multiple_workspaces branch from 5fda7f5 to d5346b6 Compare July 9, 2021 07:09
- Rename `bufler-workspace-name` to `bufler-workspace-names` to show it
  can hold multiple values
- Add prefix to workspace names in the groups (as a defcustom)
- Make `bufler-workspace-buffer-name-workspace` add to list of
  buffer-local workspace value instead of replacing it
- Use another version of `seq-group-by` in `bufler-group-tree` that adds
  an element in multiple groups if the grouping function returns a list.
- Add utility functions to access/manage named workspaces
  + Add function to list all buffers in a named workspace
  + Add function to clean up a single named workspace

Co-authored-by: Adam Porter <[email protected]>
@gagbo gagbo force-pushed the feature/multiple_workspaces branch from d5346b6 to 3d3bb8c Compare August 1, 2021 07:48
@alphapapa alphapapa force-pushed the master branch 3 times, most recently from 9333643 to 84e837f Compare September 18, 2023 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants