diff options
| author | Juanma Barranquero | 2014-03-15 18:37:58 +0100 |
|---|---|---|
| committer | Juanma Barranquero | 2014-03-15 18:37:58 +0100 |
| commit | fd16b061a9e6e89c905a7d7813867090622969e9 (patch) | |
| tree | 60616741c0a2bf3267e11ce95d4711fee8c7e50d /lisp/progmodes/python.el | |
| parent | b6d8543cd590fee31ecdef84a625a1e1d06e61c8 (diff) | |
| download | emacs-fd16b061a9e6e89c905a7d7813867090622969e9.tar.gz emacs-fd16b061a9e6e89c905a7d7813867090622969e9.zip | |
lisp/progmodes/python.el: Fix docstring typos.
(defconst, python-syntax-count-quotes)
(python-indent-region, python-indent-shift-right)
(python-indent-dedent-line-backspace, python-nav-backward-sexp)
(python-nav-backward-sexp-safe, python-nav-backward-up-list)
(python-shell-prompt-block-regexp, python-shell-prompt-output-regexp)
(python-shell-prompt-pdb-regexp, python-shell-enable-font-lock)
(inferior-python-mode, python-shell-make-comint, run-python-internal)
(python-shell-buffer-substring, python-shell-send-buffer)
(python-pdbtrack-activate, python-pdbtrack-stacktrace-info-regexp)
(python-completion-complete-at-point, python-fill-docstring-style)
(python-eldoc-function, python-imenu-format-item-label)
(python-imenu-format-parent-item-label)
(python-imenu-format-parent-item-jump-label)
(python-imenu--build-tree, python-imenu-create-index)
(python-imenu-create-flat-index): Fix docstring typos.
(python-indent-context, python-shell-prompt-regexp, run-python):
Remove superfluous backslashes.
(python-indent-line, python-nav-beginning-of-defun)
(python-shell-get-buffer, python-shell-get-process)
(python-info-current-defun, python-info-current-line-comment-p)
(python-info-current-line-empty-p, python-util-popn): Doc fixes.
(python-indent-post-self-insert-function, python-shell-send-file)
(python-shell-completion-get-completions)
(python-shell-completion-complete-or-indent)
(python-eldoc--get-doc-at-point): Reflow docstrings.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 165 |
1 files changed, 81 insertions, 84 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 670451e58ae..b0102c55ffd 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -357,7 +357,7 @@ | |||
| 357 | 357 | ||
| 358 | (defmacro python-rx (&rest regexps) | 358 | (defmacro python-rx (&rest regexps) |
| 359 | "Python mode specialized rx macro. | 359 | "Python mode specialized rx macro. |
| 360 | This variant of `rx' supports common python named REGEXPS." | 360 | This variant of `rx' supports common Python named REGEXPS." |
| 361 | (let ((rx-constituents (append python-rx-constituents rx-constituents))) | 361 | (let ((rx-constituents (append python-rx-constituents rx-constituents))) |
| 362 | (cond ((null regexps) | 362 | (cond ((null regexps) |
| 363 | (error "No regexp")) | 363 | (error "No regexp")) |
| @@ -528,7 +528,7 @@ The type returned can be `comment', `string' or `paren'." | |||
| 528 | (defsubst python-syntax-count-quotes (quote-char &optional point limit) | 528 | (defsubst python-syntax-count-quotes (quote-char &optional point limit) |
| 529 | "Count number of quotes around point (max is 3). | 529 | "Count number of quotes around point (max is 3). |
| 530 | QUOTE-CHAR is the quote char to count. Optional argument POINT is | 530 | QUOTE-CHAR is the quote char to count. Optional argument POINT is |
| 531 | the point where scan starts (defaults to current point) and LIMIT | 531 | the point where scan starts (defaults to current point), and LIMIT |
| 532 | is used to limit the scan." | 532 | is used to limit the scan." |
| 533 | (let ((i 0)) | 533 | (let ((i 0)) |
| 534 | (while (and (< i 3) | 534 | (while (and (< i 3) |
| @@ -683,7 +683,7 @@ AFTER-LINE.") | |||
| 683 | (defun python-indent-context () | 683 | (defun python-indent-context () |
| 684 | "Get information on indentation context. | 684 | "Get information on indentation context. |
| 685 | Context information is returned with a cons with the form: | 685 | Context information is returned with a cons with the form: |
| 686 | \(STATUS . START) | 686 | (STATUS . START) |
| 687 | 687 | ||
| 688 | Where status can be any of the following symbols: | 688 | Where status can be any of the following symbols: |
| 689 | 689 | ||
| @@ -963,11 +963,11 @@ variable `python-indent-current-level'. | |||
| 963 | 963 | ||
| 964 | When the variable `last-command' is not equal to one of the | 964 | When the variable `last-command' is not equal to one of the |
| 965 | symbols inside `python-indent-trigger-commands' and FORCE-TOGGLE | 965 | symbols inside `python-indent-trigger-commands' and FORCE-TOGGLE |
| 966 | is nil it calculates possible indentation levels and saves it in | 966 | is nil it calculates possible indentation levels and saves them |
| 967 | the variable `python-indent-levels'. Afterwards it sets the | 967 | in the variable `python-indent-levels'. Afterwards it sets the |
| 968 | variable `python-indent-current-level' correctly so offset is | 968 | variable `python-indent-current-level' correctly so offset is |
| 969 | equal to (`nth' `python-indent-current-level' | 969 | equal to |
| 970 | `python-indent-levels')" | 970 | (nth python-indent-current-level python-indent-levels)" |
| 971 | (or | 971 | (or |
| 972 | (and (or (and (memq this-command python-indent-trigger-commands) | 972 | (and (or (and (memq this-command python-indent-trigger-commands) |
| 973 | (eq last-command this-command)) | 973 | (eq last-command this-command)) |
| @@ -1010,14 +1010,14 @@ See `python-indent-line' for details." | |||
| 1010 | (defun python-indent-dedent-line-backspace (arg) | 1010 | (defun python-indent-dedent-line-backspace (arg) |
| 1011 | "De-indent current line. | 1011 | "De-indent current line. |
| 1012 | Argument ARG is passed to `backward-delete-char-untabify' when | 1012 | Argument ARG is passed to `backward-delete-char-untabify' when |
| 1013 | point is not in between the indentation." | 1013 | point is not in between the indentation." |
| 1014 | (interactive "*p") | 1014 | (interactive "*p") |
| 1015 | (when (not (python-indent-dedent-line)) | 1015 | (when (not (python-indent-dedent-line)) |
| 1016 | (backward-delete-char-untabify arg))) | 1016 | (backward-delete-char-untabify arg))) |
| 1017 | (put 'python-indent-dedent-line-backspace 'delete-selection 'supersede) | 1017 | (put 'python-indent-dedent-line-backspace 'delete-selection 'supersede) |
| 1018 | 1018 | ||
| 1019 | (defun python-indent-region (start end) | 1019 | (defun python-indent-region (start end) |
| 1020 | "Indent a python region automagically. | 1020 | "Indent a Python region automagically. |
| 1021 | 1021 | ||
| 1022 | Called from a program, START and END specify the region to indent." | 1022 | Called from a program, START and END specify the region to indent." |
| 1023 | (let ((deactivate-mark nil)) | 1023 | (let ((deactivate-mark nil)) |
| @@ -1076,7 +1076,7 @@ any lines in the region are indented less than COUNT columns." | |||
| 1076 | (add-to-list 'debug-ignored-errors "^Can't shift all lines enough") | 1076 | (add-to-list 'debug-ignored-errors "^Can't shift all lines enough") |
| 1077 | 1077 | ||
| 1078 | (defun python-indent-shift-right (start end &optional count) | 1078 | (defun python-indent-shift-right (start end &optional count) |
| 1079 | "Shift lines contained in region START END by COUNT columns to the left. | 1079 | "Shift lines contained in region START END by COUNT columns to the right. |
| 1080 | COUNT defaults to `python-indent-offset'. If region isn't | 1080 | COUNT defaults to `python-indent-offset'. If region isn't |
| 1081 | active, the current line is shifted. The shifted region includes | 1081 | active, the current line is shifted. The shifted region includes |
| 1082 | the lines in which START and END lie." | 1082 | the lines in which START and END lie." |
| @@ -1091,10 +1091,9 @@ the lines in which START and END lie." | |||
| 1091 | 1091 | ||
| 1092 | (defun python-indent-post-self-insert-function () | 1092 | (defun python-indent-post-self-insert-function () |
| 1093 | "Adjust indentation after insertion of some characters. | 1093 | "Adjust indentation after insertion of some characters. |
| 1094 | This function is intended to be added to the | 1094 | This function is intended to be added to `post-self-insert-hook.' |
| 1095 | `post-self-insert-hook.' If a line renders a paren alone, after | 1095 | If a line renders a paren alone, after adding a char before it, |
| 1096 | adding a char before it, the line will be re-indented | 1096 | the line will be re-indented automatically if needed." |
| 1097 | automatically if needed." | ||
| 1098 | (when (and electric-indent-mode | 1097 | (when (and electric-indent-mode |
| 1099 | (eq (char-before) last-command-event)) | 1098 | (eq (char-before) last-command-event)) |
| 1100 | (cond | 1099 | (cond |
| @@ -1176,10 +1175,10 @@ With positive ARG search backwards, else search forwards." | |||
| 1176 | 1175 | ||
| 1177 | (defun python-nav-beginning-of-defun (&optional arg) | 1176 | (defun python-nav-beginning-of-defun (&optional arg) |
| 1178 | "Move point to `beginning-of-defun'. | 1177 | "Move point to `beginning-of-defun'. |
| 1179 | With positive ARG search backwards else search forward. When ARG | 1178 | With positive ARG search backwards else search forward. |
| 1180 | is nil or 0 defaults to 1. When searching backwards nested | 1179 | ARG nil or 0 defaults to 1. When searching backwards, |
| 1181 | defuns are handled with care depending on current point | 1180 | nested defuns are handled with care depending on current |
| 1182 | position. Return non-nil if point is moved to | 1181 | point position. Return non-nil if point is moved to |
| 1183 | `beginning-of-defun'." | 1182 | `beginning-of-defun'." |
| 1184 | (when (or (null arg) (= arg 0)) (setq arg 1)) | 1183 | (when (or (null arg) (= arg 0)) (setq arg 1)) |
| 1185 | (let ((found)) | 1184 | (let ((found)) |
| @@ -1559,7 +1558,7 @@ backward N times." | |||
| 1559 | (defun python-nav-backward-sexp (&optional arg) | 1558 | (defun python-nav-backward-sexp (&optional arg) |
| 1560 | "Move backward across expressions. | 1559 | "Move backward across expressions. |
| 1561 | With ARG, do it that many times. Negative arg -N means move | 1560 | With ARG, do it that many times. Negative arg -N means move |
| 1562 | backward N times." | 1561 | forward N times." |
| 1563 | (interactive "^p") | 1562 | (interactive "^p") |
| 1564 | (or arg (setq arg 1)) | 1563 | (or arg (setq arg 1)) |
| 1565 | (python-nav-forward-sexp (- arg))) | 1564 | (python-nav-forward-sexp (- arg))) |
| @@ -1580,7 +1579,7 @@ backward N times." | |||
| 1580 | (defun python-nav-backward-sexp-safe (&optional arg) | 1579 | (defun python-nav-backward-sexp-safe (&optional arg) |
| 1581 | "Move backward safely across expressions. | 1580 | "Move backward safely across expressions. |
| 1582 | With ARG, do it that many times. Negative arg -N means move | 1581 | With ARG, do it that many times. Negative arg -N means move |
| 1583 | backward N times." | 1582 | forward N times." |
| 1584 | (interactive "^p") | 1583 | (interactive "^p") |
| 1585 | (or arg (setq arg 1)) | 1584 | (or arg (setq arg 1)) |
| 1586 | (python-nav-forward-sexp-safe (- arg))) | 1585 | (python-nav-forward-sexp-safe (- arg))) |
| @@ -1640,7 +1639,7 @@ This command assumes point is not in a string or comment." | |||
| 1640 | (defun python-nav-backward-up-list (&optional arg) | 1639 | (defun python-nav-backward-up-list (&optional arg) |
| 1641 | "Move backward out of one level of parentheses (or blocks). | 1640 | "Move backward out of one level of parentheses (or blocks). |
| 1642 | With ARG, do this that many times. | 1641 | With ARG, do this that many times. |
| 1643 | A negative argument means move backward but still to a less deep spot. | 1642 | A negative argument means move forward but still to a less deep spot. |
| 1644 | This command assumes point is not in a string or comment." | 1643 | This command assumes point is not in a string or comment." |
| 1645 | (interactive "^p") | 1644 | (interactive "^p") |
| 1646 | (or arg (setq arg 1)) | 1645 | (or arg (setq arg 1)) |
| @@ -1695,36 +1694,36 @@ position, else returns nil." | |||
| 1695 | :group 'python) | 1694 | :group 'python) |
| 1696 | 1695 | ||
| 1697 | (defcustom python-shell-prompt-regexp ">>> " | 1696 | (defcustom python-shell-prompt-regexp ">>> " |
| 1698 | "Regular Expression matching top\-level input prompt of python shell. | 1697 | "Regular expression matching top-level input prompt of Python shell. |
| 1699 | It should not contain a caret (^) at the beginning." | 1698 | It should not contain a caret (^) at the beginning." |
| 1700 | :type 'string | 1699 | :type 'string |
| 1701 | :group 'python | 1700 | :group 'python |
| 1702 | :safe 'stringp) | 1701 | :safe 'stringp) |
| 1703 | 1702 | ||
| 1704 | (defcustom python-shell-prompt-block-regexp "[.][.][.] " | 1703 | (defcustom python-shell-prompt-block-regexp "[.][.][.] " |
| 1705 | "Regular Expression matching block input prompt of python shell. | 1704 | "Regular expression matching block input prompt of Python shell. |
| 1706 | It should not contain a caret (^) at the beginning." | 1705 | It should not contain a caret (^) at the beginning." |
| 1707 | :type 'string | 1706 | :type 'string |
| 1708 | :group 'python | 1707 | :group 'python |
| 1709 | :safe 'stringp) | 1708 | :safe 'stringp) |
| 1710 | 1709 | ||
| 1711 | (defcustom python-shell-prompt-output-regexp "" | 1710 | (defcustom python-shell-prompt-output-regexp "" |
| 1712 | "Regular Expression matching output prompt of python shell. | 1711 | "Regular expression matching output prompt of Python shell. |
| 1713 | It should not contain a caret (^) at the beginning." | 1712 | It should not contain a caret (^) at the beginning." |
| 1714 | :type 'string | 1713 | :type 'string |
| 1715 | :group 'python | 1714 | :group 'python |
| 1716 | :safe 'stringp) | 1715 | :safe 'stringp) |
| 1717 | 1716 | ||
| 1718 | (defcustom python-shell-prompt-pdb-regexp "[(<]*[Ii]?[Pp]db[>)]+ " | 1717 | (defcustom python-shell-prompt-pdb-regexp "[(<]*[Ii]?[Pp]db[>)]+ " |
| 1719 | "Regular Expression matching pdb input prompt of python shell. | 1718 | "Regular expression matching pdb input prompt of Python shell. |
| 1720 | It should not contain a caret (^) at the beginning." | 1719 | It should not contain a caret (^) at the beginning." |
| 1721 | :type 'string | 1720 | :type 'string |
| 1722 | :group 'python | 1721 | :group 'python |
| 1723 | :safe 'stringp) | 1722 | :safe 'stringp) |
| 1724 | 1723 | ||
| 1725 | (defcustom python-shell-enable-font-lock t | 1724 | (defcustom python-shell-enable-font-lock t |
| 1726 | "Should syntax highlighting be enabled in the python shell buffer? | 1725 | "Should syntax highlighting be enabled in the Python shell buffer? |
| 1727 | Restart the python shell after changing this variable for it to take effect." | 1726 | Restart the Python shell after changing this variable for it to take effect." |
| 1728 | :type 'boolean | 1727 | :type 'boolean |
| 1729 | :group 'python | 1728 | :group 'python |
| 1730 | :safe 'booleanp) | 1729 | :safe 'booleanp) |
| @@ -1890,9 +1889,9 @@ It makes parens and quotes be treated as punctuation chars.") | |||
| 1890 | (define-derived-mode inferior-python-mode comint-mode "Inferior Python" | 1889 | (define-derived-mode inferior-python-mode comint-mode "Inferior Python" |
| 1891 | "Major mode for Python inferior process. | 1890 | "Major mode for Python inferior process. |
| 1892 | Runs a Python interpreter as a subprocess of Emacs, with Python | 1891 | Runs a Python interpreter as a subprocess of Emacs, with Python |
| 1893 | I/O through an Emacs buffer. Variables | 1892 | I/O through an Emacs buffer. Variables `python-shell-interpreter' |
| 1894 | `python-shell-interpreter' and `python-shell-interpreter-args' | 1893 | and `python-shell-interpreter-args' control which Python |
| 1895 | controls which Python interpreter is run. Variables | 1894 | interpreter is run. Variables |
| 1896 | `python-shell-prompt-regexp', | 1895 | `python-shell-prompt-regexp', |
| 1897 | `python-shell-prompt-output-regexp', | 1896 | `python-shell-prompt-output-regexp', |
| 1898 | `python-shell-prompt-block-regexp', | 1897 | `python-shell-prompt-block-regexp', |
| @@ -1960,8 +1959,8 @@ variable. | |||
| 1960 | (compilation-shell-minor-mode 1)) | 1959 | (compilation-shell-minor-mode 1)) |
| 1961 | 1960 | ||
| 1962 | (defun python-shell-make-comint (cmd proc-name &optional pop internal) | 1961 | (defun python-shell-make-comint (cmd proc-name &optional pop internal) |
| 1963 | "Create a python shell comint buffer. | 1962 | "Create a Python shell comint buffer. |
| 1964 | CMD is the python command to be executed and PROC-NAME is the | 1963 | CMD is the Python command to be executed and PROC-NAME is the |
| 1965 | process name the comint buffer will get. After the comint buffer | 1964 | process name the comint buffer will get. After the comint buffer |
| 1966 | is created the `inferior-python-mode' is activated. When | 1965 | is created the `inferior-python-mode' is activated. When |
| 1967 | optional argument POP is non-nil the buffer is shown. When | 1966 | optional argument POP is non-nil the buffer is shown. When |
| @@ -2000,8 +1999,8 @@ command used to call the interpreter and define DEDICATED, so a | |||
| 2000 | dedicated process for the current buffer is open. When numeric | 1999 | dedicated process for the current buffer is open. When numeric |
| 2001 | prefix arg is other than 0 or 4 do not SHOW. | 2000 | prefix arg is other than 0 or 4 do not SHOW. |
| 2002 | 2001 | ||
| 2003 | Runs the hook `inferior-python-mode-hook' (after the | 2002 | Runs the hook `inferior-python-mode-hook' after |
| 2004 | `comint-mode-hook' is run). \(Type \\[describe-mode] in the | 2003 | `comint-mode-hook' is run. (Type \\[describe-mode] in the |
| 2005 | process buffer for a list of commands.)" | 2004 | process buffer for a list of commands.)" |
| 2006 | (interactive | 2005 | (interactive |
| 2007 | (if current-prefix-arg | 2006 | (if current-prefix-arg |
| @@ -2021,7 +2020,7 @@ Input and output via buffer named after | |||
| 2021 | `python-shell-internal-get-process-name' returns. | 2020 | `python-shell-internal-get-process-name' returns. |
| 2022 | 2021 | ||
| 2023 | This new kind of shell is intended to be used for generic | 2022 | This new kind of shell is intended to be used for generic |
| 2024 | communication related to defined configurations, the main | 2023 | communication related to defined configurations; the main |
| 2025 | difference with global or dedicated shells is that these ones are | 2024 | difference with global or dedicated shells is that these ones are |
| 2026 | attached to a configuration, not a buffer. This means that can | 2025 | attached to a configuration, not a buffer. This means that can |
| 2027 | be used for example to retrieve the sys.path and other stuff, | 2026 | be used for example to retrieve the sys.path and other stuff, |
| @@ -2037,7 +2036,7 @@ startup." | |||
| 2037 | (python-shell-internal-get-process-name) nil t)))) | 2036 | (python-shell-internal-get-process-name) nil t)))) |
| 2038 | 2037 | ||
| 2039 | (defun python-shell-get-buffer () | 2038 | (defun python-shell-get-buffer () |
| 2040 | "Get inferior Python buffer for current buffer and return it." | 2039 | "Return inferior Python buffer for current buffer." |
| 2041 | (let* ((dedicated-proc-name (python-shell-get-process-name t)) | 2040 | (let* ((dedicated-proc-name (python-shell-get-process-name t)) |
| 2042 | (dedicated-proc-buffer-name (format "*%s*" dedicated-proc-name)) | 2041 | (dedicated-proc-buffer-name (format "*%s*" dedicated-proc-name)) |
| 2043 | (global-proc-name (python-shell-get-process-name nil)) | 2042 | (global-proc-name (python-shell-get-process-name nil)) |
| @@ -2049,7 +2048,7 @@ startup." | |||
| 2049 | (and global-running global-proc-buffer-name)))) | 2048 | (and global-running global-proc-buffer-name)))) |
| 2050 | 2049 | ||
| 2051 | (defun python-shell-get-process () | 2050 | (defun python-shell-get-process () |
| 2052 | "Get inferior Python process for current buffer and return it." | 2051 | "Return inferior Python process for current buffer." |
| 2053 | (get-buffer-process (python-shell-get-buffer))) | 2052 | (get-buffer-process (python-shell-get-buffer))) |
| 2054 | 2053 | ||
| 2055 | (defun python-shell-get-or-create-process () | 2054 | (defun python-shell-get-or-create-process () |
| @@ -2216,7 +2215,7 @@ source file.") | |||
| 2216 | This is a wrapper over `buffer-substring' that takes care of | 2215 | This is a wrapper over `buffer-substring' that takes care of |
| 2217 | different transformations for the code sent to be evaluated in | 2216 | different transformations for the code sent to be evaluated in |
| 2218 | the python shell: | 2217 | the python shell: |
| 2219 | 1. When Optional Argument NOMAIN is non-nil everything under an | 2218 | 1. When optional argument NOMAIN is non-nil everything under an |
| 2220 | \"if __name__ == '__main__'\" block will be removed. | 2219 | \"if __name__ == '__main__'\" block will be removed. |
| 2221 | 2. When a subregion of the buffer is sent, it takes care of | 2220 | 2. When a subregion of the buffer is sent, it takes care of |
| 2222 | appending extra empty lines so tracebacks are correct. | 2221 | appending extra empty lines so tracebacks are correct. |
| @@ -2288,7 +2287,7 @@ the python shell: | |||
| 2288 | (defun python-shell-send-buffer (&optional arg) | 2287 | (defun python-shell-send-buffer (&optional arg) |
| 2289 | "Send the entire buffer to inferior Python process. | 2288 | "Send the entire buffer to inferior Python process. |
| 2290 | With prefix ARG allow execution of code inside blocks delimited | 2289 | With prefix ARG allow execution of code inside blocks delimited |
| 2291 | by \"if __name__== '__main__':\"" | 2290 | by \"if __name__== '__main__':\"." |
| 2292 | (interactive "P") | 2291 | (interactive "P") |
| 2293 | (save-restriction | 2292 | (save-restriction |
| 2294 | (widen) | 2293 | (widen) |
| @@ -2319,8 +2318,8 @@ When argument ARG is non-nil do not include decorators." | |||
| 2319 | delete) | 2318 | delete) |
| 2320 | "Send FILE-NAME to inferior Python PROCESS. | 2319 | "Send FILE-NAME to inferior Python PROCESS. |
| 2321 | If TEMP-FILE-NAME is passed then that file is used for processing | 2320 | If TEMP-FILE-NAME is passed then that file is used for processing |
| 2322 | instead, while internally the shell will continue to use | 2321 | instead, while internally the shell will continue to use FILE-NAME. |
| 2323 | FILE-NAME. If DELETE is non-nil, delete the file afterwards." | 2322 | If DELETE is non-nil, delete the file afterwards." |
| 2324 | (interactive "fFile to send: ") | 2323 | (interactive "fFile to send: ") |
| 2325 | (let* ((process (or process (python-shell-get-or-create-process))) | 2324 | (let* ((process (or process (python-shell-get-or-create-process))) |
| 2326 | (temp-file-name (when temp-file-name | 2325 | (temp-file-name (when temp-file-name |
| @@ -2420,8 +2419,7 @@ and use the following as the value of this variable: | |||
| 2420 | 2419 | ||
| 2421 | (defun python-shell-completion-get-completions (process line input) | 2420 | (defun python-shell-completion-get-completions (process line input) |
| 2422 | "Do completion at point for PROCESS. | 2421 | "Do completion at point for PROCESS. |
| 2423 | LINE is used to detect the context on how to complete given | 2422 | LINE is used to detect the context on how to complete given INPUT." |
| 2424 | INPUT." | ||
| 2425 | (let* ((prompt | 2423 | (let* ((prompt |
| 2426 | ;; Get last prompt of the inferior process buffer (this | 2424 | ;; Get last prompt of the inferior process buffer (this |
| 2427 | ;; intentionally avoids using `comint-last-prompt' because | 2425 | ;; intentionally avoids using `comint-last-prompt' because |
| @@ -2507,8 +2505,8 @@ using that one instead of current buffer's process." | |||
| 2507 | 2505 | ||
| 2508 | (defun python-shell-completion-complete-or-indent () | 2506 | (defun python-shell-completion-complete-or-indent () |
| 2509 | "Complete or indent depending on the context. | 2507 | "Complete or indent depending on the context. |
| 2510 | If content before pointer is all whitespace indent. If not try | 2508 | If content before pointer is all whitespace, indent. |
| 2511 | to complete." | 2509 | If not try to complete." |
| 2512 | (interactive) | 2510 | (interactive) |
| 2513 | (if (string-match "^[[:space:]]*$" | 2511 | (if (string-match "^[[:space:]]*$" |
| 2514 | (buffer-substring (comint-line-beginning-position) | 2512 | (buffer-substring (comint-line-beginning-position) |
| @@ -2520,14 +2518,14 @@ to complete." | |||
| 2520 | ;;; PDB Track integration | 2518 | ;;; PDB Track integration |
| 2521 | 2519 | ||
| 2522 | (defcustom python-pdbtrack-activate t | 2520 | (defcustom python-pdbtrack-activate t |
| 2523 | "Non-nil makes python shell enable pdbtracking." | 2521 | "Non-nil makes Python shell enable pdbtracking." |
| 2524 | :type 'boolean | 2522 | :type 'boolean |
| 2525 | :group 'python | 2523 | :group 'python |
| 2526 | :safe 'booleanp) | 2524 | :safe 'booleanp) |
| 2527 | 2525 | ||
| 2528 | (defcustom python-pdbtrack-stacktrace-info-regexp | 2526 | (defcustom python-pdbtrack-stacktrace-info-regexp |
| 2529 | "> \\([^\"(<]+\\)(\\([0-9]+\\))\\([?a-zA-Z0-9_<>]+\\)()" | 2527 | "> \\([^\"(<]+\\)(\\([0-9]+\\))\\([?a-zA-Z0-9_<>]+\\)()" |
| 2530 | "Regular Expression matching stacktrace information. | 2528 | "Regular expression matching stacktrace information. |
| 2531 | Used to extract the current line and module being inspected." | 2529 | Used to extract the current line and module being inspected." |
| 2532 | :type 'string | 2530 | :type 'string |
| 2533 | :group 'python | 2531 | :group 'python |
| @@ -2613,9 +2611,9 @@ Argument OUTPUT is a string with the output from the comint process." | |||
| 2613 | 2611 | ||
| 2614 | (defun python-completion-complete-at-point () | 2612 | (defun python-completion-complete-at-point () |
| 2615 | "Complete current symbol at point. | 2613 | "Complete current symbol at point. |
| 2616 | For this to work the best as possible you should call | 2614 | For this to work as best as possible you should call |
| 2617 | `python-shell-send-buffer' from time to time so context in | 2615 | `python-shell-send-buffer' from time to time so context in |
| 2618 | inferior python process is updated properly." | 2616 | inferior Python process is updated properly." |
| 2619 | (let ((process (python-shell-get-process))) | 2617 | (let ((process (python-shell-get-process))) |
| 2620 | (if (not process) | 2618 | (if (not process) |
| 2621 | (error "Completion needs an inferior Python process running") | 2619 | (error "Completion needs an inferior Python process running") |
| @@ -2660,12 +2658,12 @@ fill parens." | |||
| 2660 | This affects `python-fill-string' behavior with regards to | 2658 | This affects `python-fill-string' behavior with regards to |
| 2661 | triple quotes positioning. | 2659 | triple quotes positioning. |
| 2662 | 2660 | ||
| 2663 | Possible values are DJANGO, ONETWO, PEP-257, PEP-257-NN, | 2661 | Possible values are `django', `onetwo', `pep-257', `pep-257-nn', |
| 2664 | SYMMETRIC, and NIL. A value of NIL won't care about quotes | 2662 | `symmetric', and nil. A value of nil won't care about quotes |
| 2665 | position and will treat docstrings a normal string, any other | 2663 | position and will treat docstrings a normal string, any other |
| 2666 | value may result in one of the following docstring styles: | 2664 | value may result in one of the following docstring styles: |
| 2667 | 2665 | ||
| 2668 | DJANGO: | 2666 | `django': |
| 2669 | 2667 | ||
| 2670 | \"\"\" | 2668 | \"\"\" |
| 2671 | Process foo, return bar. | 2669 | Process foo, return bar. |
| @@ -2677,7 +2675,7 @@ DJANGO: | |||
| 2677 | If processing fails throw ProcessingError. | 2675 | If processing fails throw ProcessingError. |
| 2678 | \"\"\" | 2676 | \"\"\" |
| 2679 | 2677 | ||
| 2680 | ONETWO: | 2678 | `onetwo': |
| 2681 | 2679 | ||
| 2682 | \"\"\"Process foo, return bar.\"\"\" | 2680 | \"\"\"Process foo, return bar.\"\"\" |
| 2683 | 2681 | ||
| @@ -2688,7 +2686,7 @@ ONETWO: | |||
| 2688 | 2686 | ||
| 2689 | \"\"\" | 2687 | \"\"\" |
| 2690 | 2688 | ||
| 2691 | PEP-257: | 2689 | `pep-257': |
| 2692 | 2690 | ||
| 2693 | \"\"\"Process foo, return bar.\"\"\" | 2691 | \"\"\"Process foo, return bar.\"\"\" |
| 2694 | 2692 | ||
| @@ -2698,7 +2696,7 @@ PEP-257: | |||
| 2698 | 2696 | ||
| 2699 | \"\"\" | 2697 | \"\"\" |
| 2700 | 2698 | ||
| 2701 | PEP-257-NN: | 2699 | `pep-257-nn': |
| 2702 | 2700 | ||
| 2703 | \"\"\"Process foo, return bar.\"\"\" | 2701 | \"\"\"Process foo, return bar.\"\"\" |
| 2704 | 2702 | ||
| @@ -2707,7 +2705,7 @@ PEP-257-NN: | |||
| 2707 | If processing fails throw ProcessingError. | 2705 | If processing fails throw ProcessingError. |
| 2708 | \"\"\" | 2706 | \"\"\" |
| 2709 | 2707 | ||
| 2710 | SYMMETRIC: | 2708 | `symmetric': |
| 2711 | 2709 | ||
| 2712 | \"\"\"Process foo, return bar.\"\"\" | 2710 | \"\"\"Process foo, return bar.\"\"\" |
| 2713 | 2711 | ||
| @@ -3064,8 +3062,8 @@ The skeleton will be bound to python-skeleton-NAME." | |||
| 3064 | 3062 | ||
| 3065 | (defun python-check (command) | 3063 | (defun python-check (command) |
| 3066 | "Check a Python file (default current buffer's file). | 3064 | "Check a Python file (default current buffer's file). |
| 3067 | Runs COMMAND, a shell command, as if by `compile'. See | 3065 | Runs COMMAND, a shell command, as if by `compile'. |
| 3068 | `python-check-command' for the default." | 3066 | See `python-check-command' for the default." |
| 3069 | (interactive | 3067 | (interactive |
| 3070 | (list (read-string "Check command: " | 3068 | (list (read-string "Check command: " |
| 3071 | (or python-check-custom-command | 3069 | (or python-check-custom-command |
| @@ -3130,10 +3128,9 @@ Runs COMMAND, a shell command, as if by `compile'. See | |||
| 3130 | 3128 | ||
| 3131 | (defun python-eldoc--get-doc-at-point (&optional force-input force-process) | 3129 | (defun python-eldoc--get-doc-at-point (&optional force-input force-process) |
| 3132 | "Internal implementation to get documentation at point. | 3130 | "Internal implementation to get documentation at point. |
| 3133 | If not FORCE-INPUT is passed then what | 3131 | If not FORCE-INPUT is passed then what `python-info-current-symbol' |
| 3134 | `python-info-current-symbol' returns will be used. If not | 3132 | returns will be used. If not FORCE-PROCESS is passed what |
| 3135 | FORCE-PROCESS is passed what `python-shell-get-process' returns | 3133 | `python-shell-get-process' returns is used." |
| 3136 | is used." | ||
| 3137 | (let ((process (or force-process (python-shell-get-process)))) | 3134 | (let ((process (or force-process (python-shell-get-process)))) |
| 3138 | (if (not process) | 3135 | (if (not process) |
| 3139 | (error "Eldoc needs an inferior Python process running") | 3136 | (error "Eldoc needs an inferior Python process running") |
| @@ -3146,9 +3143,9 @@ is used." | |||
| 3146 | 3143 | ||
| 3147 | (defun python-eldoc-function () | 3144 | (defun python-eldoc-function () |
| 3148 | "`eldoc-documentation-function' for Python. | 3145 | "`eldoc-documentation-function' for Python. |
| 3149 | For this to work the best as possible you should call | 3146 | For this to work as best as possible you should call |
| 3150 | `python-shell-send-buffer' from time to time so context in | 3147 | `python-shell-send-buffer' from time to time so context in |
| 3151 | inferior python process is updated properly." | 3148 | inferior Python process is updated properly." |
| 3152 | (python-eldoc--get-doc-at-point)) | 3149 | (python-eldoc--get-doc-at-point)) |
| 3153 | 3150 | ||
| 3154 | (defun python-eldoc-at-point (symbol) | 3151 | (defun python-eldoc-at-point (symbol) |
| @@ -3185,15 +3182,15 @@ It must be a function with two arguments: TYPE and NAME.") | |||
| 3185 | It must be a function with two arguments: TYPE and NAME.") | 3182 | It must be a function with two arguments: TYPE and NAME.") |
| 3186 | 3183 | ||
| 3187 | (defun python-imenu-format-item-label (type name) | 3184 | (defun python-imenu-format-item-label (type name) |
| 3188 | "Return imenu label for single node using TYPE and NAME." | 3185 | "Return Imenu label for single node using TYPE and NAME." |
| 3189 | (format "%s (%s)" name type)) | 3186 | (format "%s (%s)" name type)) |
| 3190 | 3187 | ||
| 3191 | (defun python-imenu-format-parent-item-label (type name) | 3188 | (defun python-imenu-format-parent-item-label (type name) |
| 3192 | "Return imenu label for parent node using TYPE and NAME." | 3189 | "Return Imenu label for parent node using TYPE and NAME." |
| 3193 | (format "%s..." (python-imenu-format-item-label type name))) | 3190 | (format "%s..." (python-imenu-format-item-label type name))) |
| 3194 | 3191 | ||
| 3195 | (defun python-imenu-format-parent-item-jump-label (type _name) | 3192 | (defun python-imenu-format-parent-item-jump-label (type _name) |
| 3196 | "Return imenu label for parent node jump using TYPE and NAME." | 3193 | "Return Imenu label for parent node jump using TYPE and NAME." |
| 3197 | (if (string= type "class") | 3194 | (if (string= type "class") |
| 3198 | "*class definition*" | 3195 | "*class definition*" |
| 3199 | "*function definition*")) | 3196 | "*function definition*")) |
| @@ -3210,7 +3207,7 @@ It must be a function with two arguments: TYPE and NAME.") | |||
| 3210 | 3207 | ||
| 3211 | (defun python-imenu--build-tree (&optional min-indent prev-indent tree) | 3208 | (defun python-imenu--build-tree (&optional min-indent prev-indent tree) |
| 3212 | "Recursively build the tree of nested definitions of a node. | 3209 | "Recursively build the tree of nested definitions of a node. |
| 3213 | Arguments MIN-INDENT PREV-INDENT and TREE are internal and should | 3210 | Arguments MIN-INDENT, PREV-INDENT and TREE are internal and should |
| 3214 | not be passed explicitly unless you know what you are doing." | 3211 | not be passed explicitly unless you know what you are doing." |
| 3215 | (setq min-indent (or min-indent 0) | 3212 | (setq min-indent (or min-indent 0) |
| 3216 | prev-indent (or prev-indent python-indent-offset)) | 3213 | prev-indent (or prev-indent python-indent-offset)) |
| @@ -3251,7 +3248,7 @@ not be passed explicitly unless you know what you are doing." | |||
| 3251 | tree))))))) | 3248 | tree))))))) |
| 3252 | 3249 | ||
| 3253 | (defun python-imenu-create-index () | 3250 | (defun python-imenu-create-index () |
| 3254 | "Return tree Imenu alist for the current python buffer. | 3251 | "Return tree Imenu alist for the current Python buffer. |
| 3255 | Change `python-imenu-format-item-label-function', | 3252 | Change `python-imenu-format-item-label-function', |
| 3256 | `python-imenu-format-parent-item-label-function', | 3253 | `python-imenu-format-parent-item-label-function', |
| 3257 | `python-imenu-format-parent-item-jump-label-function' to | 3254 | `python-imenu-format-parent-item-jump-label-function' to |
| @@ -3264,18 +3261,19 @@ customize how labels are formatted." | |||
| 3264 | index)) | 3261 | index)) |
| 3265 | 3262 | ||
| 3266 | (defun python-imenu-create-flat-index (&optional alist prefix) | 3263 | (defun python-imenu-create-flat-index (&optional alist prefix) |
| 3267 | "Return flat outline of the current python buffer for Imenu. | 3264 | "Return flat outline of the current Python buffer for Imenu. |
| 3268 | Optional Argument ALIST is the tree to be flattened, when nil | 3265 | Optional argument ALIST is the tree to be flattened; when nil |
| 3269 | `python-imenu-build-index' is used with | 3266 | `python-imenu-build-index' is used with |
| 3270 | `python-imenu-format-parent-item-jump-label-function' | 3267 | `python-imenu-format-parent-item-jump-label-function' |
| 3271 | `python-imenu-format-parent-item-label-function' | 3268 | `python-imenu-format-parent-item-label-function' |
| 3272 | `python-imenu-format-item-label-function' set to (lambda (type | 3269 | `python-imenu-format-item-label-function' set to |
| 3273 | name) name). Optional Argument PREFIX is used in recursive calls | 3270 | (lambda (type name) name) |
| 3274 | and should not be passed explicitly. | 3271 | Optional argument PREFIX is used in recursive calls and should |
| 3272 | not be passed explicitly. | ||
| 3275 | 3273 | ||
| 3276 | Converts this: | 3274 | Converts this: |
| 3277 | 3275 | ||
| 3278 | \((\"Foo\" . 103) | 3276 | ((\"Foo\" . 103) |
| 3279 | (\"Bar\" . 138) | 3277 | (\"Bar\" . 138) |
| 3280 | (\"decorator\" | 3278 | (\"decorator\" |
| 3281 | (\"decorator\" . 173) | 3279 | (\"decorator\" . 173) |
| @@ -3285,7 +3283,7 @@ Converts this: | |||
| 3285 | 3283 | ||
| 3286 | To this: | 3284 | To this: |
| 3287 | 3285 | ||
| 3288 | \((\"Foo\" . 103) | 3286 | ((\"Foo\" . 103) |
| 3289 | (\"Bar\" . 138) | 3287 | (\"Bar\" . 138) |
| 3290 | (\"decorator\" . 173) | 3288 | (\"decorator\" . 173) |
| 3291 | (\"decorator.wrap\" . 353) | 3289 | (\"decorator.wrap\" . 353) |
| @@ -3318,9 +3316,8 @@ To this: | |||
| 3318 | (defun python-info-current-defun (&optional include-type) | 3316 | (defun python-info-current-defun (&optional include-type) |
| 3319 | "Return name of surrounding function with Python compatible dotty syntax. | 3317 | "Return name of surrounding function with Python compatible dotty syntax. |
| 3320 | Optional argument INCLUDE-TYPE indicates to include the type of the defun. | 3318 | Optional argument INCLUDE-TYPE indicates to include the type of the defun. |
| 3321 | This function is compatible to be used as | 3319 | This function can be used as the value of `add-log-current-defun-function' |
| 3322 | `add-log-current-defun-function' since it returns nil if point is | 3320 | since it returns nil if point is not inside a defun." |
| 3323 | not inside a defun." | ||
| 3324 | (save-restriction | 3321 | (save-restriction |
| 3325 | (widen) | 3322 | (widen) |
| 3326 | (save-excursion | 3323 | (save-excursion |
| @@ -3583,13 +3580,13 @@ operator." | |||
| 3583 | (looking-at python-nav-beginning-of-defun-regexp)))) | 3580 | (looking-at python-nav-beginning-of-defun-regexp)))) |
| 3584 | 3581 | ||
| 3585 | (defun python-info-current-line-comment-p () | 3582 | (defun python-info-current-line-comment-p () |
| 3586 | "Check if current line is a comment line." | 3583 | "Return non-nil if current line is a comment line." |
| 3587 | (char-equal | 3584 | (char-equal |
| 3588 | (or (char-after (+ (line-beginning-position) (current-indentation))) ?_) | 3585 | (or (char-after (+ (line-beginning-position) (current-indentation))) ?_) |
| 3589 | ?#)) | 3586 | ?#)) |
| 3590 | 3587 | ||
| 3591 | (defun python-info-current-line-empty-p () | 3588 | (defun python-info-current-line-empty-p () |
| 3592 | "Check if current line is empty, ignoring whitespace." | 3589 | "Return non-nil if current line is empty, ignoring whitespace." |
| 3593 | (save-excursion | 3590 | (save-excursion |
| 3594 | (beginning-of-line 1) | 3591 | (beginning-of-line 1) |
| 3595 | (looking-at | 3592 | (looking-at |
| @@ -3633,9 +3630,9 @@ Optional argument DIRECTION defines the direction to move to." | |||
| 3633 | 3630 | ||
| 3634 | (defun python-util-popn (lst n) | 3631 | (defun python-util-popn (lst n) |
| 3635 | "Return LST first N elements. | 3632 | "Return LST first N elements. |
| 3636 | N should be an integer, when it's a natural negative number its | 3633 | N should be an integer, when negative its opposite is used. |
| 3637 | opposite is used. When N is bigger than the length of LST, the | 3634 | When N is bigger than the length of LST, the list is |
| 3638 | list is returned as is." | 3635 | returned as is." |
| 3639 | (let* ((n (min (abs n))) | 3636 | (let* ((n (min (abs n))) |
| 3640 | (len (length lst)) | 3637 | (len (length lst)) |
| 3641 | (acc)) | 3638 | (acc)) |