如何使窗口移动命令忽略某个窗口? [英] How can I make window movement commands ignore a certain window?

查看:146
本文介绍了如何使窗口移动命令忽略某个窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我正在写的实际代码的一个缓冲区。

  2. 用于所述代码的单元测试的一个缓冲区。

  3. 显示单元测试结果的第三个缓冲区。当我运行单元测试 Cx SPACE 时,这个缓冲区成为
    以下的两个缓冲区。

如何禁用此第三个缓冲区,以便当我按 Cx o 时,我只是在缓冲区1和缓冲区2之间切换?目前,我在缓冲区1,缓冲区2,缓冲区3,缓冲区1等之间进行切换。具体来说,我希望 Cx o 仅在缓冲区1和2之间切换。



谢谢。

解决方案

一般的解决方案(可以看看)如下:

 (defvar ignore-windows-contained-buffers-matching-res'(\\ *帮助)
指定要跳过的窗口的正则表达式列表(如果窗口包含缓冲区匹配,跳过))

(defadvice其他窗口(在其他窗口忽略含Windows的激活之前)
跳过包含与之匹配的缓冲区的窗口$($($($($)$($)$($)$($($) (win(next-window))
(bname(buffer-name(window-buffer win))))
(当(某些'identity(mapcar'(lambda(re)
string-match re bname))
ignore-windows-contained-buffers-matching-res))
(ad-set-arg 0 2)))))

将变量自定义为与要跳过的缓冲区名称匹配的正则表达式。


So I generally have 3 buffers open in Emacs.

  1. One buffer for the actual code I am writing.
  2. One buffer for the unit test for said code.
  3. A third buffer that displays the results of the unit test. This buffer comes into being below the two other buffers when I run my unit test C-x SPACE.

How do I disable this third buffer such that when I press C-x o I am only switching between buffer 1 and buffer 2? Currently, I switch between buffer 1, then buffer 2, then buffer 3, then buffer 1, etc. To be specific, I want C-x o to only switch between buffer 1 and 2.

Thank you.

解决方案

A general solution to this (can look) something like the following:

(defvar ignore-windows-containing-buffers-matching-res '("\\*Help")
      "List of regular expressions specifying windows to skip (if window contains buffer that matches, skip)")

(defadvice other-window (before other-window-ignore-windows-containing activate)
  "skip over windows containing buffers which match regular expressions in 'ignore-windows-containing-buffers-matching-res"
  (if (and (= 1 (ad-get-arg 0)) (interactive-p))
      (let* ((win (next-window))
             (bname (buffer-name (window-buffer win))))
        (when (some 'identity (mapcar '(lambda (re)
                                        (string-match re bname))
                                     ignore-windows-containing-buffers-matching-res))
          (ad-set-arg 0 2)))))

Customize the variable to be a regular expression matching the buffer names you want to skip.

这篇关于如何使窗口移动命令忽略某个窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆