Skip to content

Hiding dired buffers

diego edited this page Nov 18, 2017 · 2 revisions

In order to hide dired buffers in ivy-switch-buffer, you can add a function to ivy-ignore-buffers as follows:

(defun d/ignore-dired-buffers (str)
  "Return non-nil if STR names a Dired buffer.
This function is intended for use with `ivy-ignore-buffers'."
  (let ((buf (get-buffer str)))
    (and buf (eq (buffer-local-value 'major-mode buf) 'dired-mode))))

(with-eval-after-load 'ivy
  (add-to-list 'ivy-ignore-buffers #'d/ignore-dired-buffers))

This will hide dired buffers in the same way as buffers hidden by regexp, showing them if the search criteria matches the name of the dired buffer (and not the name of an open buffer).