Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs buffer-menu: how to show only file + dired buffers?

Tags:

emacs

I use buffer-menu extensively to switch between buffers. I want to list the buffers which are files or dired. How can I do that?

like image 675
Sabya Avatar asked Oct 27 '11 09:10

Sabya


People also ask

How do I change the read only buffer in Emacs?

To change the read-only status of a buffer, use C-x C-q (toggle read-only-mode ).

Can you only have one buffer open in Emacs at a time?

Each Emacs window displays one Emacs buffer at any time. A single buffer may appear in more than one window; if it does, any changes in its text are displayed in all the windows where it appears. But the windows showing the same buffer can show different parts of it, because each window has its own value of point.

Can you have more than one buffer in Emacs?

When Emacs has multiple windows, each window has a chosen buffer which is displayed there, but at any time only one of the windows is selected and its chosen buffer is the selected buffer. Each window's mode line displays the name of the buffer that the window is displaying (see section Multiple Windows).

Can I have more than one buffer open in Emacs at the time?

You can have several buffers open at once, but can edit only one at a time. Several buffers can be visible at the same time when you're splitting your window.


1 Answers

You can use ibuffer

There you can define your buffer groups. You can mark buffers, use filtering and sorting, do search/replace in marked buffers and other useful stuff.

For your case just put into the hook (ibuffer-filter-by-filename ".")

Here is an example from my .emacs .

(require 'ibuffer)

(setq ibuffer-saved-filter-groups
      (quote (("default"
               ("dired" (mode . dired-mode))
               ("java" (mode . java-mode))
               ("org" (mode . org-mode))
               ("sql" (mode . sql-mode))
               ("xml" (mode . nxml-mode))))))    

(setq ibuffer-show-empty-filter-groups nil)

(add-hook 'ibuffer-mode-hook 
 (lambda () 
  (ibuffer-switch-to-saved-filter-groups "default")
  (ibuffer-filter-by-filename "."))) ;; to show only dired and files buffers

EDIT. If you want to filter out temporary buffers (which name begins with *) you can set the following filter (regex)

(ibuffer-filter-by-name "^[^*]")

It says that the buffer name should start with any character except *.

like image 99
Oleg Pavliv Avatar answered Oct 02 '22 07:10

Oleg Pavliv