"Check if point is at `beginning-of-defun' using SYNTAX-PPSS.
When CHECK-STATEMENT is non-nil, the current statement is checked
instead of the current physical line."
- (and (not (python-syntax-context-type (or syntax-ppss (syntax-ppss))))
- (save-excursion
- (when check-statement
- (python-nav-beginning-of-statement))
- (beginning-of-line 1)
+ (save-excursion
+ (when check-statement
+ (python-nav-beginning-of-statement))
+ (beginning-of-line 1)
+ (and (not (python-syntax-context-type (or syntax-ppss (syntax-ppss))))
(looking-at python-nav-beginning-of-defun-regexp))))
(defun python-info-looking-at-beginning-of-block ()
(beginning-of-line)
(point))))))
+(ert-deftest python-nav-beginning-of-defun-6 ()
+ (python-tests-with-temp-buffer
+ "
+class C:
+ def foo(self):
+ pass
+"
+ (python-tests-look-at "self")
+ (should (= (save-excursion
+ (python-nav-beginning-of-defun)
+ (point))
+ (save-excursion
+ (beginning-of-line)
+ (point))))))
+
(ert-deftest python-nav-end-of-defun-1 ()
(python-tests-with-temp-buffer
"
(save-excursion
(point-max))))))
+(ert-deftest python-end-of-defun-1 ()
+ (python-tests-with-temp-buffer
+ "
+class C:
+ def a(self
+ ):
+ pass
+
+ def b(self):
+ pass
+"
+ (should (= (save-excursion
+ (python-tests-look-at "def a")
+ (end-of-defun)
+ (point))
+ (save-excursion
+ (python-tests-look-at "def b")
+ (forward-line -1)
+ (point))))))
+
(ert-deftest python-nav-backward-defun-1 ()
(python-tests-with-temp-buffer
"
(should (not (python-info-looking-at-beginning-of-defun)))
(should (not (python-info-looking-at-beginning-of-defun nil t)))))
+(ert-deftest python-info-looking-at-beginning-of-defun-3 ()
+ (python-tests-with-temp-buffer
+ "
+def foo(arg=\"default\"): # Comment
+ pass
+"
+ (python-tests-look-at "arg")
+ (should (python-info-looking-at-beginning-of-defun))
+ (python-tests-look-at "default")
+ (should (python-info-looking-at-beginning-of-defun))
+ (python-tests-look-at "Comment")
+ (should (python-info-looking-at-beginning-of-defun))))
+
(ert-deftest python-info-looking-at-beginning-of-block-1 ()
(python-tests-with-temp-buffer
"