Emacs Lisp Buffer out of focus function?

2019-03-02 15:31发布

Is there an emacs lisp function that will allow me to tell if a buffer is out of focus?

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.

Also is it possible to get rid of the *Messages* Buffer as well? I haven't found a function that would kill it.

3条回答
手持菜刀,她持情操
2楼-- · 2019-03-02 16:06

You can try PopWin, It lets you specify buffers that will open in a special window. This window closes when the frame gets out of focus or when you press C-g

查看更多
ら.Afraid
3楼-- · 2019-03-02 16:19

You can test if a buffer is the buffer that currently has focus with current-buffer. For example, to test if *scratch* has the focus,

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

The *Messages* buffer is an important part of emacs. It's the implicit target of the message function that is used to log various bits of information from all over. You can kill *Messages* like any other buffer, but it will just get recreated the next time something calls message. You could probably silence it by redefining the message function, but I'd question the point of doing so.

查看更多
再贱就再见
4楼-- · 2019-03-02 16:20

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:

(require 'ido)
(setq ido-ignore-buffers '("^\*Messages\*"))
查看更多
登录 后发表回答