I have one frame, one window. I use Cx 3, I now have two windows.
I use Cx Cb in order to see the list of buffers, however it opens it in another window but doesn't put the focus on it. It is even more annoying if I had opened a buffer on the 2nd window.
I would prefer to either open the buffer list in the window which currently has the focus, or temporarily change the focus to the buffer list.
First of all I want to start by saying that the ibuffer
function does similary to what you want and does so in the current window, its definitely worth checking out.
Now onto your actual question. Cx Cb
by default calls the function list-buffers
. If you search for that command using Ch f
it will show you the documentation, from there you can view the source code for the function by clicking on the underlined text that says buff-menu.el
.
Now we can view the source of the list-buffers
, the first function called is display-buffer
. That sounds promising. We can now use Ch f
once again to search for the display-buffer
command. Reading though this documentation we see that the variable display-buffer-alist
dictates how the display-buffer
and in turn how list-buffers
works. We can then see that by adding ("*Buffer List*" . display-buffer-same-window)
to display-buffer-alist
you will get the desired result.
All in all you simply need to put (add-to-list 'display-buffer-alist '("*Buffer List*" . display-buffer-same-window))
in your init file for your changes to take place.
Please just try one of these:
(defun my:list-buffers (&optional arg) (interactive "P") (display-buffer (list-buffers-no-select arg) '(display-buffer-same-window)))
(defun my:list-buffers2 (&optional arg) (interactive "P") (select-window (list-buffers arg)))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.