【问题标题】:Making Python Interactive Mode of Emacs Highlight and Indent制作 Emacs 的 Python 交互模式高亮和缩进
【发布时间】:2010-01-14 10:09:49
【问题描述】:

我正在使用 Emacs 23 和 python-mode 5.1.0 来编辑我的 python 程序。有时在编写程序时,我想运行一个小的一次性 python 脚本,所以我运行交互式移动(C-c!)。这很好,但它既不缩进也不突出显示代码,如果我尝试在其中运行 python 模式,它不再计算。那么,如何设置缩进和高亮呢?

【问题讨论】:

    标签: python emacs


    【解决方案1】:

    将这些添加到我的 .emacs 似乎已经完成了。

    它在通知中检查缓冲区名称的位置可能会更好地作为对 set-pycomint-keywords 设置的缓冲区局部变量的测试,但你明白了。

    (defun set-pycomint-keywords ()
      (setq font-lock-keywords      python-font-lock-keywords))
    
    (add-hook 'py-shell-hook 'set-pycomint-keywords)
    
    
    
     (defadvice comint-send-input (around block-comint-formatting activate)
      (if (string= (buffer-name) "*Python*")
          (letf (((symbol-function 'add-text-properties) (lambda (x y z) nil)))
            ad-do-it))
      ad-do-it)
    

    【讨论】:

    • 我试过了,它确实正确地为文本着色。但是,当我编写 def fn(a): 并按 Enter 时,它不会进入 ... 而是总是引发缩进错误。
    【解决方案2】:

    我现在没有时间尝试,但我发现你可以在按 C-c 时替换 python shell 有了这个应该更强大:

    http://ipython.scipy.org/moin/

    有时间我会试试的

    【讨论】:

    • 这没有回答问题。
    • 很高兴知道这一点,我会尝试一下,但它不会改变 emacs 显示 shell 的方式。
    猜你喜欢
    • 2020-11-09
    • 1970-01-01
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    相关资源
    最近更新 更多