@@ -1506,7 +1506,7 @@ point position. Return non-nil if point is moved to
15061506(defun python-nav-end-of-defun ()
15071507 " Move point to the end of def or class.
15081508Returns nil if point is not in a def or class."
1509- (interactive )
1509+ (interactive nil python-mode )
15101510 (let ((beg-defun-indent)
15111511 (beg-pos (point )))
15121512 (when (or (python-info-looking-at-beginning-of-defun )
@@ -1577,19 +1577,19 @@ repeat it."
15771577 " Navigate to closer defun backward ARG times.
15781578Unlikely `python-nav-beginning-of-defun' this doesn't care about
15791579nested definitions."
1580- (interactive " ^p" )
1580+ (interactive " ^p" python-mode )
15811581 (python-nav--forward-defun (- (or arg 1 ))))
15821582
15831583(defun python-nav-forward-defun (&optional arg )
15841584 " Navigate to closer defun forward ARG times.
15851585Unlikely `python-nav-beginning-of-defun' this doesn't care about
15861586nested definitions."
1587- (interactive " ^p" )
1587+ (interactive " ^p" python-mode )
15881588 (python-nav--forward-defun (or arg 1 )))
15891589
15901590(defun python-nav-beginning-of-statement ()
15911591 " Move to start of current statement."
1592- (interactive " ^" )
1592+ (interactive " ^" python-mode )
15931593 (forward-line 0 )
15941594 (let* ((ppss (syntax-ppss ))
15951595 (context-point
@@ -1613,7 +1613,7 @@ nested definitions."
16131613Optional argument NOEND is internal and makes the logic to not
16141614jump to the end of line when moving forward searching for the end
16151615of the statement."
1616- (interactive " ^" )
1616+ (interactive " ^" python-mode )
16171617 (let (string-start bs-pos (last-string-end 0 ))
16181618 (while (and (or noend (goto-char (line-end-position )))
16191619 (not (eobp ))
@@ -1654,15 +1654,15 @@ Overlapping strings detected (start=%d, last-end=%d)")
16541654(defun python-nav-backward-statement (&optional arg )
16551655 " Move backward to previous statement.
16561656With ARG, repeat. See `python-nav-forward-statement' ."
1657- (interactive " ^p" )
1657+ (interactive " ^p" python-mode )
16581658 (or arg (setq arg 1 ))
16591659 (python-nav-forward-statement (- arg)))
16601660
16611661(defun python-nav-forward-statement (&optional arg )
16621662 " Move forward to next statement.
16631663With ARG, repeat. With negative argument, move ARG times
16641664backward to previous statement."
1665- (interactive " ^p" )
1665+ (interactive " ^p" python-mode )
16661666 (or arg (setq arg 1 ))
16671667 (while (> arg 0 )
16681668 (python-nav-end-of-statement )
@@ -1677,7 +1677,7 @@ backward to previous statement."
16771677
16781678(defun python-nav-beginning-of-block ()
16791679 " Move to start of current block."
1680- (interactive " ^" )
1680+ (interactive " ^" python-mode )
16811681 (let ((starting-pos (point )))
16821682 (if (progn
16831683 (python-nav-beginning-of-statement )
@@ -1701,7 +1701,7 @@ backward to previous statement."
17011701
17021702(defun python-nav-end-of-block ()
17031703 " Move to end of current block."
1704- (interactive " ^" )
1704+ (interactive " ^" python-mode )
17051705 (when (python-nav-beginning-of-block )
17061706 (let ((block-indentation (current-indentation )))
17071707 (python-nav-end-of-statement )
@@ -1717,15 +1717,15 @@ backward to previous statement."
17171717(defun python-nav-backward-block (&optional arg )
17181718 " Move backward to previous block of code.
17191719With ARG, repeat. See `python-nav-forward-block' ."
1720- (interactive " ^p" )
1720+ (interactive " ^p" python-mode )
17211721 (or arg (setq arg 1 ))
17221722 (python-nav-forward-block (- arg)))
17231723
17241724(defun python-nav-forward-block (&optional arg )
17251725 " Move forward to next block of code.
17261726With ARG, repeat. With negative argument, move ARG times
17271727backward to previous block."
1728- (interactive " ^p" )
1728+ (interactive " ^p" python-mode )
17291729 (or arg (setq arg 1 ))
17301730 (let ((block-start-regexp
17311731 (python-rx line-start (* whitespace) block-start))
@@ -1878,7 +1878,7 @@ throw errors when at end of sexp, skip it instead. With optional
18781878argument SKIP-PARENS-P force sexp motion to ignore parenthesized
18791879expressions when looking at them in either direction (forced to t
18801880in interactive calls)."
1881- (interactive " ^p" )
1881+ (interactive " ^p" python-mode )
18821882 (or arg (setq arg 1 ))
18831883 ; ; Do not follow parens on interactive calls. This hack to detect
18841884 ; ; if the function was called interactively copes with the way
@@ -1912,7 +1912,7 @@ throw errors when at end of sexp, skip it instead. With optional
19121912argument SKIP-PARENS-P force sexp motion to ignore parenthesized
19131913expressions when looking at them in either direction (forced to t
19141914in interactive calls)."
1915- (interactive " ^p" )
1915+ (interactive " ^p" python-mode )
19161916 (or arg (setq arg 1 ))
19171917 (python-nav-forward-sexp (- arg) safe skip-parens-p))
19181918
@@ -1922,7 +1922,7 @@ With ARG, do it that many times. Negative arg -N means move
19221922backward N times. With optional argument SKIP-PARENS-P force
19231923sexp motion to ignore parenthesized expressions when looking at
19241924them in either direction (forced to t in interactive calls)."
1925- (interactive " ^p" )
1925+ (interactive " ^p" python-mode )
19261926 (python-nav-forward-sexp arg t skip-parens-p))
19271927
19281928(defun python-nav-backward-sexp-safe (&optional arg skip-parens-p )
@@ -1931,7 +1931,7 @@ With ARG, do it that many times. Negative arg -N means move
19311931forward N times. With optional argument SKIP-PARENS-P force sexp
19321932motion to ignore parenthesized expressions when looking at them in
19331933either direction (forced to t in interactive calls)."
1934- (interactive " ^p" )
1934+ (interactive " ^p" python-mode )
19351935 (python-nav-backward-sexp arg t skip-parens-p))
19361936
19371937(defun python-nav--up-list (&optional dir )
@@ -1977,7 +1977,7 @@ DIR is always 1 or -1 and comes sanitized from
19771977With ARG, do this that many times.
19781978A negative argument means move backward but still to a less deep spot.
19791979This command assumes point is not in a string or comment."
1980- (interactive " ^p" )
1980+ (interactive " ^p" python-mode )
19811981 (or arg (setq arg 1 ))
19821982 (while (> arg 0 )
19831983 (python-nav--up-list 1 )
@@ -1991,15 +1991,15 @@ This command assumes point is not in a string or comment."
19911991With ARG, do this that many times.
19921992A negative argument means move forward but still to a less deep spot.
19931993This command assumes point is not in a string or comment."
1994- (interactive " ^p" )
1994+ (interactive " ^p" python-mode )
19951995 (or arg (setq arg 1 ))
19961996 (python-nav-up-list (- arg)))
19971997
19981998(defun python-nav-if-name-main ()
19991999 " Move point at the beginning the __main__ block.
20002000When \" if __name__ == \\= '__main__\\= ':\" is found returns its
20012001position, else returns nil."
2002- (interactive )
2002+ (interactive nil python-mode )
20032003 (let ((point (point ))
20042004 (found (catch 'found
20052005 (goto-char (point-min ))
0 commit comments