aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-05-17 00:03:18 -0300
committerFabián Ezequiel Gallina2012-05-17 00:03:18 -0300
commit15cc40b8199735e600ddf718b936917ff4d79db0 (patch)
tree94ffc9575693817dc76e5081f74e94cf70f3c95c /lisp/progmodes/python.el
parent9787f82961e029a8a096aa2a4a327eebb974b13c (diff)
downloademacs-15cc40b8199735e600ddf718b936917ff4d79db0.tar.gz
emacs-15cc40b8199735e600ddf718b936917ff4d79db0.zip
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.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el37
1 files changed, 23 insertions, 14 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 20176944ebc..c35b4eec320 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1924,10 +1924,28 @@ Runs COMMAND, a shell command, as if by `compile'. See
1924(defvar python-eldoc-setup-code 1924(defvar python-eldoc-setup-code
1925 "def __PYDOC_get_help(obj): 1925 "def __PYDOC_get_help(obj):
1926 try: 1926 try:
1927 import pydoc 1927 import inspect
1928 if hasattr(obj, 'startswith'): 1928 if hasattr(obj, 'startswith'):
1929 obj = eval(obj, globals()) 1929 obj = eval(obj, globals())
1930 doc = pydoc.getdoc(obj) 1930 doc = inspect.getdoc(obj)
1931 if not doc and callable(obj):
1932 target = None
1933 if inspect.isclass(obj) and hasattr(obj, '__init__'):
1934 target = obj.__init__
1935 objtype = 'class'
1936 else:
1937 target = obj
1938 objtype = 'def'
1939 if target:
1940 args = inspect.formatargspec(
1941 *inspect.getargspec(target)
1942 )
1943 name = obj.__name__
1944 doc = '{objtype} {name}{args}'.format(
1945 objtype=objtype, name=name, args=args
1946 )
1947 else:
1948 doc = doc.splitlines()[0]
1931 except: 1949 except:
1932 doc = '' 1950 doc = ''
1933 try: 1951 try:
@@ -2000,16 +2018,7 @@ Interactively, prompt for symbol."
2000 (let ((process (python-shell-get-process))) 2018 (let ((process (python-shell-get-process)))
2001 (if (not process) 2019 (if (not process)
2002 (message "Eldoc needs an inferior Python process running.") 2020 (message "Eldoc needs an inferior Python process running.")
2003 (let ((temp-buffer-show-hook 2021 (message (python-eldoc--get-doc-at-point symbol process)))))
2004 (lambda ()
2005 (toggle-read-only 1)
2006 (setq view-return-to-alist
2007 (list (cons (selected-window) help-return-method))))))
2008 (with-output-to-temp-buffer (help-buffer)
2009 (with-current-buffer standard-output
2010 (insert
2011 (python-eldoc--get-doc-at-point symbol process))
2012 (help-print-return-message)))))))
2013 2022
2014 2023
2015;;; Imenu 2024;;; Imenu
@@ -2144,9 +2153,9 @@ not inside a defun."
2144 (save-excursion 2153 (save-excursion
2145 (goto-char (line-end-position)) 2154 (goto-char (line-end-position))
2146 (forward-comment -9999) 2155 (forward-comment -9999)
2156 (setq min-indent (current-indentation))
2147 (while (python-beginning-of-defun-function 1 t) 2157 (while (python-beginning-of-defun-function 1 t)
2148 (when (or (not min-indent) 2158 (when (< (current-indentation) min-indent)
2149 (< (current-indentation) min-indent))
2150 (setq min-indent (current-indentation)) 2159 (setq min-indent (current-indentation))
2151 (looking-at python-nav-beginning-of-defun-regexp) 2160 (looking-at python-nav-beginning-of-defun-regexp)
2152 (setq names (cons 2161 (setq names (cons