incandescentman
incandescentman

Reputation: 6378

how to get Emacs buffer-stack to ignore certain types of files?

In Emacs, I use a thing called buffer-stack to see and browse my open buffers, useful if I don't know what buffer I want to go to, but I just want to visually see the open buffers (the actual content, not the filenames). I have one keybinding for buffer-stack-up and another for buffer-stack-down, which allows me to scroll left and right between them.

I'd like to exclude certain types of buffers from this behavior. I can already exclude specific buffers by specifying the complete buffer name in a variable called buffer-stack-untracked, e.g. I can mark *Messages* as untracked.

How can I specify certain buffers as untracked using a REGEXP instead? For example, I'd like to exclude buffers that contain the REGEXP Help or .html, even though I can't predict the entire filename.

How do I do this? If it's not possible to do this using buffer-stack, then what package will give me the behavior I want?

Upvotes: 1

Views: 191

Answers (1)

Eric Johnson
Eric Johnson

Reputation: 826

I believe this will be a good starting point.

(defun buffer-stack-filter-regexp (buffer)
  "Non-nil if buffer is in buffer-stack-tracked."
  (not (or (string-match "Help\\|html" (buffer-name buffer))
           (member buffer buffer-stack-untracked))))
(setq buffer-stack-filter 'buffer-stack-filter-regexp)

Upvotes: 2

Related Questions