unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46610: Interactive mode tagging for python.el navigation functions
@ 2021-02-18  4:46 Doug Davis
  2021-02-18 11:40 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 15+ messages in thread
From: Doug Davis @ 2021-02-18  4:46 UTC (permalink / raw)
  To: 46610

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

This is my first stab at adding some interactive mode tagging for
python.el. I think that the navigation functions are the best place to
start; they have no use except on buffers where Python code exists and
it's expected that python-mode is enabled. (sent in my copyright
assignment paperwork today)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Do-interactive-mode-tagging-for-python.el-navigation.patch --]
[-- Type: text/x-patch, Size: 6676 bytes --]

From 945fa0b60174b168c7d928b36844ebe6c73bf253 Mon Sep 17 00:00:00 2001
From: Doug Davis <ddavis@ddavis.io>
Date: Wed, 17 Feb 2021 23:37:00 -0500
Subject: [PATCH] Do interactive mode tagging for python.el navigation
 functions.

* lisp/progmodes/python.el (navigation functions): add python-mode to
`interactive' declarations for all interactive functions.
---
 lisp/progmodes/python.el | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index afb96974b1..7506043a19 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1506,7 +1506,7 @@ python-nav-beginning-of-defun
 (defun python-nav-end-of-defun ()
   "Move point to the end of def or class.
 Returns nil if point is not in a def or class."
-  (interactive)
+  (interactive nil python-mode)
   (let ((beg-defun-indent)
         (beg-pos (point)))
     (when (or (python-info-looking-at-beginning-of-defun)
@@ -1577,19 +1577,19 @@ python-nav-backward-defun
   "Navigate to closer defun backward ARG times.
 Unlikely `python-nav-beginning-of-defun' this doesn't care about
 nested definitions."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (python-nav--forward-defun (- (or arg 1))))
 
 (defun python-nav-forward-defun (&optional arg)
   "Navigate to closer defun forward ARG times.
 Unlikely `python-nav-beginning-of-defun' this doesn't care about
 nested definitions."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (python-nav--forward-defun (or arg 1)))
 
 (defun python-nav-beginning-of-statement ()
   "Move to start of current statement."
-  (interactive "^")
+  (interactive "^" python-mode)
   (forward-line 0)
   (let* ((ppss (syntax-ppss))
          (context-point
@@ -1613,7 +1613,7 @@ python-nav-end-of-statement
 Optional argument NOEND is internal and makes the logic to not
 jump to the end of line when moving forward searching for the end
 of the statement."
-  (interactive "^")
+  (interactive "^" python-mode)
   (let (string-start bs-pos (last-string-end 0))
     (while (and (or noend (goto-char (line-end-position)))
                 (not (eobp))
@@ -1654,7 +1654,7 @@ python-nav-end-of-statement
 (defun python-nav-backward-statement (&optional arg)
   "Move backward to previous statement.
 With ARG, repeat.  See `python-nav-forward-statement'."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   (python-nav-forward-statement (- arg)))
 
@@ -1662,7 +1662,7 @@ python-nav-forward-statement
   "Move forward to next statement.
 With ARG, repeat.  With negative argument, move ARG times
 backward to previous statement."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   (while (> arg 0)
     (python-nav-end-of-statement)
@@ -1677,7 +1677,7 @@ python-nav-forward-statement
 
 (defun python-nav-beginning-of-block ()
   "Move to start of current block."
-  (interactive "^")
+  (interactive "^" python-mode)
   (let ((starting-pos (point)))
     (if (progn
           (python-nav-beginning-of-statement)
@@ -1701,7 +1701,7 @@ python-nav-beginning-of-block
 
 (defun python-nav-end-of-block ()
   "Move to end of current block."
-  (interactive "^")
+  (interactive "^" python-mode)
   (when (python-nav-beginning-of-block)
     (let ((block-indentation (current-indentation)))
       (python-nav-end-of-statement)
@@ -1717,7 +1717,7 @@ python-nav-end-of-block
 (defun python-nav-backward-block (&optional arg)
   "Move backward to previous block of code.
 With ARG, repeat.  See `python-nav-forward-block'."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   (python-nav-forward-block (- arg)))
 
@@ -1725,7 +1725,7 @@ python-nav-forward-block
   "Move forward to next block of code.
 With ARG, repeat.  With negative argument, move ARG times
 backward to previous block."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   (let ((block-start-regexp
          (python-rx line-start (* whitespace) block-start))
@@ -1878,7 +1878,7 @@ python-nav-forward-sexp
 argument SKIP-PARENS-P force sexp motion to ignore parenthesized
 expressions when looking at them in either direction (forced to t
 in interactive calls)."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   ;; Do not follow parens on interactive calls.  This hack to detect
   ;; if the function was called interactively copes with the way
@@ -1912,7 +1912,7 @@ python-nav-backward-sexp
 argument SKIP-PARENS-P force sexp motion to ignore parenthesized
 expressions when looking at them in either direction (forced to t
 in interactive calls)."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   (python-nav-forward-sexp (- arg) safe skip-parens-p))
 
@@ -1922,7 +1922,7 @@ python-nav-forward-sexp-safe
 backward N times.  With optional argument SKIP-PARENS-P force
 sexp motion to ignore parenthesized expressions when looking at
 them in either direction (forced to t in interactive calls)."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (python-nav-forward-sexp arg t skip-parens-p))
 
 (defun python-nav-backward-sexp-safe (&optional arg skip-parens-p)
@@ -1931,7 +1931,7 @@ python-nav-backward-sexp-safe
 forward N times.  With optional argument SKIP-PARENS-P force sexp
 motion to ignore parenthesized expressions when looking at them in
 either direction (forced to t in interactive calls)."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (python-nav-backward-sexp arg t skip-parens-p))
 
 (defun python-nav--up-list (&optional dir)
@@ -1977,7 +1977,7 @@ python-nav-up-list
 With ARG, do this that many times.
 A negative argument means move backward but still to a less deep spot.
 This command assumes point is not in a string or comment."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   (while (> arg 0)
     (python-nav--up-list 1)
@@ -1991,7 +1991,7 @@ python-nav-backward-up-list
 With ARG, do this that many times.
 A negative argument means move forward but still to a less deep spot.
 This command assumes point is not in a string or comment."
-  (interactive "^p")
+  (interactive "^p" python-mode)
   (or arg (setq arg 1))
   (python-nav-up-list (- arg)))
 
@@ -1999,7 +1999,7 @@ python-nav-if-name-main
   "Move point at the beginning the __main__ block.
 When \"if __name__ == \\='__main__\\=':\" is found returns its
 position, else returns nil."
-  (interactive)
+  (interactive nil python-mode)
   (let ((point (point))
         (found (catch 'found
                  (goto-char (point-min))
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-02-18 20:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-18  4:46 bug#46610: Interactive mode tagging for python.el navigation functions Doug Davis
2021-02-18 11:40 ` Lars Ingebrigtsen
2021-02-18 11:49   ` Dmitry Gutov
2021-02-18 11:52     ` Lars Ingebrigtsen
2021-02-18 14:41     ` Eli Zaretskii
2021-02-18 14:54       ` Dmitry Gutov
2021-02-18 15:07         ` Eli Zaretskii
2021-02-18 15:37           ` Dmitry Gutov
2021-02-18 17:25             ` Eli Zaretskii
2021-02-18 17:54               ` Dmitry Gutov
2021-02-18 19:47                 ` Eli Zaretskii
2021-02-18 19:57                   ` Dmitry Gutov
2021-02-18 20:00                     ` Eli Zaretskii
2021-02-18 20:05                       ` Dmitry Gutov
2021-02-18 15:50     ` Doug Davis

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).