简体   繁体   English

Emacs:如何自动以python模式启动python解释器?

[英]Emacs: How can I automatically start a python interpreter in python-mode?

After every Emacs startup in python-mode I need to open the interpreter in a different buffer and change the size of the new buffer that it fits emacs-code-browser's history. 每次以python模式启动Emacs之后,我都需要在其他缓冲区中打开解释器,并更改新缓冲区的大小以适应emacs-code-browser的历史记录。 I want to automate this activity. 我想自动执行此活动。

  • How can I automate that an interactive python shell always appears (after Emacs startup) in an extra buffer like in the screenshot? 如何自动使交互式python shell始终出现(在Emacs启动之后)在屏幕截图中所示的额外缓冲区中?

UPDATE: See below: workgroups.el and emacs-code-browser seem to collide. 更新:参见下文:workgroups.el和emacs-code-browser似乎冲突。 See screenshot 看截图

Before Editing 编辑之前

编辑之前

After Editing 编辑后

编辑后

I use Emacs23, emacs-code-browser and python-mode.el. 我使用Emacs23,emacs代码浏览器和python-mode.el。

UPDATE : I tried to use workgroups.el. 更新 :我尝试使用workgroups.el。 I defined a new python workgroup and added the following line to my .emacs : (wg-load "~/.emacs.d/workgroups/python_workgroup.wg"). 我定义了一个新的python工作组 ,并将以下行添加到我的.emacs中 :(wg-load“〜/ .emacs.d / workgroups / python_workgroup.wg”)。 The windows are, however, messed up. 窗户不过被弄乱了。 You can see it on the screenshot below: 您可以在以下屏幕截图中看到它:

It think that emacs-code-browser and the settings of my workgroup collide. 它认为emacs代码浏览器和我的工作组的设置冲突。 Is there a way to avoid this behavior? 有办法避免这种行为吗? 在此处输入图片说明

also you may try desktop-save-mode: 您也可以尝试使用桌面保存模式:

desktop-save-mode is an interactive autoloaded Lisp function. 桌面保存模式是一种交互式自动加载的Lisp功能。

(desktop-save-mode &optional ARG) (桌面保存模式和可选的ARG)

Toggle desktop saving (Desktop Save mode). 切换桌面保存(桌面保存模式)。 With a prefix argument ARG, enable Desktop Save mode if ARG is positive, and disable it otherwise. 使用前缀参数ARG,如果ARG为正,则启用桌面保存模式,否则禁用它。 If called from Lisp, enable the mode if ARG is omitted or nil. 如果从Lisp调用,则如果ARG被省略或为nil,则启用该模式。

If Desktop Save mode is enabled, the state of Emacs is saved from one session to another. 如果启用了桌面保存模式,则Emacs的状态将从一个会话保存到另一个会话。 See variable desktop-save' and function desktop-read' for details. 有关详细信息,请参见变量“ desktop-save' and function桌面功能读取”。

How about using workgroups.el ? 使用workgroups.el怎么样?
It is used for saving your window configuration which is exactly what you need. 它用于保存您所需的窗口配置。

This way you can create a workgroup called for example Python, adjust buffers (including one containing interactive python shell) and everything and save the group, and next time you just open workgroup Python and all buffers open as they were before. 这样,您可以创建一个名为Python的工作组,调整缓冲区(包括一个包含交互式python shell的缓冲区)并保存所有内容,然后下次打开工作组Python并像以前一样打开所有缓冲区。 If you want it to open automatically when emacs is started, just set your saved Python workgroup as a default workgroup. 如果要在启动emacs时自动打开它,只需将保存的Python工作组设置为默认工作组。

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

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