From unknown Sun Jun 22 08:01:09 2025 X-Loop: help-debbugs@gnu.org Subject: bug#61463: 29.0.60; python-shell-send-region moves point Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: kobarity@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Feb 2023 21:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61463 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 61463@debbugs.gnu.org Cc: kobarity X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: kobarity Received: via spool by submit@debbugs.gnu.org id=B.167623891824878 (code B ref -1); Sun, 12 Feb 2023 21:56:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Feb 2023 21:55:18 +0000 Received: from localhost ([127.0.0.1]:47091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRKJZ-0006TC-P8 for submit@debbugs.gnu.org; Sun, 12 Feb 2023 16:55:18 -0500 Received: from lists.gnu.org ([209.51.188.17]:51864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRKJY-0006T5-Mo for submit@debbugs.gnu.org; Sun, 12 Feb 2023 16:55:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRKJX-000205-Vq for bug-gnu-emacs@gnu.org; Sun, 12 Feb 2023 16:55:16 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRKJW-0003xN-En for bug-gnu-emacs@gnu.org; Sun, 12 Feb 2023 16:55:15 -0500 Received: by mail-ej1-x636.google.com with SMTP id sb24so3644064ejb.8 for ; Sun, 12 Feb 2023 13:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=eRwUsJVt7pUo5rVqBb5nYQArXSaFRXpjAPZhE1yzmLk=; b=O5ciktsMTRVSZ3SoCGShIcm2+oIYx6j847yCcnIMpk9DRVlJONZUC6Lkmy5UIX0kc5 wbGDrpC9FtIawzBvWIE5emsh1aPlpqH6V/z57Gy0XPql9vo8FashHQhwv0h/hCbJitG4 kg2lJCuSsBL9EgtrN0kEc9u3SxjFp9bKprxv8Hnzn8DEQ8G2A7rZPOp0sbrBFg/09joP KOSKmw3whQog73letwPUuX8RHucy4KK5w2kH+YzNXbO7BhSCZspScG+KwInuA61zdzL1 Nifm9e8eCCggWxi5Lq22cqr9/ydtpZQkBvSFfewAurgx1wL1/G+fKWX8vK7soZrSCV2k 4sbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eRwUsJVt7pUo5rVqBb5nYQArXSaFRXpjAPZhE1yzmLk=; b=EpJoMHgmG3mFwBg4a0EiZoQbU6EHVpC8HJ16aPYSl05I/YzDejM36raDWCE+/K4770 ekOjVcAO2sgk6mPaBWYmimAicQ6vAxO8m+yTA11xcKRGNveUeDdOtXdSv9PRxj4Qj3LS YccAGiNC2AMl7TLwveh+cAD5UWJqsWV5t2ypV8mryMBgiiIJX3uh7r/QGxp9asA4NFbb i28Ah56osoKayjVWJo4XUYNtHlEEDfBY3qxAD2a77NGTHs2pPBI+VeF1hLLx3EeCCBtf 0eU+3vz/tgkJQ8xmjX4IT19y/JPXdyHS5+nD5nK3MOq5WS7lNWFdzZsimN8OXFd04avU VwVQ== X-Gm-Message-State: AO0yUKW4RUVo72ANF//VqjgibDjw3GJ0p+uPQ8d5sikGF1DU5OAPM3Ra /r3R9C/9y2l+pabV5an6oBecI7xFYGo= X-Google-Smtp-Source: AK7set+387ej0ka6Bx/y5mZLTMDwLSfUWwF5ZPQm0a/ikHaXXTx5uByXI6U/p38x2J0gIWjdQGRPOQ== X-Received: by 2002:a17:906:581b:b0:88e:d435:3fd6 with SMTP id m27-20020a170906581b00b0088ed4353fd6mr23732087ejq.63.1676238910361; Sun, 12 Feb 2023 13:55:10 -0800 (PST) Received: from ars3 ([2a02:8109:8ac0:56d0::6fd0]) by smtp.gmail.com with ESMTPSA id hf27-20020a1709072c5b00b0088cdb05f1d5sm5852018ejc.113.2023.02.12.13.55.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 13:55:09 -0800 (PST) From: Augusto Stoffel Date: Sun, 12 Feb 2023 22:55:07 +0100 Message-ID: <87pmaeo8g4.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=arstoffel@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On Emacs -Q: 1) M-x run-python 2) In the scratch buffer, type something, say 1 + 2 and mark it, leaving point at the end. 3) M-x python-shell-send-string Now the point is at the beginning of the region. It was supposed not to move. I suspect this might be due to a missing `save-excursion' in the definition of the local variable `single-p' in python.el. From unknown Sun Jun 22 08:01:09 2025 X-Loop: help-debbugs@gnu.org Subject: bug#61463: 29.0.60; python-shell-send-region moves point Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Feb 2023 15:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61463 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Augusto Stoffel Cc: 61463@debbugs.gnu.org Received: via spool by 61463-submit@debbugs.gnu.org id=B61463.167630304631394 (code B ref 61463); Mon, 13 Feb 2023 15:45:02 +0000 Received: (at 61463) by debbugs.gnu.org; 13 Feb 2023 15:44:06 +0000 Received: from localhost ([127.0.0.1]:51276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRazt-0008AH-Pr for submit@debbugs.gnu.org; Mon, 13 Feb 2023 10:44:06 -0500 Received: from mail-pj1-f47.google.com ([209.85.216.47]:52216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRazr-00089f-21 for 61463@debbugs.gnu.org; Mon, 13 Feb 2023 10:44:04 -0500 Received: by mail-pj1-f47.google.com with SMTP id gd1so1529194pjb.1 for <61463@debbugs.gnu.org>; Mon, 13 Feb 2023 07:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=Ayg4OARTTRtnrU4rn+7WrF2CSf9ijbGpoSmSKi/pmPw=; b=GvOylfJ7nWChgSFAuABbqjJjKdKg7xecQSvYmSpDgsAH9xtDYHHT9pyjBxuMAe7TcO vJBiruGAiBcdf4ytHF5RCHOIljXvqkRRyEzmTGRWWxn8ps3MYIOpwBPPHjVpldYQ6JKX 2qo+JoyBXNpcda/P4xOoCjpiJ3yibynG1KzKe+sxtTFO60wvpRebCDhu+lu08LMTirur PgBt+ZT1EjRkCBNZa3p08Q0XFEcX/uQKPklwvB6QNz1oU6ZSTbxe46oLVf4FxWSTq8Un ggJXa0KIs6ZXQEc79iV1ZUJZko521JzC57IFTctchLb0iriClazP1dmHVnmzx3KNiAHh zKhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ayg4OARTTRtnrU4rn+7WrF2CSf9ijbGpoSmSKi/pmPw=; b=xgc92baXx4QsoQmy+7vYIpUEC27OrGMAdAq0A7uDlVOHk2+VbxxmipohHV0l0/Z1pC lUDensICx+Vf0V7BoV0tdvdGvLF7j/nAIKBoyVj5WW30wW+5fcIlndjuU64Xn4yEHlJo 18dA7R+RWMsDaTjCziTTJHdb48CBRjdJcs7OgxJhMLZvD+VZc5FnDq+bZze6GwTtL5Yu rBFMj3zk9az98WFtAPbz+7Xcn6940N4uM9upkI7Z+IUhiUSXDnxxRTd42CPHsGSy82vH WwyFvT49UPUKYOo24rgltWy1uP7ZSswtd7omkt5avAl2jisl+8poIkCUZxnrCQkmeP5B GVrg== X-Gm-Message-State: AO0yUKUEMERA0VkDBjJpKgEFc6URiiWDNo0WnwzyASPV7OeMbm9mSKut sZljUzZ/IhepdAHG2PPH3ag= X-Google-Smtp-Source: AK7set99awlPijBdWMefStR9jW0iRDzTl6zd6+oI5S8jtnBCuoD7tPbUK1LRifTljWDzF1ZIiWygxw== X-Received: by 2002:a17:902:c405:b0:19a:a9d8:e499 with SMTP id k5-20020a170902c40500b0019aa9d8e499mr1860075plk.44.1676303037136; Mon, 13 Feb 2023 07:43:57 -0800 (PST) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id jk13-20020a170903330d00b0019a8597788csm4467612plb.0.2023.02.13.07.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 07:43:56 -0800 (PST) Date: Tue, 14 Feb 2023 00:43:39 +0900 Message-ID: From: kobarity In-Reply-To: <87pmaeo8g4.fsf@gmail.com> References: <87pmaeo8g4.fsf@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Tue_Feb_14_00:43:39_2023-1" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Multipart_Tue_Feb_14_00:43:39_2023-1 Content-Type: text/plain; charset=US-ASCII Augusto Stoffel wrote: > On Emacs -Q: > > 1) M-x run-python > 2) In the scratch buffer, type something, say 1 + 2 and mark it, leaving > point at the end. > 3) M-x python-shell-send-string Probably a typo of python-shell-send-region. > Now the point is at the beginning of the region. It was supposed not to > move. > > I suspect this might be due to a missing `save-excursion' in the > definition of the local variable `single-p' in python.el. Thank you for pointing that out. You are right, `single-p' needs `save-excursion'. The same bug exists in `starts-at-first-line-p'. I'm sorry for those bugs. Atatched is a fix for this problem with improved ERTs to detect this issue. --Multipart_Tue_Feb_14_00:43:39_2023-1 Content-Type: application/octet-stream; type=patch; name="0001-Fix-point-moving-when-calling-python-shell-send-regi.patch" Content-Disposition: attachment; filename="0001-Fix-point-moving-when-calling-python-shell-send-regi.patch" Content-Transfer-Encoding: 7bit >From e8714171a974961946771f23f2e26ec27b5344fc Mon Sep 17 00:00:00 2001 From: kobarity Date: Tue, 14 Feb 2023 00:30:15 +0900 Subject: [PATCH] Fix point moving when calling python-shell-send-region * lisp/progmodes/python.el (python-shell-buffer-substring): Add `save-excursion' to prevent the point from moving. * test/lisp/progmodes/python-tests.el (python-tests-should-not-move): New helper function to assert that point does not move while calling a function. (python-shell-buffer-substring-*): Use `python-tests-should-not-move'. (Bug#61463) --- lisp/progmodes/python.el | 26 ++++++------ test/lisp/progmodes/python-tests.el | 62 ++++++++++++++++++++--------- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index df0d1c96965..0d714c31e9e 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3759,14 +3759,15 @@ python-shell-buffer-substring whitespaces will be removed. Otherwise, wraps indented regions under an \"if True:\" block so the interpreter evaluates them correctly." - (let* ((single-p (save-restriction - (narrow-to-region start end) - (= (progn - (goto-char start) - (python-nav-beginning-of-statement)) - (progn - (goto-char end) - (python-nav-beginning-of-statement))))) + (let* ((single-p (save-excursion + (save-restriction + (narrow-to-region start end) + (= (progn + (goto-char start) + (python-nav-beginning-of-statement)) + (progn + (goto-char end) + (python-nav-beginning-of-statement)))))) (start (save-excursion ;; If we're at the start of the expression, and if ;; the region consists of a single statement, then @@ -3785,10 +3786,11 @@ python-shell-buffer-substring (line-beginning-position) start)))) (substring (buffer-substring-no-properties start end)) - (starts-at-first-line-p (save-restriction - (widen) - (goto-char start) - (= (line-number-at-pos) 1))) + (starts-at-first-line-p (save-excursion + (save-restriction + (widen) + (goto-char start) + (= (line-number-at-pos) 1)))) (encoding (python-info-encoding)) (toplevel-p (zerop (save-excursion (goto-char start) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index df71990278e..4f24c042c6a 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -189,6 +189,14 @@ python-tests-visible-string (overlay-end overlay)))) (buffer-substring-no-properties (point-min) (point-max))))) +(defun python-tests-should-not-move (func &rest args) + "Assert that point does not move while calling FUNC with ARGS. +Returns the value returned by FUNC." + (let ((pos (point)) + (ret (apply func args))) + (should (= pos (point))) + ret)) + (defun python-virt-bin (&optional virt-root) "Return the virtualenv bin dir, starting from VIRT-ROOT. If nil, VIRT-ROOT defaults to `python-shell-virtualenv-root'. @@ -4213,7 +4221,8 @@ python-shell-buffer-substring-1 pass " (should (string= (buffer-string) - (python-shell-buffer-substring (point-min) (point-max)))))) + (python-tests-should-not-move + #'python-shell-buffer-substring (point-min) (point-max)))))) (ert-deftest python-shell-buffer-substring-2 () "Main block should be removed if NOMAIN is non-nil." @@ -4229,7 +4238,8 @@ python-shell-buffer-substring-2 foo = Foo() print (foo) " - (should (string= (python-shell-buffer-substring (point-min) (point-max) t) + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (point-min) (point-max) t) " class Foo(models.Model): pass @@ -4256,7 +4266,8 @@ python-shell-buffer-substring-3 class Bar(models.Model): pass " - (should (string= (python-shell-buffer-substring (point-min) (point-max) t) + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (point-min) (point-max) t) " class Foo(models.Model): pass @@ -4284,7 +4295,8 @@ python-shell-buffer-substring-4 class Bar(models.Model): pass " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "class Foo(models.Model):") (progn (python-nav-forward-sexp) (point))) "# -*- coding: latin-1 -*- @@ -4307,7 +4319,8 @@ python-shell-buffer-substring-5 class Bar(models.Model): pass " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "class Bar(models.Model):") (progn (python-nav-forward-sexp) (point))) "# -*- coding: latin-1 -*- @@ -4338,7 +4351,8 @@ python-shell-buffer-substring-6 class Bar(models.Model): pass " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "# coding: latin-1") (python-tests-look-at "if __name__ == \"__main__\":")) "# -*- coding: latin-1 -*- @@ -4365,7 +4379,8 @@ python-shell-buffer-substring-7 class Bar(models.Model): pass " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "# coding: latin-1") (python-tests-look-at "if __name__ == \"__main__\":")) "# -*- coding: utf-8 -*- @@ -4385,7 +4400,8 @@ python-shell-buffer-substring-8 class Foo(models.Model): pass " - (should (string= (python-shell-buffer-substring (point-min) (point-max)) + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (point-min) (point-max)) "# coding: utf-8 @@ -4404,7 +4420,8 @@ python-shell-buffer-substring-9 class Bar(models.Model): pass " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (point-min) (python-tests-look-at "class Bar(models.Model):")) "# coding: utf-8 @@ -4421,7 +4438,8 @@ python-shell-buffer-substring-10 def foo(): print ('a') " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "print ('a')") (point-max)) "# -*- coding: utf-8 -*-\nif True:\n print ('a')\n\n")))) @@ -4433,7 +4451,8 @@ python-shell-buffer-substring-11 def foo(): print ('a') " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (progn (python-tests-look-at "print ('a')") (backward-char 1) @@ -4451,7 +4470,8 @@ python-shell-buffer-substring-12 print ('a') " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "# Whitespace") (point-max)) "# -*- coding: utf-8 -*-\n\nif True:\n # Whitespace\n\n print ('a')\n\n")))) @@ -4463,7 +4483,8 @@ python-shell-buffer-substring-13 def foo(): a = 1 " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "a = 1") (pos-eol)) "# -*- coding: utf-8 -*-\n\na = 1")))) @@ -4476,7 +4497,8 @@ python-shell-buffer-substring-14 a = \"\"\"Some string\"\"\" " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "a = \"\"\"Some") (pos-eol 2)) "# -*- coding: utf-8 -*-\n\na = \"\"\"Some\n string\"\"\"")))) @@ -4488,7 +4510,8 @@ python-shell-buffer-substring-15 def foo(): a = 1 " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at " a = 1") (python-tests-look-at " = 1")) "# -*- coding: utf-8 -*-\n\na")))) @@ -4500,7 +4523,8 @@ python-shell-buffer-substring-16 def foo(): a = 1 " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "1") (1+ (point))) "# -*- coding: utf-8 -*-\n\n1")))) @@ -4515,7 +4539,8 @@ python-shell-buffer-substring-17 b = 2 \"\"\" " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "a = 1") (python-tests-look-at "\"\"\"")) "# -*- coding: utf-8 -*-\n\nif True:\n a = 1\n b = 2\n\n")))) @@ -4525,7 +4550,8 @@ python-shell-buffer-substring-18 (python-tests-with-temp-buffer "s = 'test' " - (should (string= (python-shell-buffer-substring + (should (string= (python-tests-should-not-move + #'python-shell-buffer-substring (python-tests-look-at "'test'") (pos-eol)) "'test'")))) -- 2.34.1 --Multipart_Tue_Feb_14_00:43:39_2023-1-- From unknown Sun Jun 22 08:01:09 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Augusto Stoffel Subject: bug#61463: closed (Re: bug#61463: 29.0.60; python-shell-send-region moves point) Message-ID: References: <835ybyzzvm.fsf@gnu.org> <87pmaeo8g4.fsf@gmail.com> X-Gnu-PR-Message: they-closed 61463 X-Gnu-PR-Package: emacs Reply-To: 61463@debbugs.gnu.org Date: Sat, 18 Feb 2023 16:46:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1676738762-13601-1" This is a multi-part message in MIME format... ------------=_1676738762-13601-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #61463: 29.0.60; python-shell-send-region moves point which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 61463@debbugs.gnu.org. --=20 61463: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D61463 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1676738762-13601-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 61463-done) by debbugs.gnu.org; 18 Feb 2023 16:45:35 +0000 Received: from localhost ([127.0.0.1]:44794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pTQL8-0003Wg-Oh for submit@debbugs.gnu.org; Sat, 18 Feb 2023 11:45:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pTQL7-0003WT-1h for 61463-done@debbugs.gnu.org; Sat, 18 Feb 2023 11:45:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTQL1-0004T9-Q4; Sat, 18 Feb 2023 11:45:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=MDW8krtA/AhhrYksg7Msboh973P6PJ6Ftx6avAU1z3I=; b=AMrNj39Zd7ll Fa8jdp2398la+9dX0pUHJz5H9Ix4CXNm2/3TVW/ij6JzsIm0hRv5EZY5QTSUETMXnpIGI287na9PQ twxkOIQdfiA3zE9ne2g5yJYajEM5W+aQa4bal4on50bu0p9XFsF+Mc7H6bOJ9E3Z0jOvrZhE86f6Y iASy1jgBDvw6MkKWkiURKEZVsoYxDFH8qKFOG9AUV9PZ0CGod0V2gtKnkNnwVOry49J1x0jAsmgQb aiBruJyOgiwUkbE5cm+rdPKFu7sr4N1WoFi4lIZgnhQGacd8knXU3XzeDH7n6Dv9JlOtBfaEzIQ8x FnVNiFWPIj/PYbvAi1fNaQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTQL0-0001tZ-IK; Sat, 18 Feb 2023 11:45:27 -0500 Date: Sat, 18 Feb 2023 18:45:17 +0200 Message-Id: <835ybyzzvm.fsf@gnu.org> From: Eli Zaretskii To: kobarity In-Reply-To: (message from kobarity on Tue, 14 Feb 2023 00:43:39 +0900) Subject: Re: bug#61463: 29.0.60; python-shell-send-region moves point References: <87pmaeo8g4.fsf@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61463-done Cc: 61463-done@debbugs.gnu.org, arstoffel@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 61463@debbugs.gnu.org > Date: Tue, 14 Feb 2023 00:43:39 +0900 > From: kobarity > > Augusto Stoffel wrote: > > On Emacs -Q: > > > > 1) M-x run-python > > 2) In the scratch buffer, type something, say 1 + 2 and mark it, leaving > > point at the end. > > 3) M-x python-shell-send-string > > Probably a typo of python-shell-send-region. > > > Now the point is at the beginning of the region. It was supposed not to > > move. > > > > I suspect this might be due to a missing `save-excursion' in the > > definition of the local variable `single-p' in python.el. > > Thank you for pointing that out. You are right, `single-p' needs > `save-excursion'. The same bug exists in `starts-at-first-line-p'. > I'm sorry for those bugs. > > Atatched is a fix for this problem with improved ERTs to detect this > issue. Thanks, installed on the emacs-29 branch, and closing the bug. ------------=_1676738762-13601-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 Feb 2023 21:55:18 +0000 Received: from localhost ([127.0.0.1]:47091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRKJZ-0006TC-P8 for submit@debbugs.gnu.org; Sun, 12 Feb 2023 16:55:18 -0500 Received: from lists.gnu.org ([209.51.188.17]:51864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRKJY-0006T5-Mo for submit@debbugs.gnu.org; Sun, 12 Feb 2023 16:55:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRKJX-000205-Vq for bug-gnu-emacs@gnu.org; Sun, 12 Feb 2023 16:55:16 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRKJW-0003xN-En for bug-gnu-emacs@gnu.org; Sun, 12 Feb 2023 16:55:15 -0500 Received: by mail-ej1-x636.google.com with SMTP id sb24so3644064ejb.8 for ; Sun, 12 Feb 2023 13:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=eRwUsJVt7pUo5rVqBb5nYQArXSaFRXpjAPZhE1yzmLk=; b=O5ciktsMTRVSZ3SoCGShIcm2+oIYx6j847yCcnIMpk9DRVlJONZUC6Lkmy5UIX0kc5 wbGDrpC9FtIawzBvWIE5emsh1aPlpqH6V/z57Gy0XPql9vo8FashHQhwv0h/hCbJitG4 kg2lJCuSsBL9EgtrN0kEc9u3SxjFp9bKprxv8Hnzn8DEQ8G2A7rZPOp0sbrBFg/09joP KOSKmw3whQog73letwPUuX8RHucy4KK5w2kH+YzNXbO7BhSCZspScG+KwInuA61zdzL1 Nifm9e8eCCggWxi5Lq22cqr9/ydtpZQkBvSFfewAurgx1wL1/G+fKWX8vK7soZrSCV2k 4sbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eRwUsJVt7pUo5rVqBb5nYQArXSaFRXpjAPZhE1yzmLk=; b=EpJoMHgmG3mFwBg4a0EiZoQbU6EHVpC8HJ16aPYSl05I/YzDejM36raDWCE+/K4770 ekOjVcAO2sgk6mPaBWYmimAicQ6vAxO8m+yTA11xcKRGNveUeDdOtXdSv9PRxj4Qj3LS YccAGiNC2AMl7TLwveh+cAD5UWJqsWV5t2ypV8mryMBgiiIJX3uh7r/QGxp9asA4NFbb i28Ah56osoKayjVWJo4XUYNtHlEEDfBY3qxAD2a77NGTHs2pPBI+VeF1hLLx3EeCCBtf 0eU+3vz/tgkJQ8xmjX4IT19y/JPXdyHS5+nD5nK3MOq5WS7lNWFdzZsimN8OXFd04avU VwVQ== X-Gm-Message-State: AO0yUKW4RUVo72ANF//VqjgibDjw3GJ0p+uPQ8d5sikGF1DU5OAPM3Ra /r3R9C/9y2l+pabV5an6oBecI7xFYGo= X-Google-Smtp-Source: AK7set+387ej0ka6Bx/y5mZLTMDwLSfUWwF5ZPQm0a/ikHaXXTx5uByXI6U/p38x2J0gIWjdQGRPOQ== X-Received: by 2002:a17:906:581b:b0:88e:d435:3fd6 with SMTP id m27-20020a170906581b00b0088ed4353fd6mr23732087ejq.63.1676238910361; Sun, 12 Feb 2023 13:55:10 -0800 (PST) Received: from ars3 ([2a02:8109:8ac0:56d0::6fd0]) by smtp.gmail.com with ESMTPSA id hf27-20020a1709072c5b00b0088cdb05f1d5sm5852018ejc.113.2023.02.12.13.55.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 13:55:09 -0800 (PST) From: Augusto Stoffel To: bug-gnu-emacs@gnu.org Subject: 29.0.60; python-shell-send-region moves point X-Debbugs-Cc: kobarity Date: Sun, 12 Feb 2023 22:55:07 +0100 Message-ID: <87pmaeo8g4.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=arstoffel@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On Emacs -Q: 1) M-x run-python 2) In the scratch buffer, type something, say 1 + 2 and mark it, leaving point at the end. 3) M-x python-shell-send-string Now the point is at the beginning of the region. It was supposed not to move. I suspect this might be due to a missing `save-excursion' in the definition of the local variable `single-p' in python.el. ------------=_1676738762-13601-1--