Filtering Major Modes in Emacs Buffers

February 10, 2020

Having adopt­ed emacs-libvterm as my main term, I wanted a first-class way to open and switch between vterm buffers.

With ivy-rich, one can view the major mode of the buffer list when run­ning ivy-switch-bufffer. How­ev­er, there does­n’t seem to be a way to filter by mode, or any­thing else, really, aside from buffer name.

I’m not quite happy with this yet, but I wrote this:

(defun sy/search-vterm()
  (ibuffer-filter-by-mode 'vterm-mode))
(map! "C-c C-v" #'sy/search-vterm)

which first runs swiper on ibuffer, clears the exist­ing ibuffer fil­ters, then fil­ters by 'vterm-mode. Of course, this can be swapped out for any other mode you like.


Swiper in action
Swiper in action