emacs从原始缓冲区调度帮助窗口

Kev*_*vin 4 emacs

每当我在emacs中执行apropos,describe-key或其他一些帮助功能时,它会在我的其他窗口中显示帮助.为了摆脱它,我必须更改窗口/缓冲区去那里,键入"q",然后更改回我原来的工作缓冲区.

有没有办法在代码中以某种方式执行此操作?我知道如何保存 - 偏移,切换缓冲区等,但是当我在另一个缓冲区中时,我不知道如何将"q"发送到迷你缓冲区/ emacs.谢谢

Jul*_*les 5

help-window-select变量可能正是你想要的.如果将其值设置为true,(setq help-window-select t)则在通过其中一个帮助命令打开时,将自动选择帮助窗口.然后,您可以按q退出退出并返回原始缓冲区.还有很多其他选项,所以你也应该检查一下.

对于apropos窗口或display-buffer您使用的任何窗口都可以使用.

(add-to-list 'display-buffer-alist
         '("*Apropos*" display-buffer-same-window))
Run Code Online (Sandbox Code Playgroud)

display-buffer-same-window是许多人的一种选择; 它在当前窗口中打开缓冲区.通过查找display-buffer函数的文档可以看到其他可能的选项.


Aar*_*ris 1

这是我对这个问题的解决方案。我将此命令绑定到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)))))
Run Code Online (Sandbox Code Playgroud)