[英]how to show buffer content in real time in other window when focus is in buffer list
我有2个窗口,一个是缓冲区列表,当我使用n和p导航缓冲区列表时,如何在其他窗口的缓冲区列表中显示缓冲区? 非常感谢。
如果我理解正确的问题,答案只是在缓冲区菜单中使用Co
会在另一个窗口中显示您所在行的缓冲区,但不会选择该缓冲区。 也就是说,它不会将输入焦点移到该缓冲区的窗口。 缓冲区列表保留了输入焦点,因此您可以继续在不同的行上使用Co
来显示不同的缓冲区。
如果您说“框架”是指Emacs窗口,请参见上文。 即使缓冲区在不同的框架上也是如此,这是一个警告:一些窗口管理器(包括MS Windows)将输入焦点更改为创建的新框架。 因此,如果,例如,你有非nil
pop-up-frames
(使得一个单独的帧被用于显示的缓冲液),和如果选择显示(使用缓冲Co
)没有在某些其它帧已经示出,然后显示它不仅为其创建了一个新框架,而且还将焦点转移到了该新框架。 如果该缓冲区在另一帧中已经可见,则Co
只需升高该帧。
当前在缓冲区列表显示中没有键绑定,这两种方法(a)将光标向下或向上移动到下一个或上一个缓冲区行,以及(b)调用显示目标缓冲区行上命名的缓冲区的Co
行为。 但是您可以轻松定义这样的命令并将其绑定到键:
(defun show-next (arg)
"Show next line's buffer in another window."
(interactive "p")
(next-line arg)
(Buffer-menu-switch-other-window))
(defun show-previous (arg)
"Show previous line's buffer in another window."
(interactive "p")
(previous-line arg)
(Buffer-menu-switch-other-window))
(define-key Buffer-menu-mode-map "\M-n" 'show-next)
(define-key Buffer-menu-mode-map "\M-p" 'show-previous)
这是我在干燥缓冲区中实现此功能的原型。 它被访问后杀死缓冲区。
我喜欢Ranger文件管理器中的此功能,在浏览目录时非常方便。
(setq show-next-current-buffer nil)
(defun show-next ()
(interactive)
(next-line 1)
(dired-find-file-other-window)
(if show-next-current-buffer (kill-buffer show-next-current-buffer))
(setq show-next-current-buffer (current-buffer))
(other-window 1)
)
(defun show-previous ()
(interactive)
(previous-line 1)
(dired-find-file-other-window)
(if show-next-current-buffer (kill-buffer show-next-current-buffer))
(setq show-next-current-buffer (current-buffer))
(other-window 1)
)
(define-key dired-mode-map "n" 'show-next)
(define-key dired-mode-map "p" 'show-previous)
编辑 :我编写了一个次要模式,以轻松启用/禁用此功能。 请参阅https://gitlab.com/emacs-stuff/my-elisp/blob/master/dired-show.el,然后将其融合到您的需求中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.