在emacs中python语法高亮的奇怪问题

时间:2013-06-12 15:23:38

标签: emacs syntax-highlighting font-lock

我使用Emacs 24.3附带的python.el在Windows下为我的Ethon配置了Emacs 24.3,以下是我在init.el中进行python IDE配置的代码片段

;;; python IDE
;;; setup jedi and autocomplete for python
(require 'jedi)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys 1)
(setq jedi:tooltip-method nil)
(add-hook 'python-mode-hook 'auto-complete-mode)
;; (add-hook 'after-init-hook #'global-flycheck-mode) ; flycheck for python
;;; setup ipython for default interpreter
(require 'python)
(require 'ein)
;;; setup ein for ipython notebook support
(setq ein:use-auto-complete-superpack t)
(add-hook 'ein:connect-mode-hook 'ein:jedi-setup)
(setq python-shell-interpreter "C:/Python27/python")
(setq python-shell-interpreter-args "-i C:/Python27/Scripts/ipython-script.py --pylab")
(setq python-shell-prompt-regexp "In \\[[0-9]+\\]: ")
(setq python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: ")
(setq python-shell-completion-setup-code 
      "from IPython.core.completerlib import module_completion")
(setq python-shell-completion-module-string-code 
      "';'.join(module_completion('''%s'''))\n")
(setq python-shell-completion-string-code 
    "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")

它工作正常,但我的语法高亮显示奇怪的问题,如图所示。左侧的一些变量突出显示为红色,有些变量未突出显示... 那有什么不对?

Emacs Python mode screenshot

1 个答案:

答案 0 :(得分:0)

python.el highlihghts左侧的任务以不同的颜色。众所周知,它不适用于复杂的[1]。但看起来您展示的示例很简单(例如,第537行xfast_image)。如果您有Python代码片段来重现该问题,发送错误报告将有助于Emacs开发人员[2]。