From 1e66c8af402176e9f1b5f3fbdbf5f796fec79079 Mon Sep 17 00:00:00 2001 From: kobarity Date: Sat, 28 May 2022 18:51:01 +0200 Subject: 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). --- lisp/progmodes/python.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 9adbb82abf4..c2483436fe9 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -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'.") -- cgit v1.2.1