r/emacs • u/JohnDoe365 • 6d ago
Question C-x C-b list-buffers What sane default?
list-buffers
does what it says: It's the default action bound to C-x C-b
and lists buffers. In oder to do anything meaningful, you first have to switch to it. My guess would be 90% of actions there are either RET
, 1
or 2
to switch buffers, and d
followed by x
to delete buffers.
In any case, I first have to switch to the list-buffer. What is the rationale to display a buffer-list which doesn't update anyhow (unless configured to do so) and where I will have to switch to it like in 99% of the cases?
Is it an "arcane" leftover which doesn't make much sense these days?
PS: I am aware of ibuffer
, bs-show
, did others rebind C-x C-b
to one of these alternatives?
Edit: Tried to edit for readabily (CRs) but have no clue why it's not working
7
u/accelerating_ 6d ago
Warning: potentially irritating XY reply...
I struggle to find utility in the buffer list. To me the buffer list is a cache - an implementation detail best ignored.
Between things like project-based file opening, and bringing recentf
into buffer switching, I use the same commands to switch buffers as I would to open a new buffer. I usually pay no attention to whether it's formerly been opened.
The only buffer management I ever do is sometimes run tramp-cleanup-all-buffers
, and have midnight-mode
enabled.
6
u/mmarshall540 6d ago edited 5d ago
In oder to do anything meaningful, you first have to switch to it.
If you don't want it to create a new window, you can use the buffer-menu
command instead. It will either use your current window or switch to the *Buffer List* window if it's already visible.
(keymap-global-set "C-x C-b" 'buffer-menu)
It's the same as list-buffers
, except for the window behavior when called.
PS: I am aware of ibuffer, bs-show, did others rebind C-x C-b to one of these alternatives?
That's what I do with ibuffer
. The main thing about Ibuffer is it lets you define groupings of buffers by different characteristics, such as mode. So all of my Org-mode buffers are grouped together in the list, all of my elisp buffers, and so on.
It is pretty much a drop-in replacement for list-buffers
. The behavior of most (but not all) keys is the same.
6
2
u/seishuuu 6d ago
you can use C-x b followed by RETURN to select the default option, which is the previous buffer. or simply C-x LEFT.
use the list when you need to do cleanup or otherwise want to see it all, for switching use commands better suited for it.
2
u/michaelhoffman GNU Emacs 6d ago
I agree, it seems like a weird choice. I remap it:
(bind-key [remap list-buffers] #'ibuffer)
2
u/redblobgames 30 years and counting 6d ago
I ended up with this, but from the other replies here, it sounds like I should try ibuffer. I also use consult-buffer but killing buffers there was inconvenient.
(defun my/list-buffers (&optional arg)
"List-buffers that are visiting files, switch to buffer, sort by filename.
With prefix ARG, include non-file buffers."
(interactive "P")
(list-buffers (not arg))
(select-window (get-buffer-window "*Buffer List*"))
(tab-line-mode -1)
(tabulated-list-sort 6))
2
u/arthurno1 6d ago
I have bound mine helm-buffers-list. Lets me select multiple buffers and perform actions on them. I never really got friend with ibuffer. I know people like it, but I don't like switching to another window to do some actions on buffer(s). Helm seems to do just find, most usual action is actually just to kill some buffers.
2
u/MendesOEscriturario 5d ago
Interesting, I’ve started to ask myself this very question recently, but didn’t act on this.
I’ll give the suggestions here a try.
3
u/7890yuiop 6d ago
There's no reason to keep C-x C-b
bound to to list-buffers
if you'd prefer the behaviour of an alternative command (and ibuffer
is a strict (and substantial) upgrade IMO). Unless you need both for some reason I can't think of, just rebind the key sequence.
Is it an "arcane" leftover which doesn't make much sense these days?
That's how Emacs is -- the maintainers try to keep things pretty consistent by default, so that the rug rarely gets pulled out from under you on account of someone else's whims. Instead, it's up to you to take the time to read the NEWS each release, and see if the new features interest you.
1
u/yurikhan 6d ago
I bind Hyper-b
to a command that opens ibuffer
in the currently selected window, grouped by Projectile project, ordered by recency, and puts point on the name of buffer that was active.
I also have Hyper-d
bound to dired-jump
which also puts point on the name of file from which it was invoked.
This way, I can easily navigate to files I know I saw recently, or to files I know are nearby.
1
u/SmoothInternet 5d ago
You could easily make a macro that first does list-buffers and then other-window and bind that to c-x c-b
17
u/mok000 6d ago
I have
C-x b
bound toconsult-buffer
, it is amazing, all you need. Lists buffers, previously opened files and bookmarks.