2

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"
            ("Ruby" 
              (mode . ruby-mode))
            ("Specs"
              (name . "spec\.rb$"))))))
3
  • Have you tried reversing the order? Like putting "Specs" before "Ruby"?
    – Dmitry
    Commented 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
    Commented Nov 30, 2014 at 0:21
  • Okay, then I guess you'll need to use a predicate (see the answer).
    – Dmitry
    Commented Nov 30, 2014 at 2:09

1 Answer 1

2

Try this:

(setq ibuffer-saved-filter-groups
      '(("default"
         ("Ruby"
          (predicate . (and (eq major-mode 'ruby-mode)
                            (not (string-match-p "spec\\.rb\\'"
                                                 buffer-file-name)))))
         ("Specs"
          (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").

0

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.