+
+ (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
+ (defun b/ivy-ignore-buffer-p (str)
+ "Return non-nil if str names a buffer with a major mode
+derived from one of `b/ivy-ignore-buffer-modes'.
+
+This function is intended for use with `ivy-ignore-buffers'."
+ (let* ((buf (get-buffer str))
+ (mode (and buf (buffer-local-value 'major-mode buf))))
+ (and mode
+ (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
+ (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
+