用C-x C-b切换到缓冲区而不改变窗口

时间:2016-04-05 16:18:17

标签: emacs window buffer

我通常在emacs中打开2-3个窗口,特别是哪个缓冲区显示在哪里。当C-x C-f显示当前窗口中的缓冲区(文件访问)时,C-x C-b(以及来自recentf包的recentf-open-files)有时会在另一个窗口中显示它,然后需要进行复杂的重新排列。

有没有办法强制这些命令最终显示在C-x C-f或C-x C-b发布时处于活动状态的窗口中的缓冲区?

1 个答案:

答案 0 :(得分:1)

问题的功能list-buffers是一行的 - 所以只需将display-buffer更改为switch-to-buffer并重新定义键盘快捷键以指向新功能:

  
(defun my-list-buffers (&optional arg)
"Display a list of existing buffers.
The list is displayed in a buffer named \"*Buffer List*\".
See `buffer-menu' for a description of the Buffer Menu.
By default, all buffers are listed except those whose names start
with a space (which are for internal use).  With prefix argument
ARG, show only buffers that are visiting files."
  (interactive "P")
  (switch-to-buffer (list-buffers-noselect arg)))

(define-key ctl-x-map "\C-b" 'my-list-buffers)