每当我在emacs中执行apropos,describe-key或其他一些帮助功能时,它会在我的其他窗口中显示帮助。为了摆脱它,我必须更改窗口/缓冲区去那里,键入“q”,然后回到我的原始工作缓冲区。emacs从原始缓冲区调度帮助窗口
有没有一种方法可以以某种方式在代码中执行此操作?我知道如何保存偏移,切换缓冲区等,但我不知道如何在另一个缓冲区中结束时将“q”发送到minibuffer/emacs。谢谢
每当我在emacs中执行apropos,describe-key或其他一些帮助功能时,它会在我的其他窗口中显示帮助。为了摆脱它,我必须更改窗口/缓冲区去那里,键入“q”,然后回到我的原始工作缓冲区。emacs从原始缓冲区调度帮助窗口
有没有一种方法可以以某种方式在代码中执行此操作?我知道如何保存偏移,切换缓冲区等,但我不知道如何在另一个缓冲区中结束时将“q”发送到minibuffer/emacs。谢谢
这是我对这个问题的解决方案。我将此命令绑定到C-c q
:
(defvar my/help-window-names
'(
;; Ubiquitous help buffers
"*Help*"
"*Apropos*"
"*Messages*"
"*Completions*"
;; Other general buffers
"*Command History*"
"*Compile-Log*"
"*disabled command*")
"Names of buffers that `my/quit-help-windows' should quit.")
(defun my/quit-help-windows (&optional kill frame)
"Quit all windows with help-like buffers.
Call `quit-windows-on' for every buffer named in
`my/help-windows-name'. The optional parameters KILL and FRAME
are just as in `quit-windows-on', except FRAME defaults to t (so
that only windows on the selected frame are considered).
Note that a nil value for FRAME cannot be distinguished from an
omitted parameter and will be ignored; use some other value if
you want to quit windows on all frames."
(interactive)
(let ((frame (or frame t)))
(dolist (name my/help-window-names)
(ignore-errors
(quit-windows-on name kill frame)))))
有趣的解决方案 - 不要用“q”与缓冲区交谈,与Emacs交谈并说“杀死所有这些人”。并且可扩展,这很好。感谢您贡献您的代码。 – Kevin
help-window-select
变量可能正是你想要的。 如果您将其值设置为true (setq help-window-select t)
,那么当您通过其中一个帮助命令打开帮助窗口时,将自动选择帮助窗口。然后您可以按q
退出并返回原始缓冲区。还有很多其他的选择,所以你应该检查这些。
对于apropos窗口或任何使用display-buffer
的窗口,您可以使用。
(add-to-list 'display-buffer-alist
'("*Apropos*" display-buffer-same-window))
display-buffer-same-window
是许多选项之一;它会在当前窗口中打开缓冲区。查看display-buffer
函数的文档可以看到其他可能的选项。
谢谢你的快速,准确的目标回复!我们在那里。设置变量确实可以解决describe-key的问题,但不能解决Apropos显示问题。我检查了等效的apropos变量(describe-variable apropos),但没有一个看起来像帮助窗口选择。想法? – Kevin
对不起,延迟重播,我编辑我的答案与apropos缓冲区的一些信息。我使用一个类似的命令在当前窗口中打开一个shell,而不是在另一个窗口中打开。希望能帮助到你。 – Jules
谢谢Jules。我想最好让它覆盖我目前的缓冲区,因为很容易以这种方式进行调度。比不得不去那边并输入q ...再次感谢你。 – Kevin
我建议把(winner-mode 1)
在你的init文件,然后使用C-C<左>调用winner-undo
(反复,如果需要的话)返回到上一个窗口的配置。
是的,谢谢你的提示。我已经有了赢家模式(但奇怪的是,很少使用它,因为ctrl-x o的旧习惯很难实现......)在Emacs的底层有很多缓冲/窗口魔法。我不知道为什么Apropos不算作帮助窗口 - 它以相同的方式发送(用q)。好吧。我现在有一些工作,所以对其他事情。 – Kevin
'apropos-mode'和'help-mode'是不同的主要模式。然而,它们都是从'special-mode'(它提供了键绑定)派生而来的。 – phils
YMMV,但我只能建议习惯于使用'winner-undo'(也许将它绑定到稍微简单的按键序列,如果有帮助的话)。我发现它对于类似于这个问题的所有问题的一般化解决方案来说是非常宝贵的,同时也便于恢复我故意制作的窗口更改。 – phils
帮助缓冲区具有'help-window-select',如下所述。一般来说,你可能对枷锁包(https://github.com/wasamasa/shackle)感兴趣。 – jpkotta