diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 37 |
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 |