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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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