Elpy: What to do to get eldoc documentation via company?

Created on 3 May 2015  路  4Comments  路  Source: jorgenschaefer/elpy

In the examples on the Internet, there is a documentation appears next to the autocomplete menu, if it is possible. I have not this by default

Elpy Configuration

Virtualenv........: None
RPC Python........: 3.4.0 (/usr/bin/python3)
Interactive Python: ipython3 (/usr/bin/ipython3)
Emacs.............: 24.3.1
Elpy..............: 1.8.0
Jedi..............: 0.9.0
Rope..............: 0.9.4-1
Importmagic.......: 0.1.3
Syntax checker....: flake8 (/usr/local/bin/flake8)
(require 'elpy)
(elpy-enable)
(elpy-use-ipython)
(setq elpy-rpc-backend "jedi")

(defun prelude-personal-python-mode-defaults ()
  "Personal defaults for Python programming."
  ;; Enable elpy mode
  (elpy-mode)
  ;; Jedi backend                                                                                       
  ;; (jedi:setup)
  ;; (setq jedi:complete-on-dot t) ;optional                                                               
  ;; (auto-complete-mode)
  ;; (jedi:ac-setup)
  ;; (setq elpy-rpc-python-command "python3") 
  ;; (python-shell-interpreter "ipython3")
  )

(setq prelude-personal-python-mode-hook 'prelude-personal-python-mode-defaults)

(add-hook 'python-mode-hook (lambda ()
                              (run-hooks 'prelude-personal-python-mode-hook)))

(custom-set-variables
 '(company-auto-complete t)
 '(eldoc-echo-area-use-multiline-p t)
 '(elpy-mode-hook (quote (subword-mode hl-line-mode)))
 '(elpy-rpc-python-command "python3")
 '(python-shell-interpreter "ipython3")
)

Installed package: company , company-jedi, elpy

Question

Most helpful comment

That example uses a pretty old version of Elpy, which still used the auto-complete library. Due to various problems with auto-complete, Elpy moved to company-mode, which does not by default have these docstring popups. There are two options for you.

First, you can live without the popups. C-h on an option will display the full docstring in another buffer, so you only lose the automatic popup, which can even get annoying at times.

Second, you can install the company-quickhelp package, which replicates the pop-up behavior of auto-complete for company-mode. This is another external package, but it should do what you want.

Let me know if this solves your question, or if there are any further problems :-)

All 4 comments

That example uses a pretty old version of Elpy, which still used the auto-complete library. Due to various problems with auto-complete, Elpy moved to company-mode, which does not by default have these docstring popups. There are two options for you.

First, you can live without the popups. C-h on an option will display the full docstring in another buffer, so you only lose the automatic popup, which can even get annoying at times.

Second, you can install the company-quickhelp package, which replicates the pop-up behavior of auto-complete for company-mode. This is another external package, but it should do what you want.

Let me know if this solves your question, or if there are any further problems :-)

Compile Emacs 24.4 on ubuntu 14.04

GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)

Elpy Configuration
Virtualenv........: None
RPC Python........: 3.4.0 (/usr/bin/python3)
Interactive Python: ipython (/usr/bin/ipython)
Emacs.............: 24.4.1
Elpy..............: 1.8.0
Jedi..............: 0.9.0
Rope..............: 0.9.4-1
Importmagic.......: 0.1.3
Syntax checker....: flake8 (/usr/local/bin/flake8)

install packages:

  company            20150428.... installed             Modular text completion framework
  company-jedi       20150304.351 installed             company-mode completion back-end for Python JEDI
  company-quickhelp  20150501.609 installed             Popup documentation for completion candidates
  concurrent         20150309.... installed             Concurrent utility functions for emacs lisp
  ctable             20140304.... installed             Table component for Emacs Lisp
  deferred           20150309.... installed             Simple asynchronous functions for emacs lisp
  elpy               1.8.0        installed             Emacs Python Development Environment
  epc                20140609.... installed             A RPC stack for the Emacs Lisp
  find-file-in-pr... 20150421.436 installed             Find files in a project quickly.
  highlight-inden... 20150307.208 installed             Minor modes for highlighting indentation
  idomenu            0.1          installed             imenu tag selection with ido
  jedi-core          20150422.209 installed             Common code of jedi.el and company-jedi.el
  pos-tip            20150318.813 installed             Show tooltip at point
  python-environment 20150310.153 installed             virtualenv API for Emacs Lisp
  pyvenv             20150503.941 installed             Python virtual environment interface
  yasnippet          20150415.244 installed             Yet another snippet extension for Emacs.

my configure

(when (>= emacs-major-version 24)
  (require 'package) ;; You might already have this line
  ;; For important compatibility libraries like cl-lib
  (add-to-list
   'package-archives 
   '("melpa" . "http://melpa.org/packages/") 
   t)
  (add-to-list
   'package-archives
   '("gnu" . "http://elpa.gnu.org/packages/")
   t)
  ;; 袛芯斜邪胁谢褟械屑 锌邪泻械褌 褌邪泻 泻邪泻 胁 24.4 械谐芯 薪械褌 芯褌 褋谢芯胁邪 褋芯胁褋械屑
  (add-to-list
   'package-archives
   '("elpy" . "http://jorgenschaefer.github.io/packages/")
   t)
  (package-initialize) ;; You might already have this line
  )


;; Elpy, the Emacs Lisp Python Environment
;; Initialize package mode along with all the installed packages
(setenv "PYTHONPATH" "/usr/bin/python3") 


(require 'elpy)
;;(prelude-require-packages '(elpy jedi))
(elpy-enable)
(elpy-use-ipython)
(setq elpy-rpc-backend "jedi")

(defun prelude-personal-python-mode-defaults ()
  "Personal defaults for Python programming."
  ;; Enable elpy mode
  (elpy-mode)
  ;; Jedi backend                                                                                       
  ;; (jedi:setup)
  ;; (setq jedi:complete-on-dot t) ;optional                                                               
  ;; (auto-complete-mode)
  ;; (jedi:ac-setup)
  (setq elpy-rpc-python-command "python3") 
  ;; (python-shell-interpreter "ipython3")
  )

(setq prelude-personal-python-mode-hook 'prelude-personal-python-mode-defaults)

(add-hook 'python-mode-hook (lambda ()
                              (run-hooks 'prelude-personal-python-mode-hook)))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(company-auto-complete t)
 '(elpy-mode-hook (quote (subword-mode hl-line-mode)))
 '(elpy-rpc-python-command "python3")
 '(python-shell-interpreter "ipython3"))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

Error output when I use F1 or C-d

Output from Backend

There was some unexpected output from the Elpy backend. This is
usually some module that does not use correct logging, but might
indicate a configuration problem.

Output

** (__main__.py:9285): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-zFz4kAJHDm:

Hello!
I hope the company-quickhelp module works as you expected?

The output you see there is from some module you are using which Elpy does not control. Ideally, modules should not simply write to stdout but use the logging module, but well, not all modules are well-behaved like that.

Sadly, Elpy can not distinguish if output from the subprocess is simply a status message or if it is an indicate of an error, so it shows the output to you. If it's expected output like this, you can simply bury the buffer and ignore it.

Does this help?

Activate company-quickhelp-mode and now all works fine.

(defun prelude-personal-python-mode-defaults ()
  "Personal defaults for Python programming."
  ;; Enable elpy mode
  (elpy-mode)
  ;; Jedi backend                                                                                       
  ;; (jedi:setup)
  ;; (setq jedi:complete-on-dot t) ;optional                                                               
  ;; (auto-complete-mode)
  ;; (jedi:ac-setup)
  (setq elpy-rpc-python-command "python3") 
  ;; (python-shell-interpreter "ipython3")
  (company-quickhelp-mode)
  )

(setq prelude-personal-python-mode-hook 'prelude-personal-python-mode-defaults)

(add-hook 'python-mode-hook (lambda ()
                              (run-hooks 'prelude-personal-python-mode-hook)))

Thank you for your help and suggestive answers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kirk86 picture kirk86  路  5Comments

rthompsonj picture rthompsonj  路  6Comments

Arseny-N picture Arseny-N  路  4Comments

SirSharpest picture SirSharpest  路  6Comments

twangnh picture twangnh  路  6Comments