I have files like model.rb and model_spec.rb in my Rails project. Both have ruby as major mode and using a regex doesn't work on the Specs filter group.

(setq ibuffer-saved-filter-groups
  (quote (("default"
              (mode . ruby-mode))
              (name . "spec\.rb$"))))))
  • Have you tried reversing the order? Like putting "Specs" before "Ruby"?
    – Dmitry
    Nov 29, 2014 at 18:43
  • @Dimitry: Reversing the order puts my spec files into the right filter group but i like to have the ruby filter group on top of my ibuffer.
    – t-p
    Nov 30, 2014 at 0:21
  • Okay, then I guess you'll need to use a predicate (see the answer).
    – Dmitry
    Nov 30, 2014 at 2:09

1 Answer 1


Try this:

(setq ibuffer-saved-filter-groups
          (predicate . (and (eq major-mode 'ruby-mode)
                            (not (string-match-p "spec\\.rb\\'"
          (name . "spec\\.rb\\'")))))

Using a more complex check seems necessary, since you want Ruby to be at the top. I also fixed the spec regexp a bit (really escape the dot and use the "end of string" anchor instead of the "end of line").


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.