tkf / emacs-jedi

Python auto-completion for Emacs
http://tkf.github.io/emacs-jedi/latest/
666 stars 89 forks source link

minibuffer switching between function signature and description #337

Open DiogoFerrari opened 5 years ago

DiogoFerrari commented 5 years ago

My minibuffer keeps switching between showing the function signature and the first line of the description of the function. I want to have only the former. Any idea of what is happening?

immerrr commented 5 years ago

It could be a weird interaction between jedi showing the signature and python-mode's builtin eldoc backend that tries to show the documentation in the same minibuffer. I have

(setq eldoc-documentation-function nil)

in my python-mode-hook. Could be that. If not, I'm going to need a repro to tell more.

DiogoFerrari commented 5 years ago

I am not using eldoc. A repro code is difficult to get for this case.

immerrr commented 5 years ago

Starting with Emacs 25.1 global-eldoc-mode is enabled by default, so it could be active unless you specifically disabled it. Other than that, it's difficult to say what's going on without a repro, but most likely it's unrelated to jedi either. The only places where in jedi sources the docstrings are referred are in jedi:show-doc function that shows the docstring in a separate buffer and in the auto-complete backend implementation.

tangxinfa commented 4 years ago

For anyone who prefer integration jedi with eldoc:

(defun jedi:get-documentation-deferred ()
  (deferred:$
    (jedi:call-deferred 'get_definition)
    (deferred:nextc it
      (lambda (reply)
        (cl-loop for def in reply
                 do (cl-destructuring-bind (&key doc description full_name &allow-other-keys)
                        def
                      (when (or doc description)
                        (return
                         (string-trim
                          (concat
                           (propertize (or full_name "") 'face 'font-lock-variable-name-face)
                           "\n\n"
                           (or doc description)))))))))))
(cl-defun jedi:get-documentation-sync ()
  (epc:sync
   (jedi:get-epc)
   (deferred:timeout 500 nil (jedi:get-documentation-deferred))))

(setq jedi:get-in-function-call--d t) ; disable jedi's popup documentation
(add-hook 'python-mode-hook 
          (lambda ()
            (setq-local eldoc-documentation-function #'jedi:get-documentation-sync)))