Commit 15cc40b8 authored by Fabián Ezequiel Gallina's avatar Fabián Ezequiel Gallina Committed by Fabián Ezequiel Gallina
Browse files

Fixed eldoc behavior.

      * python-eldoc-setup-code: The code to get help now uses the
        inspect element. When an object doesn't have documentation and
        if it is callable it returns the signature for it. Also when
        an object does contain documentation it only returns the first
        line.

      * python-eldoc-at-point: has been simplified to just message the
        doc header of objects.

      * python-info-current-defun: was not taking into account the
        current indentation so point was always inside a defun, even
        if the indentation was less or equal than the defun above.
parent 9787f829
...@@ -1924,10 +1924,28 @@ Runs COMMAND, a shell command, as if by `compile'. See ...@@ -1924,10 +1924,28 @@ Runs COMMAND, a shell command, as if by `compile'. See
(defvar python-eldoc-setup-code (defvar python-eldoc-setup-code
"def __PYDOC_get_help(obj): "def __PYDOC_get_help(obj):
try: try:
import pydoc import inspect
if hasattr(obj, 'startswith'): if hasattr(obj, 'startswith'):
obj = eval(obj, globals()) obj = eval(obj, globals())
doc = pydoc.getdoc(obj) doc = inspect.getdoc(obj)
if not doc and callable(obj):
target = None
if inspect.isclass(obj) and hasattr(obj, '__init__'):
target = obj.__init__
objtype = 'class'
else:
target = obj
objtype = 'def'
if target:
args = inspect.formatargspec(
*inspect.getargspec(target)
)
name = obj.__name__
doc = '{objtype} {name}{args}'.format(
objtype=objtype, name=name, args=args
)
else:
doc = doc.splitlines()[0]
except: except:
doc = '' doc = ''
try: try:
...@@ -2000,16 +2018,7 @@ Interactively, prompt for symbol." ...@@ -2000,16 +2018,7 @@ Interactively, prompt for symbol."
(let ((process (python-shell-get-process))) (let ((process (python-shell-get-process)))
(if (not process) (if (not process)
(message "Eldoc needs an inferior Python process running.") (message "Eldoc needs an inferior Python process running.")
(let ((temp-buffer-show-hook (message (python-eldoc--get-doc-at-point symbol process)))))
(lambda ()
(toggle-read-only 1)
(setq view-return-to-alist
(list (cons (selected-window) help-return-method))))))
(with-output-to-temp-buffer (help-buffer)
(with-current-buffer standard-output
(insert
(python-eldoc--get-doc-at-point symbol process))
(help-print-return-message)))))))
;;; Imenu ;;; Imenu
...@@ -2144,9 +2153,9 @@ not inside a defun." ...@@ -2144,9 +2153,9 @@ not inside a defun."
(save-excursion (save-excursion
(goto-char (line-end-position)) (goto-char (line-end-position))
(forward-comment -9999) (forward-comment -9999)
(setq min-indent (current-indentation))
(while (python-beginning-of-defun-function 1 t) (while (python-beginning-of-defun-function 1 t)
(when (or (not min-indent) (when (< (current-indentation) min-indent)
(< (current-indentation) min-indent))
(setq min-indent (current-indentation)) (setq min-indent (current-indentation))
(looking-at python-nav-beginning-of-defun-regexp) (looking-at python-nav-beginning-of-defun-regexp)
(setq names (cons (setq names (cons
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment