[Top][All Lists]

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

[Emacs-diffs] emacs-25 66d556b: Fix eldoc-related freezes in python mode

From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-25 66d556b: Fix eldoc-related freezes in python mode
Date: Fri, 10 Jun 2016 09:08:52 +0000 (UTC)

branch: emacs-25
commit 66d556b5187d768bbd233513b54dcb4beaa90c6d
Author: Jules Tamagnan <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix eldoc-related freezes in python mode
    * lisp/progmodes/python.el (python-eldoc-get-doc): New defvar.
    (python-eldoc-function-timeout-permanent): New defcustoms.
    (python-eldoc-function): If python-eldoc--get-doc-at-point times
    out, effectively turn off ElDoc in current buffer.  (Bug#23609)
 lisp/progmodes/python.el |   39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 41d3e1c..49f7bcf 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -4292,12 +4292,47 @@ returns will be used.  If not FORCE-PROCESS is passed 
         (unless (zerop (length docstring))
+(defvar-local python-eldoc-get-doc t
+  "Non-nil means eldoc should fetch the documentation
+  automatically. Set to nil by `python-eldoc-function' if
+  `python-eldoc-function-timeout-permanent' is non-nil and
+  `python-eldoc-function' times out.")
+(defcustom python-eldoc-function-timeout 1
+  "Timeout for `python-eldoc-function' in seconds."
+  :group 'python
+  :type 'integer
+  :version "25.1")
+(defcustom python-eldoc-function-timeout-permanent t
+  "Non-nil means that when `python-eldoc-function' times out
+`python-eldoc-get-doc' will be set to nil"
+  :group 'python
+  :type 'boolean
+  :version "25.1")
 (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 if
+`python-eldoc-function-timeout-permanent' is non-nil
+`python-eldoc-get-doc' will be set to nil and eldoc will no
+longer return the documentation at the point automatically.
+Set `python-eldoc-get-doc' to t to reenable eldoc documentation
+  (when python-eldoc-get-doc
+    (with-timeout (python-eldoc-function-timeout
+                   (if python-eldoc-function-timeout-permanent
+                       (progn
+                         (message "Eldoc echo-area display muted in this 
buffer, see `python-eldoc-function'")
+                         (setq python-eldoc-get-doc nil))
+                     (message "`python-eldoc-function' timed out, see 
+      (python-eldoc--get-doc-at-point))))
 (defun python-eldoc-at-point (symbol)
   "Get help on SYMBOL using `help'.

reply via email to

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