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

Problem with grouping special buffers #25

Open
carcot opened this issue Jul 14, 2019 · 7 comments
Open

Problem with grouping special buffers #25

carcot opened this issue Jul 14, 2019 · 7 comments

Comments

@carcot
Copy link

carcot commented Jul 14, 2019

For me some of the special buffers get listed under a VC project. I had to change ibuffer-vc-root like this to make it work properly:

(defun ibuffer-vc-root (buf)
  "Return a cons cell (backend-name . root-dir) for BUF.
If the file is not under version control, nil is returned instead."
  (let ((file-name (with-current-buffer buf
                     (and buffer-file-name
                          (file-truename buffer-file-name)))))
    (when (and file-name
               (ibuffer-vc--include-file-p file-name))
      (let ((backend (ibuffer-vc--deduce-backend file-name)))
        (when backend
          (let* ((root-fn-name (intern (format "vc-%s-root" (downcase (symbol-name backend)))))
                 (root-dir
                  (cond
                   ((fboundp root-fn-name) (funcall root-fn-name file-name)) ; git, svn, hg, bzr (at least)
                   ((memq backend '(darcs DARCS)) (vc-darcs-find-root file-name))
                   ((memq backend '(cvs CVS)) (vc-find-root file-name "CVS"))
                   ((memq backend '(rcs RCS)) (or (vc-find-root file-name "RCS")
                                                  (concat file-name ",v")))
                   ((memq backend '(src SRC)) (or (vc-find-root file-name ".src")
                                                  (concat file-name ",v")))
                   (t (error "ibuffer-vc: don't know how to find root for vc backend '%s' - please submit a bug report or patch" backend)))))
            (cons backend root-dir)))))))
@purcell
Copy link
Owner

purcell commented Jul 15, 2019

Thanks, but what do you mean by "properly"? You've provided some changed code, but not described why it was changed, so it's not obvious why a change might be necessary.

@carcot
Copy link
Author

carcot commented Jul 15, 2019

Sorry I wasn't clear. In the Screenshot in the README, the special buffers like *Messages* are listed under the group [ Default ]. For me the special buffers were being listed under a VC project group (e.g., [ Git: ~/.emacs.d/ ]), generally the first one, at the top.

Does that make sense now?

Oh, and the changes in the code are at the beginning. In particular, in the let and the when condition so that ibuffer-vc-root returns nil for the special buffers. That wasn't happening for me with the original code. (I don't know why -- the function must have worked in the past and I assume still works for others now.)

@doolio
Copy link

doolio commented Jan 26, 2020

To add to this discussion, as an issue I've noted seems related. For me, the default special buffers like *Messages* and *scratch* are listed under the [ Default ] group but I guess it is because these are created by default (!) at startup before one even opens an *Ibuffer*.

Other special buffers such as *help* (or *helpful* in my specific case) can be listed either under a VC group or the [ Default ] group as one might expect. What I've found is that it depends on which buffer you are in when you open such special buffers which determine under which *Ibuffer* group they end up. For example if you are in your *scratch* buffer and open a *help* buffer this *help* buffer is grouped under [ Default ]. However, if you are in a VC grouped buffer when you open a *help* buffer it is listed under the VC group of the VC grouped buffer you were in. I just tried killing and re-creating a *scratch* buffer and it is treated the same as *help* buffers.

Perhaps this behaviour is intentional as you could presume if one opens a *help* buffer when in a VC grouped buffer they are opening it for something related to the VC project. But this won't always be the case.

In any case, thanks for this and your other packages and for your time. Hope this helps.

@purcell
Copy link
Owner

purcell commented Jan 26, 2020

Yes, those buffers inherit their default-directory from the current buffer when they are created.

@doolio
Copy link

doolio commented Jan 26, 2020

ah I see thanks for explaining

@c-alpha
Copy link

c-alpha commented Sep 10, 2022

FWIW, I've faced the same issue, and this solved it for me:

(setq ibuffer-vc-include-function (lambda (file) (not (file-directory-p file))))

@doolio
Copy link

doolio commented Sep 12, 2022

Good to know thanks.

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

No branches or pull requests

4 participants