;;; Navigation
(defvar python-nav-beginning-of-defun-regexp
- (python-rx line-start (* space) defun (+ space) symbol-name)
- "Regular expresion matching beginning of innermost class or function.")
+ (python-rx line-start (* space) defun (+ space) (group symbol-name))
+ "Regular expresion matching beginning of class or function.
+The name of the class or function should be in a group so it can
+be retrieved via `match-string'.")
(defun python-nav-beginning-of-defun (&optional nodecorators)
"Move point to `beginning-of-defun'.
(when (or (not min-indent)
(< (current-indentation) min-indent))
(setq min-indent (current-indentation))
- (back-to-indentation)
- (looking-at "\\(?:def\\|class\\) +\\([^(]+\\)[^:]+:\\s-*\n")
+ (looking-at python-nav-beginning-of-defun-regexp)
(setq names (cons (match-string-no-properties 1) names))))))
(when names
(mapconcat (lambda (string) string) names "."))))