简体   繁体   English

杀死缓冲区有时会将焦点切换到新树窗口

[英]kill-buffer switches focus to neotree window sometimes

And I dont want this behavior. 而且我不想要这种行为。 Actually, not everytime is focus switched. 实际上,并非每次都切换焦点。 For example, buffers like *Help* or *Message* does not have this behavior, this unwanted feature is active only when closing regular file buffers. 例如, *Help**Message*类的缓冲区不具有此行为,该有害功能仅在关闭常规文件缓冲区时才处于活动状态。

How to disable this feature completelly ? 如何完全禁用此功能?

My solution for this problem is simply write my own handler for buffer kill. 对于这个问题,我的解决方案是简单地编写自己的处理程序以消除缓冲区。 Hope it will help someone in future. 希望以后能对某人有所帮助。

(global-set-key (kbd "C-w")
                (lambda ()
                  (interactive)
                  (if (string= (substring (buffer-name) 0 2) " *")
                      (progn
                        (message "You can not kill protected BUFFER"))
                    (progn
                      (if (string= (substring (buffer-name) 0 1) "*")
                          (progn
                            (call-interactively 'kill-buffer))
                        (progn
                          (call-interactively 'kill-buffer)
                          (run-at-time "0.5 sec" nil
                                       (lambda ()
                                         (call-interactively 'windmove-right)))))))))

You need to have installed ace-window package for windmove-right , that feature with protected buffers is not relevant to this answer so you can freely remove it. 您需要为windmove-right安装ace-window软件包,该功能具有受保护的缓冲区与此答案无关,因此您可以自由地删除它。

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

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