Skip to main content
edited tags
Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Source Link
PRouleau
  • 841
  • 5
  • 10

How to programmatically find buffer visiting specific directory

I'm looking for something similar to (find-buffer-visiting FILENAME &optional PREDICATE) that would find a dired-mode buffer visiting a specified directory. Something like:

(find-buffer-visiting-dir DIRNAME)

The built-in find-buffer-visiting only searches buffer visiting files quite unfortunately. It checks if the buffer has a local buffer-file-name variable bound. The optional PREDICATE is therefore used only on files.

A potential improvement for that function would be to write (find-buffer-visiting FILENAME &optional PREDICATE FILTER) where FILTER would be a filter function used on all buffers to determine if the buffer should be included in the search.

Is there something like this already available?