Fix Python Hideshow problem with backslash escaped newlines

* lisp/progmodes/python.el (python-rx)
(python-nav-beginning-of-defun-regexp): Allow
python-nav-*-defun to handle backslash escaped newlines
(bug#55690).
This commit is contained in:
kobarity 2022-05-28 18:51:01 +02:00 committed by Lars Ingebrigtsen
parent 5d8b6ba89e
commit 1e66c8af40
2 changed files with 57 additions and 2 deletions

View file

@ -359,7 +359,8 @@
(defmacro python-rx (&rest regexps)
"Python mode specialized rx macro.
This variant of `rx' supports common Python named REGEXPS."
`(rx-let ((block-start (seq symbol-start
`(rx-let ((sp-bsnl (or space (and ?\\ ?\n)))
(block-start (seq symbol-start
(or "def" "class" "if" "elif" "else" "try"
"except" "finally" "for" "while" "with"
;; Python 3.10+ PEP634
@ -1439,7 +1440,7 @@ marks the next defun after the ones already marked."
function))
(defvar python-nav-beginning-of-defun-regexp
(python-rx line-start (* space) defun (+ space) (group symbol-name))
(python-rx line-start (* space) defun (+ sp-bsnl) (group symbol-name))
"Regexp matching class or function definition.
The name of the defun should be grouped so it can be retrieved
via `match-string'.")