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

Multiple frames? #24

Open
will-henney opened this issue Aug 31, 2016 · 2 comments
Open

Multiple frames? #24

will-henney opened this issue Aug 31, 2016 · 2 comments

Comments

@will-henney
Copy link

Hi. This looks like a nice package, but I can't work out how it is supposed to work when you have more than one frame open. Say that I have Buffer A visible in Frame X and Buffer B visible in Frame Y. I turn on imenu-list-minor-mode in Frame X and it shows me the menu for Buffer A - so far, so good! But now, if I change focus to Frame Y, the menu for Buffer B appears in Frame X (not in Frame Y). This is not useful - for instance, I can't click on any Buffer B items in the menu because that switches the focus back to Frame X, which means that the menu jumps back to Buffer A without registering the click.

The only workaround seems to be to toggle imenu-list-minor-mode two times after each time that I switch frames.

Any advice? Thanks

@bmag
Copy link
Owner

bmag commented Sep 1, 2016

Hi, thanks for the feedback. imenu-list doesn't support a multiple frames workflow yet. The current status is that imenu-list assumes there's only one imenu-list buffer at all times. I'd like to support a ilist-buffer-per-frame or even an ilist-buffer-per-window workflow, but unfortunately I don't have the time to implement it, at least not in the foreseeable future. If you'd like to help, I'll gladly discuss and merge pull requests.

You can checkout the per-frame branch, where I have started work on a somewhat heavy-weight approach for the one-ilist-buffer-per-frame workflow. It's not finished, and the commit message of the last commit has details about what needs to be done. However, that branch might be too heavy-weight. I have a few other ideas for how to implement per-frame or per-window support, let me know if you're interested.

@Alexander-Miller
Copy link

Your use case is very similar to treemacs, where I did implement frame locality a while ago. If a simple one buffer per frame approach is what you're going for you can copy most of the implementation details from treemacs.

The basic idea is quite simple, you just build an alist mapping frames to buffers and access your buffer with something like this:

(defsubst treemacs--get-framelocal-buffer ()
  "Get this frame's local buffer, creating it if necessary.
Will also perform cleanup if the buffer is dead."
  (-let*- [(frame (selected-frame))
           (buf   (assq frame treemacs--buffer-access))]
    (when (or (null buf)
              (not (buffer-live-p buf)))
      (setq treemacs--buffer-access
            (assq-delete-all frame treemacs--buffer-access))
      (setq buf (get-buffer-create (format "%sFramebuffer-%s*" treemacs--buffer-name-prefix (frame-parameter frame 'treemacs-id))))
      (push (cons frame buf) treemacs--buffer-access))
    buf))

Other than that code you'll also need some hooks to clean up the alist when frames/buffers are killed and deal with a bunch of your global variables suddenly becoming buffer-local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants