imenu-list icon indicating copy to clipboard operation
imenu-list copied to clipboard

Multiple frames?

Open will-henney opened this issue 9 years ago • 2 comments

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

will-henney avatar Aug 31 '16 18:08 will-henney

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.

bmag avatar Sep 01 '16 06:09 bmag

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.

Alexander-Miller avatar Feb 05 '18 18:02 Alexander-Miller