diff options
| author | Noam Postavsky | 2020-09-20 10:46:16 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-09-20 10:46:16 +0200 |
| commit | a68a0e69da11430401eb4868ee1bd1c88ae869d4 (patch) | |
| tree | 6fcf8ce102d5f2595137d1a3a24f60e44c9f3647 /lisp/progmodes/python.el | |
| parent | 1278a9a907e59b22d8e20a806055c7cb92959017 (diff) | |
| download | emacs-a68a0e69da11430401eb4868ee1bd1c88ae869d4.tar.gz emacs-a68a0e69da11430401eb4868ee1bd1c88ae869d4.zip | |
Fix slow python-mode inserts when there's a lot of strings
* lisp/progmodes/python.el (python-info-docstring-p): Doing more
than two repetitions here doesn't improve indentation (bug#39598).
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ccbcb081305..d2eb5f268bd 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -5129,21 +5129,22 @@ point's current `syntax-ppss'." | |||
| 5129 | (>= | 5129 | (>= |
| 5130 | 2 | 5130 | 2 |
| 5131 | (let (last-backward-sexp-point) | 5131 | (let (last-backward-sexp-point) |
| 5132 | (while (save-excursion | 5132 | (while (and (<= counter 2) |
| 5133 | (python-nav-backward-sexp) | 5133 | (save-excursion |
| 5134 | (setq backward-sexp-point (point)) | 5134 | (python-nav-backward-sexp) |
| 5135 | (and (= indentation (current-indentation)) | 5135 | (setq backward-sexp-point (point)) |
| 5136 | ;; Make sure we're always moving point. | 5136 | (and (= indentation (current-indentation)) |
| 5137 | ;; If we get stuck in the same position | 5137 | ;; Make sure we're always moving point. |
| 5138 | ;; on consecutive loop iterations, | 5138 | ;; If we get stuck in the same position |
| 5139 | ;; bail out. | 5139 | ;; on consecutive loop iterations, |
| 5140 | (prog1 (not (eql last-backward-sexp-point | 5140 | ;; bail out. |
| 5141 | backward-sexp-point)) | 5141 | (prog1 (not (eql last-backward-sexp-point |
| 5142 | (setq last-backward-sexp-point | 5142 | backward-sexp-point)) |
| 5143 | backward-sexp-point)) | 5143 | (setq last-backward-sexp-point |
| 5144 | (looking-at-p | 5144 | backward-sexp-point)) |
| 5145 | (concat "[uU]?[rR]?" | 5145 | (looking-at-p |
| 5146 | (python-rx string-delimiter))))) | 5146 | (concat "[uU]?[rR]?" |
| 5147 | (python-rx string-delimiter)))))) | ||
| 5147 | ;; Previous sexp was a string, restore point. | 5148 | ;; Previous sexp was a string, restore point. |
| 5148 | (goto-char backward-sexp-point) | 5149 | (goto-char backward-sexp-point) |
| 5149 | (cl-incf counter)) | 5150 | (cl-incf counter)) |