jojojames / ibuffer-sidebar

A sidebar for IBuffer
GNU General Public License v3.0
69 stars 8 forks source link

Frame-specific ibuffers (mainly for frame-purpose.el) #2

Open akirak opened 6 years ago

akirak commented 6 years ago

frame-purpose.el by alphapapa alters buffer-list function on a frame so that it serves a specific mode/directory. That is, with frame-purpose, ibuffer/switch-to-buffer/etc. can be restricted to a specific mode/directory.

ibuffer-sidebar does not seem to work well with frame-purpose at present, because it shares the same buffer name between all frames. I could invent a solution to this problem by overriding ibuffer-sidebar-get-or-create-buffer function as follows:

(defun ibuffer-sidebar-get-or-create-buffer ()
    "Get or create a `ibuffer-sidebar' buffer."
    (or (ibuffer-sidebar-buffer)
        (let ((new-buffer (generate-new-buffer ibuffer-sidebar-name)))
          (with-current-buffer new-buffer
            (ibuffer-sidebar-setup))
          new-buffer)))

This solution creates a new (number-suffixed) ibuffer-sidebar buffer if the current frame does not have one. This seem to work nicely with frame-purpose and makes an Emacs frame more like an IDE window, thanks to your sidebar packages.

Note that this is a proof of concept and may not be a practical solution. If you don't use frame-purpose, sharing the same ibuffer-sidebar buffer between all frames would be better. I think it needs refinement, but I would like to hear your comment before I (or you) may work on further implementation. Is there anything wrong with this solution?

jojojames commented 6 years ago

Note that this is a proof of concept and may not be a practical solution. If you don't use frame-purpose, sharing the same ibuffer-sidebar buffer between all frames would be better. I think it needs refinement, but I would like to hear your comment before I (or you) may work on further implementation. Is there anything wrong with this solution?

Sounds good. When I have some time, I'll try frame-purpose.el for myself. I'm open to you trying to jigger something up and opening a PR though. As long as both workflows work (frame-purpose or not), I think it'd be a cool change.