Aquamacs:C-c C-c(python mode)上的窗口交换

2024-10-03 04:37:32 发布

您现在位置:Python中文网/ 问答频道 /正文

如果我在这里使用了不正确的术语,我很抱歉,我使用emacs才几个月。在

我刚在我重新格式化的macbook上重新安装了Aquamac,但问题很奇怪。在

我打开一个.py文件,然后使用C-C!打开python shell。因此,正如预期的那样,.py文件位于顶部窗口,pythonshell位于底部窗口。在

如果我在.py文件中运行C-C-C(py execute buffer),两个窗口交换位置。我的意思是,.py文件缓冲区在新缓冲区的底部窗口打开,而PythonShell在新缓冲区的顶部窗口打开。所以基本上,他们交换位置。反复使用C-C C-C再次交换窗口。。。所以他们在改变位置。另外,两个窗口(顶部和底部)的选项卡中都有缓冲区(.py文件和pythonshell)。在

我还没有对默认设置做任何修改,而且2.3a和2.3都有问题(2.3以前在机器上,没有这个问题,所以我尝试回滚。。。无济于事)。在

有人知道如何阻止这种行为吗?提前谢谢!在


Tags: 文件py机器executebuffershell选项卡缓冲区
3条回答

您也可以尝试将以下内容添加到emacs init文件中:

(setq py-split-windows-on-execute-p nil)

这将防止当前窗口在运行任何py execute-*后分裂。(这也意味着,如果pythonshell还没有出现在您的某个窗口中,它就不会出现。)

我不使用Aquamacs,也无法重现您所描述的行为,不过,请尝试使用此代码将任一窗口切换为“专用”。在启动并运行emacs时,我首先要做的就是将窗口锁定到缓冲区。也许这对你有帮助。在

将代码添加到“.emacs”中,然后“标记”(选择)区域的-<;key down>;,然后“M-x eval region”对其求值。或者保存并重新启动emacs。在

(global-set-key [pause] 'window-dedication-toggle)

(defun window-dedication-toggle (&optional window force quiet)
  "toggle or ensure the 'dedicated' state for a window"
  (interactive)
    (let* ((toggle t) (window (if window window (selected-window))) (dedicated (window-dedicated-p window)))
      (cond ((equal force "on") (setq toggle (eq dedicated nil))) 
            ((equal force "off") (setq toggle (eq dedicated t))))
      (if toggle (progn
        (setq dedicated (not dedicated))
        (set-window-dedicated-p window dedicated)
        (if (not quiet)
        (message "window %sdedicated to %s" (if (not dedicated) "no longer " "") (buffer-name)))))))

将以下内容添加到Aquamacs中的Emacs init文件中,以防止它交换缓冲区:

(defadvice py-execute-buffer
  (around keep-buffers-same activate)
  "Don't swap buffers in Aquamacs."
  (save-window-excursion 
    ad-do-it))

相关问题 更多 >