1

I would like to catch popup buffers with display-buffer-alist by their major-mode instead of matching the buffer name with a regexp.

For example I have dired-mode buffers that popup and I can't come up with proper regexp that would only match dired-mode buffer names.

It would be nice if I could instead do something like this:

(setq display-buffer-alist
      '((string= major-mode "dired-mode")
         (display-buffer-same-window)))

I understand that their are packages such as popwin and shackle that can do this but these packages do not work for my use case.

2
  • 1
    I do this by having a catch-all regexp and a custom function that handles all incoming buffers that are processed through the display-buffer-alist -- if the buffer coming through has a particular major-mode that my custom function looks for, then it is handled according to my pre-programmed method. I will probably not write up a minimal answer for this particular thread, but if you would like to see a more complex example of how this works, see my previous question/answer on stackoverflow.com: stackoverflow.com/q/18346785/2112489
    – lawlist
    Oct 1 '21 at 16:56
  • FYI: The most common method for testing the existence of a particular major-mode within a buffer is with the following code snippet: (eq major-mode 'dired-mode)
    – lawlist
    Oct 1 '21 at 21:42

Your Answer

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

Browse other questions tagged or ask your own question.