简体   繁体   English

Emacs Lisp缓冲区失焦功能?

[英]Emacs Lisp Buffer out of focus function?

Is there an emacs lisp function that will allow me to tell if a buffer is out of focus? 是否有emacs lisp函数,可以让我判断一个缓冲区是否失焦?

I am trying to write a hook that will get rid of the semantics *possible completion's* buffer right after it is out of focus. 我正在尝试编写一个钩子,它将在焦点失效后摆脱语义*possible completion's*缓冲区。

Also is it possible to get rid of the *Messages* Buffer as well? 还有可能摆脱*Messages* Buffer吗? I haven't found a function that would kill it. 我还没有发现会杀死它的功能。

You can test if a buffer is the buffer that currently has focus with current-buffer . 您可以测试缓冲区是否是当前具有current-buffer焦点current-buffer For example, to test if *scratch* has the focus, 例如,要测试*scratch*是否具有焦点,

(eq 
 (current-buffer) 
 (get-buffer "*scratch*"))

The *Messages* buffer is an important part of emacs. *Messages*缓冲区是emacs的重要组成部分。 It's the implicit target of the message function that is used to log various bits of information from all over. 它是message函数的隐含目标,用于记录来自全世界的各种信息。 You can kill *Messages* like any other buffer, but it will just get recreated the next time something calls message . 您可以像其他任何缓冲区一样杀死*Messages* ,但是下次有人调用message时它会被重新创建。 You could probably silence it by redefining the message function, but I'd question the point of doing so. 您可能可以通过重新定义message函数来使其静音,但是我对此有疑问。

Related to your second question, Also is it possible to get rid of the Messages Buffer as well . 与您的第二个问题相关, 也可以删除消息缓冲区 If you're using ido-mode (and everyone should be using it!), you can hide the *Messages* buffer from the buffer listing with the following elisp: 如果您正在使用ido-mode (并且每个人都应该使用它!),您可以使用以下elisp从缓冲区列表中隐藏*Messages*缓冲区:

(require 'ido)
(setq ido-ignore-buffers '("^\*Messages\*"))

You can try PopWin , It lets you specify buffers that will open in a special window. 您可以尝试使用PopWin ,它允许您指定将在特殊窗口中打开的缓冲区。 This window closes when the frame gets out of focus or when you press Cg 当框架失焦或按Cg时,此窗口关闭

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM