diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 5aeefe47a54..90097df7ef1 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -283,18 +283,6 @@ | |||
| 283 | :version "24.3" | 283 | :version "24.3" |
| 284 | :link '(emacs-commentary-link "python")) | 284 | :link '(emacs-commentary-link "python")) |
| 285 | 285 | ||
| 286 | |||
| 287 | ;;; 24.x Compat | ||
| 288 | |||
| 289 | |||
| 290 | (unless (fboundp 'prog-widen) | ||
| 291 | (defun prog-widen () | ||
| 292 | (widen))) | ||
| 293 | |||
| 294 | (unless (fboundp 'prog-first-column) | ||
| 295 | (defun prog-first-column () | ||
| 296 | 0)) | ||
| 297 | |||
| 298 | 286 | ||
| 299 | ;;; Bindings | 287 | ;;; Bindings |
| 300 | 288 | ||
| @@ -761,7 +749,7 @@ work on `python-indent-calculate-indentation' instead." | |||
| 761 | (interactive) | 749 | (interactive) |
| 762 | (save-excursion | 750 | (save-excursion |
| 763 | (save-restriction | 751 | (save-restriction |
| 764 | (prog-widen) | 752 | (widen) |
| 765 | (goto-char (point-min)) | 753 | (goto-char (point-min)) |
| 766 | (let ((block-end)) | 754 | (let ((block-end)) |
| 767 | (while (and (not block-end) | 755 | (while (and (not block-end) |
| @@ -860,7 +848,7 @@ keyword | |||
| 860 | - Point is on a line starting a dedenter block. | 848 | - Point is on a line starting a dedenter block. |
| 861 | - START is the position where the dedenter block starts." | 849 | - START is the position where the dedenter block starts." |
| 862 | (save-restriction | 850 | (save-restriction |
| 863 | (prog-widen) | 851 | (widen) |
| 864 | (let ((ppss (save-excursion | 852 | (let ((ppss (save-excursion |
| 865 | (beginning-of-line) | 853 | (beginning-of-line) |
| 866 | (syntax-ppss)))) | 854 | (syntax-ppss)))) |
| @@ -1007,10 +995,10 @@ current context or a list of integers. The latter case is only | |||
| 1007 | happening for :at-dedenter-block-start context since the | 995 | happening for :at-dedenter-block-start context since the |
| 1008 | possibilities can be narrowed to specific indentation points." | 996 | possibilities can be narrowed to specific indentation points." |
| 1009 | (save-restriction | 997 | (save-restriction |
| 1010 | (prog-widen) | 998 | (widen) |
| 1011 | (save-excursion | 999 | (save-excursion |
| 1012 | (pcase (python-indent-context) | 1000 | (pcase (python-indent-context) |
| 1013 | (`(:no-indent . ,_) (prog-first-column)) ; usually 0 | 1001 | (`(:no-indent . ,_) 0) |
| 1014 | (`(,(or :after-line | 1002 | (`(,(or :after-line |
| 1015 | :after-comment | 1003 | :after-comment |
| 1016 | :inside-string | 1004 | :inside-string |
| @@ -1048,7 +1036,7 @@ possibilities can be narrowed to specific indentation points." | |||
| 1048 | (let ((opening-block-start-points | 1036 | (let ((opening-block-start-points |
| 1049 | (python-info-dedenter-opening-block-positions))) | 1037 | (python-info-dedenter-opening-block-positions))) |
| 1050 | (if (not opening-block-start-points) | 1038 | (if (not opening-block-start-points) |
| 1051 | (prog-first-column) ; if not found default to first column | 1039 | 0 ; if not found default to first column |
| 1052 | (mapcar (lambda (pos) | 1040 | (mapcar (lambda (pos) |
| 1053 | (save-excursion | 1041 | (save-excursion |
| 1054 | (goto-char pos) | 1042 | (goto-char pos) |
| @@ -1066,7 +1054,7 @@ integers. Levels are returned in ascending order, and in the | |||
| 1066 | case INDENTATION is a list, this order is enforced." | 1054 | case INDENTATION is a list, this order is enforced." |
| 1067 | (if (listp indentation) | 1055 | (if (listp indentation) |
| 1068 | (sort (copy-sequence indentation) #'<) | 1056 | (sort (copy-sequence indentation) #'<) |
| 1069 | (nconc (number-sequence (prog-first-column) (1- indentation) | 1057 | (nconc (number-sequence 0 (1- indentation) |
| 1070 | python-indent-offset) | 1058 | python-indent-offset) |
| 1071 | (list indentation)))) | 1059 | (list indentation)))) |
| 1072 | 1060 | ||
| @@ -1091,7 +1079,7 @@ minimum." | |||
| 1091 | (python-indent--previous-level levels (current-indentation)) | 1079 | (python-indent--previous-level levels (current-indentation)) |
| 1092 | (if levels | 1080 | (if levels |
| 1093 | (apply #'max levels) | 1081 | (apply #'max levels) |
| 1094 | (prog-first-column))))) | 1082 | 0)))) |
| 1095 | 1083 | ||
| 1096 | (defun python-indent-line (&optional previous) | 1084 | (defun python-indent-line (&optional previous) |
| 1097 | "Internal implementation of `python-indent-line-function'. | 1085 | "Internal implementation of `python-indent-line-function'. |
| @@ -4479,7 +4467,7 @@ Optional argument INCLUDE-TYPE indicates to include the type of the defun. | |||
| 4479 | This function can be used as the value of `add-log-current-defun-function' | 4467 | This function can be used as the value of `add-log-current-defun-function' |
| 4480 | since it returns nil if point is not inside a defun." | 4468 | since it returns nil if point is not inside a defun." |
| 4481 | (save-restriction | 4469 | (save-restriction |
| 4482 | (prog-widen) | 4470 | (widen) |
| 4483 | (save-excursion | 4471 | (save-excursion |
| 4484 | (end-of-line 1) | 4472 | (end-of-line 1) |
| 4485 | (let ((names) | 4473 | (let ((names) |
| @@ -4662,7 +4650,7 @@ likely an invalid python file." | |||
| 4662 | (let ((point (python-info-dedenter-opening-block-position))) | 4650 | (let ((point (python-info-dedenter-opening-block-position))) |
| 4663 | (when point | 4651 | (when point |
| 4664 | (save-restriction | 4652 | (save-restriction |
| 4665 | (prog-widen) | 4653 | (widen) |
| 4666 | (message "Closes %s" (save-excursion | 4654 | (message "Closes %s" (save-excursion |
| 4667 | (goto-char point) | 4655 | (goto-char point) |
| 4668 | (buffer-substring | 4656 | (buffer-substring |
| @@ -4683,7 +4671,7 @@ statement." | |||
| 4683 | With optional argument LINE-NUMBER, check that line instead." | 4671 | With optional argument LINE-NUMBER, check that line instead." |
| 4684 | (save-excursion | 4672 | (save-excursion |
| 4685 | (save-restriction | 4673 | (save-restriction |
| 4686 | (prog-widen) | 4674 | (widen) |
| 4687 | (when line-number | 4675 | (when line-number |
| 4688 | (python-util-goto-line line-number)) | 4676 | (python-util-goto-line line-number)) |
| 4689 | (while (and (not (eobp)) | 4677 | (while (and (not (eobp)) |
| @@ -4699,7 +4687,7 @@ With optional argument LINE-NUMBER, check that line instead." | |||
| 4699 | Optional argument LINE-NUMBER forces the line number to check against." | 4687 | Optional argument LINE-NUMBER forces the line number to check against." |
| 4700 | (save-excursion | 4688 | (save-excursion |
| 4701 | (save-restriction | 4689 | (save-restriction |
| 4702 | (prog-widen) | 4690 | (widen) |
| 4703 | (when line-number | 4691 | (when line-number |
| 4704 | (python-util-goto-line line-number)) | 4692 | (python-util-goto-line line-number)) |
| 4705 | (when (python-info-line-ends-backslash-p) | 4693 | (when (python-info-line-ends-backslash-p) |
| @@ -4716,7 +4704,7 @@ When current line is continuation of another return the point | |||
| 4716 | where the continued line ends." | 4704 | where the continued line ends." |
| 4717 | (save-excursion | 4705 | (save-excursion |
| 4718 | (save-restriction | 4706 | (save-restriction |
| 4719 | (prog-widen) | 4707 | (widen) |
| 4720 | (let* ((context-type (progn | 4708 | (let* ((context-type (progn |
| 4721 | (back-to-indentation) | 4709 | (back-to-indentation) |
| 4722 | (python-syntax-context-type))) | 4710 | (python-syntax-context-type))) |