diff options
| author | Tomas Nordin | 2020-12-14 16:58:07 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-12-14 16:58:07 +0100 |
| commit | 8b3de06347dfcb4afab93f17f32297fe721b363b (patch) | |
| tree | f7b827eff170ee18f886368d2dbdd01924ef295a /lisp/progmodes/python.el | |
| parent | 252366866b5691965c8c752aa103ab157a6f3aaa (diff) | |
| download | emacs-8b3de06347dfcb4afab93f17f32297fe721b363b.tar.gz emacs-8b3de06347dfcb4afab93f17f32297fe721b363b.zip | |
Fix narrow-to-defun in python-mode
* lisp/progmodes/python.el (python-nav--beginning-of-defun): Make
narrow-to-defun work better in classes (bug#40563).
Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d75944a702f..d58b32f3c3c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1404,7 +1404,7 @@ With positive ARG search backwards, else search forwards." | |||
| 1404 | (line-beg-pos (line-beginning-position)) | 1404 | (line-beg-pos (line-beginning-position)) |
| 1405 | (line-content-start (+ line-beg-pos (current-indentation))) | 1405 | (line-content-start (+ line-beg-pos (current-indentation))) |
| 1406 | (pos (point-marker)) | 1406 | (pos (point-marker)) |
| 1407 | (beg-indentation | 1407 | (body-indentation |
| 1408 | (and (> arg 0) | 1408 | (and (> arg 0) |
| 1409 | (save-excursion | 1409 | (save-excursion |
| 1410 | (while (and | 1410 | (while (and |
| @@ -1415,9 +1415,16 @@ With positive ARG search backwards, else search forwards." | |||
| 1415 | 0)))) | 1415 | 0)))) |
| 1416 | (found | 1416 | (found |
| 1417 | (progn | 1417 | (progn |
| 1418 | (when (and (< arg 0) | 1418 | (when (and (python-info-looking-at-beginning-of-defun) |
| 1419 | (python-info-looking-at-beginning-of-defun)) | 1419 | (or (< arg 0) |
| 1420 | ;; If looking at beginning of defun, and if | ||
| 1421 | ;; pos is > line-content-start, ensure a | ||
| 1422 | ;; backward re search match this defun by | ||
| 1423 | ;; going to end of line before calling | ||
| 1424 | ;; re-search-fn bug#40563 | ||
| 1425 | (and (> arg 0) (> pos line-content-start)))) | ||
| 1420 | (end-of-line 1)) | 1426 | (end-of-line 1)) |
| 1427 | |||
| 1421 | (while (and (funcall re-search-fn | 1428 | (while (and (funcall re-search-fn |
| 1422 | python-nav-beginning-of-defun-regexp nil t) | 1429 | python-nav-beginning-of-defun-regexp nil t) |
| 1423 | (or (python-syntax-context-type) | 1430 | (or (python-syntax-context-type) |
| @@ -1425,7 +1432,7 @@ With positive ARG search backwards, else search forwards." | |||
| 1425 | ;; backwards by checking indentation. | 1432 | ;; backwards by checking indentation. |
| 1426 | (and (> arg 0) | 1433 | (and (> arg 0) |
| 1427 | (not (= (current-indentation) 0)) | 1434 | (not (= (current-indentation) 0)) |
| 1428 | (>= (current-indentation) beg-indentation))))) | 1435 | (>= (current-indentation) body-indentation))))) |
| 1429 | (and (python-info-looking-at-beginning-of-defun) | 1436 | (and (python-info-looking-at-beginning-of-defun) |
| 1430 | (or (not (= (line-number-at-pos pos) | 1437 | (or (not (= (line-number-at-pos pos) |
| 1431 | (line-number-at-pos))) | 1438 | (line-number-at-pos))) |