aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorGlenn Morris2017-12-20 21:15:43 -0500
committerGlenn Morris2017-12-20 21:15:43 -0500
commitb1cf262a79463f28164ea1c2ffee3c657ce02ea4 (patch)
tree4a428c5e0c026c1bb30e5972e78b145335b4b747 /lisp/progmodes/python.el
parenta415a97461cb10d2c6710871f90f57bd1ca34ec2 (diff)
parentb3f4a3a5aee93fa2f7ad2597383befbf7b242209 (diff)
downloademacs-b1cf262a79463f28164ea1c2ffee3c657ce02ea4.tar.gz
emacs-b1cf262a79463f28164ea1c2ffee3c657ce02ea4.zip
Merge from origin/emacs-26
b3f4a3a (origin/emacs-26) Special-case %DUMBFW for GnuTLS between 3.2... c2ae057 Work around GnuTLS version issues with %DUMBFW (tiny change) 2f9d9ef ; Remove the mention of "plain C code" in the docstring as well aca827b Merge branch 'widen-less' into emacs-26 87548f5 ; Rephrase NEWS entry a bit da0d773 (emacs-26) ; * lisp/erc/erc.el: Update URL. 3a60515 * lisp/erc/erc.el (erc-shorten-server-name): Silence compiler... 471b6c1 ; Replace non-ascii quote characters in doc strings etc 7af7f5e Fix some more aliases to user options 79fb4b5 Fix some flymake aliases b9fbc03 (origin/widen-less) Widen in indent-for-tab-command in the no... 446faf3 Replace the mention of c-indent-defun with js-indent-line 7e9eef0 Consolidate 'widen' calls # Conflicts: # etc/NEWS # lisp/progmodes/flymake-proc.el
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el72
1 files changed, 28 insertions, 44 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 035d93f7b99..a72a55d2d9a 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -287,10 +287,6 @@
287;;; 24.x Compat 287;;; 24.x Compat
288 288
289 289
290(unless (fboundp 'prog-widen)
291 (defun prog-widen ()
292 (widen)))
293
294(unless (fboundp 'prog-first-column) 290(unless (fboundp 'prog-first-column)
295 (defun prog-first-column () 291 (defun prog-first-column ()
296 0)) 292 0))
@@ -725,12 +721,18 @@ It makes underscores and dots word constituent chars.")
725 721
726;;; Indentation 722;;; Indentation
727 723
724(define-obsolete-variable-alias
725 'python-indent 'python-indent-offset "24.3")
726
728(defcustom python-indent-offset 4 727(defcustom python-indent-offset 4
729 "Default indentation offset for Python." 728 "Default indentation offset for Python."
730 :group 'python 729 :group 'python
731 :type 'integer 730 :type 'integer
732 :safe 'integerp) 731 :safe 'integerp)
733 732
733(define-obsolete-variable-alias
734 'python-guess-indent 'python-indent-guess-indent-offset "24.3")
735
734(defcustom python-indent-guess-indent-offset t 736(defcustom python-indent-guess-indent-offset t
735 "Non-nil tells Python mode to guess `python-indent-offset' value." 737 "Non-nil tells Python mode to guess `python-indent-offset' value."
736 :type 'boolean 738 :type 'boolean
@@ -750,12 +752,6 @@ It makes underscores and dots word constituent chars.")
750 :type '(repeat symbol) 752 :type '(repeat symbol)
751 :group 'python) 753 :group 'python)
752 754
753(define-obsolete-variable-alias
754 'python-indent 'python-indent-offset "24.3")
755
756(define-obsolete-variable-alias
757 'python-guess-indent 'python-indent-guess-indent-offset "24.3")
758
759(defvar python-indent-current-level 0 755(defvar python-indent-current-level 0
760 "Deprecated var available for compatibility.") 756 "Deprecated var available for compatibility.")
761 757
@@ -785,7 +781,7 @@ work on `python-indent-calculate-indentation' instead."
785 (interactive) 781 (interactive)
786 (save-excursion 782 (save-excursion
787 (save-restriction 783 (save-restriction
788 (prog-widen) 784 (widen)
789 (goto-char (point-min)) 785 (goto-char (point-min))
790 (let ((block-end)) 786 (let ((block-end))
791 (while (and (not block-end) 787 (while (and (not block-end)
@@ -883,8 +879,6 @@ keyword
883:at-dedenter-block-start 879:at-dedenter-block-start
884 - Point is on a line starting a dedenter block. 880 - Point is on a line starting a dedenter block.
885 - START is the position where the dedenter block starts." 881 - START is the position where the dedenter block starts."
886 (save-restriction
887 (prog-widen)
888 (let ((ppss (save-excursion 882 (let ((ppss (save-excursion
889 (beginning-of-line) 883 (beginning-of-line)
890 (syntax-ppss)))) 884 (syntax-ppss))))
@@ -1022,7 +1016,7 @@ keyword
1022 (looking-at (python-rx block-ender))) 1016 (looking-at (python-rx block-ender)))
1023 :after-block-end) 1017 :after-block-end)
1024 (t :after-line)) 1018 (t :after-line))
1025 (point))))))))) 1019 (point))))))))
1026 1020
1027(defun python-indent--calculate-indentation () 1021(defun python-indent--calculate-indentation ()
1028 "Internal implementation of `python-indent-calculate-indentation'. 1022 "Internal implementation of `python-indent-calculate-indentation'.
@@ -1030,8 +1024,6 @@ May return an integer for the maximum possible indentation at
1030current context or a list of integers. The latter case is only 1024current context or a list of integers. The latter case is only
1031happening for :at-dedenter-block-start context since the 1025happening for :at-dedenter-block-start context since the
1032possibilities can be narrowed to specific indentation points." 1026possibilities can be narrowed to specific indentation points."
1033 (save-restriction
1034 (prog-widen)
1035 (save-excursion 1027 (save-excursion
1036 (pcase (python-indent-context) 1028 (pcase (python-indent-context)
1037 (`(:no-indent . ,_) (prog-first-column)) ; usually 0 1029 (`(:no-indent . ,_) (prog-first-column)) ; usually 0
@@ -1081,7 +1073,7 @@ possibilities can be narrowed to specific indentation points."
1081 (`(,(or :inside-paren-newline-start-from-block) . ,start) 1073 (`(,(or :inside-paren-newline-start-from-block) . ,start)
1082 ;; Add two indentation levels to make the suite stand out. 1074 ;; Add two indentation levels to make the suite stand out.
1083 (goto-char start) 1075 (goto-char start)
1084 (+ (current-indentation) (* python-indent-offset 2))))))) 1076 (+ (current-indentation) (* python-indent-offset 2))))))
1085 1077
1086(defun python-indent--calculate-levels (indentation) 1078(defun python-indent--calculate-levels (indentation)
1087 "Calculate levels list given INDENTATION. 1079 "Calculate levels list given INDENTATION.
@@ -2042,6 +2034,9 @@ executed through tramp connections."
2042 :type '(repeat string) 2034 :type '(repeat string)
2043 :group 'python) 2035 :group 'python)
2044 2036
2037(define-obsolete-variable-alias
2038 'python-shell-virtualenv-path 'python-shell-virtualenv-root "25.1")
2039
2045(defcustom python-shell-virtualenv-root nil 2040(defcustom python-shell-virtualenv-root nil
2046 "Path to virtualenv root. 2041 "Path to virtualenv root.
2047This variable, when set to a string, makes the environment to be 2042This variable, when set to a string, makes the environment to be
@@ -2050,9 +2045,6 @@ virtualenv."
2050 :type '(choice (const nil) string) 2045 :type '(choice (const nil) string)
2051 :group 'python) 2046 :group 'python)
2052 2047
2053(define-obsolete-variable-alias
2054 'python-shell-virtualenv-path 'python-shell-virtualenv-root "25.1")
2055
2056(defcustom python-shell-setup-codes nil 2048(defcustom python-shell-setup-codes nil
2057 "List of code run by `python-shell-send-setup-codes'." 2049 "List of code run by `python-shell-send-setup-codes'."
2058 :type '(repeat symbol) 2050 :type '(repeat symbol)
@@ -3289,14 +3281,6 @@ def __PYTHON_EL_get_completions(text):
3289 :type 'string 3281 :type 'string
3290 :group 'python) 3282 :group 'python)
3291 3283
3292(defcustom python-shell-completion-string-code
3293 "';'.join(__PYTHON_EL_get_completions('''%s'''))"
3294 "Python code used to get a string of completions separated by semicolons.
3295The string passed to the function is the current python name or
3296the full statement in the case of imports."
3297 :type 'string
3298 :group 'python)
3299
3300(define-obsolete-variable-alias 3284(define-obsolete-variable-alias
3301 'python-shell-completion-module-string-code 3285 'python-shell-completion-module-string-code
3302 'python-shell-completion-string-code 3286 'python-shell-completion-string-code
@@ -3309,6 +3293,14 @@ the full statement in the case of imports."
3309 "25.1" 3293 "25.1"
3310 "Completion string code must work for (i)pdb.") 3294 "Completion string code must work for (i)pdb.")
3311 3295
3296(defcustom python-shell-completion-string-code
3297 "';'.join(__PYTHON_EL_get_completions('''%s'''))"
3298 "Python code used to get a string of completions separated by semicolons.
3299The string passed to the function is the current python name or
3300the full statement in the case of imports."
3301 :type 'string
3302 :group 'python)
3303
3312(defcustom python-shell-completion-native-disabled-interpreters 3304(defcustom python-shell-completion-native-disabled-interpreters
3313 ;; PyPy's readline cannot handle some escape sequences yet. Native 3305 ;; PyPy's readline cannot handle some escape sequences yet. Native
3314 ;; completion was found to be non-functional for IPython (see 3306 ;; completion was found to be non-functional for IPython (see
@@ -4040,6 +4032,9 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'."
4040 4032
4041;;; Skeletons 4033;;; Skeletons
4042 4034
4035(define-obsolete-variable-alias
4036 'python-use-skeletons 'python-skeleton-autoinsert "24.3")
4037
4043(defcustom python-skeleton-autoinsert nil 4038(defcustom python-skeleton-autoinsert nil
4044 "Non-nil means template skeletons will be automagically inserted. 4039 "Non-nil means template skeletons will be automagically inserted.
4045This happens when pressing \"if<SPACE>\", for example, to prompt for 4040This happens when pressing \"if<SPACE>\", for example, to prompt for
@@ -4048,9 +4043,6 @@ the if condition."
4048 :group 'python 4043 :group 'python
4049 :safe 'booleanp) 4044 :safe 'booleanp)
4050 4045
4051(define-obsolete-variable-alias
4052 'python-use-skeletons 'python-skeleton-autoinsert "24.3")
4053
4054(defvar python-skeleton-available '() 4046(defvar python-skeleton-available '()
4055 "Internal list of available skeletons.") 4047 "Internal list of available skeletons.")
4056 4048
@@ -4593,7 +4585,7 @@ Optional argument INCLUDE-TYPE indicates to include the type of the defun.
4593This function can be used as the value of `add-log-current-defun-function' 4585This function can be used as the value of `add-log-current-defun-function'
4594since it returns nil if point is not inside a defun." 4586since it returns nil if point is not inside a defun."
4595 (save-restriction 4587 (save-restriction
4596 (prog-widen) 4588 (widen)
4597 (save-excursion 4589 (save-excursion
4598 (end-of-line 1) 4590 (end-of-line 1)
4599 (let ((names) 4591 (let ((names)
@@ -4791,12 +4783,10 @@ likely an invalid python file."
4791 "Message the first line of the block the current statement closes." 4783 "Message the first line of the block the current statement closes."
4792 (let ((point (python-info-dedenter-opening-block-position))) 4784 (let ((point (python-info-dedenter-opening-block-position)))
4793 (when point 4785 (when point
4794 (save-restriction
4795 (prog-widen)
4796 (message "Closes %s" (save-excursion 4786 (message "Closes %s" (save-excursion
4797 (goto-char point) 4787 (goto-char point)
4798 (buffer-substring 4788 (buffer-substring
4799 (point) (line-end-position)))))))) 4789 (point) (line-end-position)))))))
4800 4790
4801(defun python-info-dedenter-statement-p () 4791(defun python-info-dedenter-statement-p ()
4802 "Return point if current statement is a dedenter. 4792 "Return point if current statement is a dedenter.
@@ -4812,8 +4802,6 @@ statement."
4812 "Return non-nil if current line ends with backslash. 4802 "Return non-nil if current line ends with backslash.
4813With optional argument LINE-NUMBER, check that line instead." 4803With optional argument LINE-NUMBER, check that line instead."
4814 (save-excursion 4804 (save-excursion
4815 (save-restriction
4816 (prog-widen)
4817 (when line-number 4805 (when line-number
4818 (python-util-goto-line line-number)) 4806 (python-util-goto-line line-number))
4819 (while (and (not (eobp)) 4807 (while (and (not (eobp))
@@ -4822,14 +4810,12 @@ With optional argument LINE-NUMBER, check that line instead."
4822 (not (equal (char-before (point)) ?\\))) 4810 (not (equal (char-before (point)) ?\\)))
4823 (forward-line 1)) 4811 (forward-line 1))
4824 (when (equal (char-before) ?\\) 4812 (when (equal (char-before) ?\\)
4825 (point-marker))))) 4813 (point-marker))))
4826 4814
4827(defun python-info-beginning-of-backslash (&optional line-number) 4815(defun python-info-beginning-of-backslash (&optional line-number)
4828 "Return the point where the backslashed line starts. 4816 "Return the point where the backslashed line starts.
4829Optional argument LINE-NUMBER forces the line number to check against." 4817Optional argument LINE-NUMBER forces the line number to check against."
4830 (save-excursion 4818 (save-excursion
4831 (save-restriction
4832 (prog-widen)
4833 (when line-number 4819 (when line-number
4834 (python-util-goto-line line-number)) 4820 (python-util-goto-line line-number))
4835 (when (python-info-line-ends-backslash-p) 4821 (when (python-info-line-ends-backslash-p)
@@ -4838,15 +4824,13 @@ Optional argument LINE-NUMBER forces the line number to check against."
4838 (python-syntax-context 'paren)) 4824 (python-syntax-context 'paren))
4839 (forward-line -1)) 4825 (forward-line -1))
4840 (back-to-indentation) 4826 (back-to-indentation)
4841 (point-marker))))) 4827 (point-marker))))
4842 4828
4843(defun python-info-continuation-line-p () 4829(defun python-info-continuation-line-p ()
4844 "Check if current line is continuation of another. 4830 "Check if current line is continuation of another.
4845When current line is continuation of another return the point 4831When current line is continuation of another return the point
4846where the continued line ends." 4832where the continued line ends."
4847 (save-excursion 4833 (save-excursion
4848 (save-restriction
4849 (prog-widen)
4850 (let* ((context-type (progn 4834 (let* ((context-type (progn
4851 (back-to-indentation) 4835 (back-to-indentation)
4852 (python-syntax-context-type))) 4836 (python-syntax-context-type)))
@@ -4872,7 +4856,7 @@ where the continued line ends."
4872 (python-util-forward-comment -1) 4856 (python-util-forward-comment -1)
4873 (when (and (equal (1- line-start) (line-number-at-pos)) 4857 (when (and (equal (1- line-start) (line-number-at-pos))
4874 (python-info-line-ends-backslash-p)) 4858 (python-info-line-ends-backslash-p))
4875 (point-marker)))))))) 4859 (point-marker)))))))
4876 4860
4877(defun python-info-block-continuation-line-p () 4861(defun python-info-block-continuation-line-p ()
4878 "Return non-nil if current line is a continuation of a block." 4862 "Return non-nil if current line is a continuation of a block."