如何更改Elpy自动补全框的颜色,并不优先显示私有变量

1 投票
1 回答
1588 浏览
提问于 2025-04-18 14:57

我正在尝试在Ubuntu 14.04上运行Emacs 24.3.1,并为Python开发进行配置,使用的是elpy来实现自动补全。目前我遇到了两个问题。你可以在这个截图中看到这两个问题:

screenshot.

首先,颜色方案让我觉得很难使用;其次,私有方法总是排在列表的最前面。

我在emacs初始化文件中的相关代码是:

;;pop-ups                                                                                             
(require 'popup)

;;;python-mode                                                                                        
(require 'package)
(add-to-list 'package-archives
         '("elpy" . "http://jorgenschaefer.github.io/packages/"))
(elpy-enable)
;; Fixing a key binding bug in elpy                                                                   
(define-key yas-minor-mode-map (kbd "C-c k") 'yas-expand)
(define-key global-map (kbd "C-c o") 'iedit-mode)
;;Use jedi for autocomplete                                                                           
(setq elpy-rpc-backend "jedi")

(setq py-install-directory "~/.emacs.d/python-mode.el-6.1.3")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)

; use IPython                                                                                         
(setq-default py-shell-name "ipython")
(setq-default py-which-bufname "IPython")
; use the wx backend, for both mayavi and matplotlib                                                  
(setq py-python-command-args
  '("--gui=wx" "--pylab=wx" "-colors" "Linux"))
(setq py-force-py-shell-name-p t)

; switch to the interpreter after executing code                                                      
(setq py-shell-switch-buffers-on-execute-p t)
(setq py-switch-buffers-on-execute-p t)
; don't split windows                                                                                 
(setq py-split-windows-on-execute-p nil)
; try to automagically figure out indentation                                                         
(setq py-smart-indentation t)
;; Jedi backend                                                                                       
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t) ;optional                                                               
(add-hook 'python-mode-hook 'auto-complete-mode)
(add-hook 'python-mode-hook 'jedi:ac-setup)

如果有人能帮我解决这两个问题,我将非常感激。

1 个回答

3

这个颜色主题和Elpy使用的补全方法是一样的。如果你升级到了当前的1.5.1版本,那就是company-mode。理论上,这个在深色背景的Emacs下应该能正常工作。你可以先试着把frame-background-mode设置为dark,也许Emacs没有正确识别你的背景颜色(虽然它应该能识别)。如果这样还是不行,你可以通过输入M-x customize-group RET company RET来更改它使用的颜色(也就是“面”),找找名字里带有“face”的选项。

改变补全的顺序就有点复杂了,需要修改Elpy里面的一些代码。我为这个请求创建了一个问题

撰写回答