bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23609: 25.0.92; Python eldoc freeze


From: Jules Tamagnan
Subject: bug#23609: 25.0.92; Python eldoc freeze
Date: Fri, 27 May 2016 16:19:57 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: Jules Tamagnan <address@hidden>
>> Cc: address@hidden,  address@hidden
>> Date: Fri, 27 May 2016 15:43:18 -0400
>>
>> > Once again, perhaps I misunderstand the nature of the problem, but
>> > doesn't it happen only when the Python interpreter is busy doing
>> > something when the eldoc function is invoked?  If so, then the next
>> > time eldoc is invoked, the Python interpreter might not be busy, and
>> > the feature will work without hanging, right?  Or am I missing
>> > something?
>>
>> No that's exactly correct. I'm just thinking of it from the point of
>> view that perhaps somebody is plotting a graph from the interpreter
>> which causes the interpreter to be busy. Then while having that graph
>> open they would still like to be able to edit their code (I have been in
>> this situation dozens of times). Or if the code they are running takes a
>> a minute or two there is a good chance that they would want to edit some
>> of the code while it is running. In those scenarios I feel like it makes
>> sense to stop eldoc from doing the automatic checking permanently for
>> that buffer because otherwise my work would be constantly interrupted.
>
> OK, so let's go with your suggestion, but make that message we agreed
> should be added say something like
>
>   ElDoc mode echo-area display turned off; type .... to turn on
>
> where "..." stands for whatever needs to be done to turn it back on
> again.
>
> Also, I do think a defcustom is due instead of a hardwired constant of
> 1 sec.
>
> Could you please augment your patch along these lines?
>
> Thanks.

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.

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.

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

Thanks





reply via email to

[Prev in Thread] Current Thread [Next in Thread]