bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71083: [PATCH] ; Enhance the "python-shell-send-block" for convenien


From: Eli Zaretskii
Subject: bug#71083: [PATCH] ; Enhance the "python-shell-send-block" for convenience
Date: Sat, 25 May 2024 11:03:49 +0300

Any comments on the proposed patch?

> From: Lin Sun <sunlin7.mail@gmail.com>
> Date: Mon, 20 May 2024 20:28:17 +0000
> 
> This patch tries to make `python-shell-send-block' more convenient.
> 
> I had added the function `python-shell-send-block'  twenty days ago in
> bug#70609, it will send code block with header by default, and a
> prefix "C-u" to call the function will send block without header.
> 
> And I received some feedback that sending a block without a header
> should be a more used one.
> 
> Many python blocks begin with "if condition", and users may want to
> send the block without its condition header to try different condition
> branches.
> 
> So this patch will make sending block without header to be the default
> behavior, and a prefix "C-u" will make the function to send block with
> header.
> 
> Please help review this minor change. Thanks
> 
> 
> From 7eefbf3e4de925c211e483a809d0f8d94e8d17f0 Mon Sep 17 00:00:00 2001
> From: Lin Sun <sunlin7@hotmail.com>
> Date: Mon, 20 May 2024 06:55:31 +0000
> Subject: [PATCH] ; Enhance the "python-shell-send-block" for convenience
> 
> * lisp/progmodes/python.el (python-shell-send-block):
>   The "python-shell-send-block" will send block without header defaultly.
> * lisp/progmodes/python.el: Update test case.
> ---
>  lisp/progmodes/python.el            | 4 ++--
>  test/lisp/progmodes/python-tests.el | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 7f28f583543..9ec198da79a 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -4149,14 +4149,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)))
> diff --git a/test/lisp/progmodes/python-tests.el 
> b/test/lisp/progmodes/python-tests.el
> index f50797953c3..803008db8a3 100644
> --- a/test/lisp/progmodes/python-tests.el
> +++ b/test/lisp/progmodes/python-tests.el
> @@ -7476,7 +7476,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))
> @@ -7485,7 +7485,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
> -- 
> 2.20.5
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]