aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorJules Tamagnan2016-06-10 12:08:29 +0300
committerEli Zaretskii2016-06-10 12:08:29 +0300
commit66d556b5187d768bbd233513b54dcb4beaa90c6d (patch)
treeaeca525a52d33c82892d5d7c161f5f377bf7d7fc /lisp/progmodes/python.el
parentd59bcbc00bc70f101492a80ea48964b2dd5d337d (diff)
downloademacs-66d556b5187d768bbd233513b54dcb4beaa90c6d.tar.gz
emacs-66d556b5187d768bbd233513b54dcb4beaa90c6d.zip
Fix eldoc-related freezes in python mode
* lisp/progmodes/python.el (python-eldoc-get-doc): New defvar. (python-eldoc-function-timeout) (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)
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el39
1 files changed, 37 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 41d3e1c7310..49f7bcf5df9 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 what
4292 (unless (zerop (length docstring)) 4292 (unless (zerop (length docstring))
4293 docstring))))) 4293 docstring)))))
4294 4294
4295(defvar-local python-eldoc-get-doc t
4296 "Non-nil means eldoc should fetch the documentation
4297 automatically. Set to nil by `python-eldoc-function' if
4298 `python-eldoc-function-timeout-permanent' is non-nil and
4299 `python-eldoc-function' times out.")
4300
4301(defcustom python-eldoc-function-timeout 1
4302 "Timeout for `python-eldoc-function' in seconds."
4303 :group 'python
4304 :type 'integer
4305 :version "25.1")
4306
4307(defcustom python-eldoc-function-timeout-permanent t
4308 "Non-nil means that when `python-eldoc-function' times out
4309`python-eldoc-get-doc' will be set to nil"
4310 :group 'python
4311 :type 'boolean
4312 :version "25.1")
4313
4295(defun python-eldoc-function () 4314(defun python-eldoc-function ()
4296 "`eldoc-documentation-function' for Python. 4315 "`eldoc-documentation-function' for Python.
4297For this to work as best as possible you should call 4316For this to work as best as possible you should call
4298`python-shell-send-buffer' from time to time so context in 4317`python-shell-send-buffer' from time to time so context in
4299inferior Python process is updated properly." 4318inferior Python process is updated properly.
4300 (python-eldoc--get-doc-at-point)) 4319
4320If `python-eldoc-function-timeout' seconds elapse before this
4321function returns then if
4322`python-eldoc-function-timeout-permanent' is non-nil
4323`python-eldoc-get-doc' will be set to nil and eldoc will no
4324longer return the documentation at the point automatically.
4325
4326Set `python-eldoc-get-doc' to t to reenable eldoc documentation
4327fetching"
4328 (when python-eldoc-get-doc
4329 (with-timeout (python-eldoc-function-timeout
4330 (if python-eldoc-function-timeout-permanent
4331 (progn
4332 (message "Eldoc echo-area display muted in this buffer, see `python-eldoc-function'")
4333 (setq python-eldoc-get-doc nil))
4334 (message "`python-eldoc-function' timed out, see `python-eldoc-function-timeout'")))
4335 (python-eldoc--get-doc-at-point))))
4301 4336
4302(defun python-eldoc-at-point (symbol) 4337(defun python-eldoc-at-point (symbol)
4303 "Get help on SYMBOL using `help'. 4338 "Get help on SYMBOL using `help'.