aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2015-02-07 18:39:07 -0300
committerFabián Ezequiel Gallina2015-02-07 18:39:07 -0300
commit2155973e5e35d11a50ce6773bb34d5df68beea57 (patch)
tree682fa184b144ec057533839858c6617c8d166b46 /lisp/progmodes/python.el
parent2d467a0ff0cd446ec0d83044a0be819cbf874cdf (diff)
downloademacs-2155973e5e35d11a50ce6773bb34d5df68beea57.tar.gz
emacs-2155973e5e35d11a50ce6773bb34d5df68beea57.zip
python.el: Keep eldoc visible while typing args.
Fixes: debbugs:19637 * lisp/progmodes/python.el (python-eldoc--get-symbol-at-point): New function. (python-eldoc--get-doc-at-point, python-eldoc-at-point): Use it. * test/automated/python-tests.el (python-eldoc--get-symbol-at-point-1) (python-eldoc--get-symbol-at-point-2) (python-eldoc--get-symbol-at-point-3) (python-eldoc--get-symbol-at-point-4): New tests.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 3399429538f..72a76a461a6 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3921,15 +3921,29 @@ See `python-check-command' for the default."
3921 :type 'string 3921 :type 'string
3922 :group 'python) 3922 :group 'python)
3923 3923
3924(defun python-eldoc--get-symbol-at-point ()
3925 "Get the current symbol for eldoc.
3926Returns the current symbol handling point within arguments."
3927 (save-excursion
3928 (let ((start (python-syntax-context 'paren)))
3929 (when start
3930 (goto-char start))
3931 (when (or start
3932 (eobp)
3933 (memq (char-syntax (char-after)) '(?\ ?-)))
3934 ;; Try to adjust to closest symbol if not in one.
3935 (python-util-forward-comment -1)))
3936 (python-info-current-symbol t)))
3937
3924(defun python-eldoc--get-doc-at-point (&optional force-input force-process) 3938(defun python-eldoc--get-doc-at-point (&optional force-input force-process)
3925 "Internal implementation to get documentation at point. 3939 "Internal implementation to get documentation at point.
3926If not FORCE-INPUT is passed then what `python-info-current-symbol' 3940If not FORCE-INPUT is passed then what `python-eldoc--get-symbol-at-point'
3927returns will be used. If not FORCE-PROCESS is passed what 3941returns will be used. If not FORCE-PROCESS is passed what
3928`python-shell-get-process' returns is used." 3942`python-shell-get-process' returns is used."
3929 (let ((process (or force-process (python-shell-get-process)))) 3943 (let ((process (or force-process (python-shell-get-process))))
3930 (when process 3944 (when process
3931 (let ((input (or force-input 3945 (let ((input (or force-input
3932 (python-info-current-symbol t)))) 3946 (python-eldoc--get-symbol-at-point))))
3933 (and input 3947 (and input
3934 ;; Prevent resizing the echo area when iPython is 3948 ;; Prevent resizing the echo area when iPython is
3935 ;; enabled. Bug#18794. 3949 ;; enabled. Bug#18794.
@@ -3949,7 +3963,7 @@ inferior Python process is updated properly."
3949 "Get help on SYMBOL using `help'. 3963 "Get help on SYMBOL using `help'.
3950Interactively, prompt for symbol." 3964Interactively, prompt for symbol."
3951 (interactive 3965 (interactive
3952 (let ((symbol (python-info-current-symbol t)) 3966 (let ((symbol (python-eldoc--get-symbol-at-point))
3953 (enable-recursive-minibuffers t)) 3967 (enable-recursive-minibuffers t))
3954 (list (read-string (if symbol 3968 (list (read-string (if symbol
3955 (format "Describe symbol (default %s): " symbol) 3969 (format "Describe symbol (default %s): " symbol)