Subject: Re: bug#23609: 25.0.92; Python eldoc freeze

From: Eli Zaretskii <[email-masked]>
Date: Sat, 28 May 2016 10:53:38 +0300

> From: Jules Tamagnan <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Fri, 27 May 2016 16:19:57 -0400
> 
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 5aeefe4..46c3bd9 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -4293,12 +4293,29 @@ python-eldoc--get-doc-at-point
>          (unless (zerop (length docstring))
>            docstring)))))
> 
> +(defvar-local python-eldoc--get-doc t
> +  "If eldoc should be used to get the documentation automatically")
> +
> +(defcustom python-eldoc-function-timeout 1
> +  "Timeout for python-eldoc-function in seconds."
> +  :group 'python
> +  :type 'integer)
> +
>  (defun python-eldoc-function ()
>    "`eldoc-documentation-function' for Python.
>  For this to work as best as possible you should call
>  `python-shell-send-buffer' from time to time so context in
> -inferior Python process is updated properly."
> -  (python-eldoc--get-doc-at-point))
> +inferior Python process is updated properly.
> +
> +If `python-eldoc-function-timeout' seconds elapse before this
> +function returns then `python-eldoc--get-doc' will be set to nil
> +and eldoc will no longer return the documentation at the point
> +automatically."
> +  (when python-eldoc--get-doc
> +    (with-timeout (python-eldoc-function-timeout
> +                   (message "Eldoc mode echo-area display turned off in current buffer; eval (setq python-eldoc--get-doc t) to turn on")
> +                   (setq python-eldoc--get-doc nil))
> +      (python-eldoc--get-doc-at-point))))
> 
>  (defun python-eldoc-at-point (symbol)
>    "Get help on SYMBOL using `help'.
> 
> Here was my rendition of the task at hand.

Thanks.  We should try making the message text shorter, so it fits on
a single line.

> We could also perhaps make it such that if the timeout variable were
> negative then instead of permanently stopping eldoc it would only
> return, like you had suggested. A boolean defcustom could also be
> used for that if we want.

I don't see any significant advantage either way.

> Also 'python-eldoc--get-doc' could be renamed to not be private if we
> expect somebody to want to change it

Yes, that variable should not be private if users are expected to set
it.  Alternatively, we could add a simple command to set the variable
non-nil, which might also help making the message text shorter.