diff options
| author | kobarity | 2022-07-03 14:22:13 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-07-03 14:23:25 +0200 |
| commit | 6e2f9dd3dd8b3c65608366039ce69666905d80cb (patch) | |
| tree | 5231d795049ffc2314b0f5198ff773f6739caf3e /lisp/progmodes/python.el | |
| parent | c61c647f7272faf625b5584035d455e81d1ebd0e (diff) | |
| download | emacs-6e2f9dd3dd8b3c65608366039ce69666905d80cb.tar.gz emacs-6e2f9dd3dd8b3c65608366039ce69666905d80cb.zip | |
Fix `python-nav-beginning-of-defun' line continuation using backslash
* lisp/progmodes/python.el (python-nav--beginning-of-defun): Allow
line continuation using backslash in defuns (bug#55702).
(python-info-looking-at-beginning-of-defun): Add CHECK-STATEMENT
argument.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 16cdf58611a..7a626ae35ee 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1472,15 +1472,17 @@ With positive ARG search backwards, else search forwards." | |||
| 1472 | 0)))) | 1472 | 0)))) |
| 1473 | (found | 1473 | (found |
| 1474 | (progn | 1474 | (progn |
| 1475 | (when (and (python-info-looking-at-beginning-of-defun) | 1475 | (when (and (python-info-looking-at-beginning-of-defun nil t) |
| 1476 | (or (< arg 0) | 1476 | (or (< arg 0) |
| 1477 | ;; If looking at beginning of defun, and if | 1477 | ;; If looking at beginning of defun, and if |
| 1478 | ;; pos is > line-content-start, ensure a | 1478 | ;; pos is > line-content-start, ensure a |
| 1479 | ;; backward re search match this defun by | 1479 | ;; backward re search match this defun by |
| 1480 | ;; going to end of line before calling | 1480 | ;; going to end of line before calling |
| 1481 | ;; re-search-fn bug#40563 | 1481 | ;; re-search-fn bug#40563 |
| 1482 | (and (> arg 0) (> pos line-content-start)))) | 1482 | (and (> arg 0) |
| 1483 | (end-of-line 1)) | 1483 | (or (python-info-continuation-line-p) |
| 1484 | (> pos line-content-start))))) | ||
| 1485 | (python-nav-end-of-statement)) | ||
| 1484 | 1486 | ||
| 1485 | (while (and (funcall re-search-fn | 1487 | (while (and (funcall re-search-fn |
| 1486 | python-nav-beginning-of-defun-regexp nil t) | 1488 | python-nav-beginning-of-defun-regexp nil t) |
| @@ -1490,14 +1492,18 @@ With positive ARG search backwards, else search forwards." | |||
| 1490 | (and (> arg 0) | 1492 | (and (> arg 0) |
| 1491 | (not (= (current-indentation) 0)) | 1493 | (not (= (current-indentation) 0)) |
| 1492 | (>= (current-indentation) body-indentation))))) | 1494 | (>= (current-indentation) body-indentation))))) |
| 1493 | (and (python-info-looking-at-beginning-of-defun) | 1495 | (and (python-info-looking-at-beginning-of-defun nil t) |
| 1494 | (or (not (= (line-number-at-pos pos) | 1496 | (or (not (= (line-number-at-pos pos) |
| 1495 | (line-number-at-pos))) | 1497 | (line-number-at-pos))) |
| 1496 | (and (>= (point) line-beg-pos) | 1498 | (and (>= (point) line-beg-pos) |
| 1497 | (<= (point) line-content-start) | 1499 | (<= (point) line-content-start) |
| 1498 | (> pos line-content-start))))))) | 1500 | (> pos line-content-start))))))) |
| 1499 | (if found | 1501 | (if found |
| 1500 | (or (beginning-of-line 1) t) | 1502 | (progn |
| 1503 | (when (< arg 0) | ||
| 1504 | (python-nav-beginning-of-statement)) | ||
| 1505 | (beginning-of-line 1) | ||
| 1506 | t) | ||
| 1501 | (and (goto-char pos) nil)))) | 1507 | (and (goto-char pos) nil)))) |
| 1502 | 1508 | ||
| 1503 | (defun python-nav-beginning-of-defun (&optional arg) | 1509 | (defun python-nav-beginning-of-defun (&optional arg) |
| @@ -5299,10 +5305,15 @@ operator." | |||
| 5299 | (forward-line -1) | 5305 | (forward-line -1) |
| 5300 | (python-info-assignment-statement-p t)))) | 5306 | (python-info-assignment-statement-p t)))) |
| 5301 | 5307 | ||
| 5302 | (defun python-info-looking-at-beginning-of-defun (&optional syntax-ppss) | 5308 | (defun python-info-looking-at-beginning-of-defun (&optional syntax-ppss |
| 5303 | "Check if point is at `beginning-of-defun' using SYNTAX-PPSS." | 5309 | check-statement) |
| 5310 | "Check if point is at `beginning-of-defun' using SYNTAX-PPSS. | ||
| 5311 | When CHECK-STATEMENT is non-nil, the current statement is checked | ||
| 5312 | instead of the current physical line." | ||
| 5304 | (and (not (python-syntax-context-type (or syntax-ppss (syntax-ppss)))) | 5313 | (and (not (python-syntax-context-type (or syntax-ppss (syntax-ppss)))) |
| 5305 | (save-excursion | 5314 | (save-excursion |
| 5315 | (when check-statement | ||
| 5316 | (python-nav-beginning-of-statement)) | ||
| 5306 | (beginning-of-line 1) | 5317 | (beginning-of-line 1) |
| 5307 | (looking-at python-nav-beginning-of-defun-regexp)))) | 5318 | (looking-at python-nav-beginning-of-defun-regexp)))) |
| 5308 | 5319 | ||