]> git.eshelyaron.com Git - emacs.git/commitdiff
Enhance 'python-shell-send-block' for convenience
authorLin Sun <sunlin7@hotmail.com>
Mon, 20 May 2024 06:55:31 +0000 (06:55 +0000)
committerEshel Yaron <me@eshelyaron.com>
Sun, 26 May 2024 09:04:44 +0000 (11:04 +0200)
* lisp/progmodes/python.el (python-shell-send-block):
'python-shell-send-block' will now send block without header
by default.
* test/lisp/progmodes/python-tests.el
(python-test--shell-send-block): Update the test case.
(Bug#71083)

(cherry picked from commit b241ec0e78f141e7fc22cf3afb11037d14fc028c)

lisp/progmodes/python.el
test/lisp/progmodes/python-tests.el

index fea52b2f7d6f32336c80b00396cfdcfa87bdd32c..b5c00385ef3b299ca30766f22f573e17e5bdcd82 100644 (file)
@@ -4156,14 +4156,14 @@ interactively."
   "Send the block at point to inferior Python process.
 The block is delimited by `python-nav-beginning-of-block' and
 `python-nav-end-of-block'.  If optional argument ARG is non-nil
-(interactively, the prefix argument), send the block body without
+\(interactively, the prefix argument), send the block body with
 its header.  If optional argument MSG is non-nil, force display
 of a user-friendly message if there's no process running; this
 always happens interactively."
   (interactive (list current-prefix-arg t))
   (let ((beg (save-excursion
                (when (python-nav-beginning-of-block)
-                 (if (null arg)
+                 (if arg
                      (beginning-of-line)
                    (python-nav-end-of-statement)
                    (beginning-of-line 2)))
@@ -4172,7 +4172,7 @@ always happens interactively."
         (python-indent-guess-indent-offset-verbose nil))
     (if (and beg end)
         (python-shell-send-region beg end nil msg t)
-      (user-error "Can't get code block from current position."))))
+      (user-error "Can't get code block from current position"))))
 
 (defun python-shell-send-buffer (&optional send-main msg)
   "Send the entire buffer to inferior Python process.
index 0aee5a2212bf0bd99bb00ebce02659b00875e592..2494e80ebc09f63120a10071cb55a35ca78764af 100644 (file)
@@ -7491,7 +7491,7 @@ print('current 3')"
     (goto-char (point-min))
     (should-error (python-shell-send-block) :type 'user-error)
     (forward-line)
-    (python-shell-send-block)
+    (python-shell-send-block t) ;; send block with header
     (python-tests-shell-wait-for-prompt)
     (python-shell-with-shell-buffer
       (goto-char (point-min))
@@ -7500,7 +7500,7 @@ print('current 3')"
       (should (re-search-forward "current 2" nil t))
       (should-not (re-search-forward "current 3" nil t)))
     (forward-line)
-    (python-shell-send-block t) ;; send block body only
+    (python-shell-send-block) ;; send block body only
     (python-tests-shell-wait-for-prompt)
     (python-shell-with-shell-buffer
       ;; should only 1 line output from the block body