all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nitish <nitishch@protonmail.com>
To: "30822@debbugs.gnu.org" <30822@debbugs.gnu.org>
Subject: bug#30822: 25.3; python-shell-send-defun sends only one line
Date: Thu, 05 Apr 2018 23:22:19 -0400	[thread overview]
Message-ID: <2TBX-5tQa3z6kWZxs4hPoDxkagXwe0NxEwDdjzHU_uRqsVBbVca1oB6AQQr2QIbJYeTPfxylVs5gQpYKILklEds9P_Pj-9ck9unIMByTS_w=@protonmail.com> (raw)
In-Reply-To: <CAMSHvJH5Q8oFgJwow=-wtQD+Lr-HKoCpLiD47MZxEm642HnakQ@mail.gmail.com>

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

As Noam Postavsky mentioned, there was an unconditional (forward-line 1) expression.

The issue manifests itself in a different way too. In the example that David Liu gave, add a decorator to the function on the first line. Then `python-shell-send-defun` enters an infinite loop.

The attached patch fixes both these issues. `(forward-line 1)` should be called only when `(forward-line -1)` moves Point and `(looking-at..` returns false.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-30822-Fixed-infinite-loop-and-also-removed-an-extra-.patch --]
[-- Type: text/x-patch; name="0001-30822-Fixed-infinite-loop-and-also-removed-an-extra-.patch", Size: 1249 bytes --]

From 17b43cf36c58bb396bf269762fb081af1e08f736 Mon Sep 17 00:00:00 2001
From: nitishch <nitishchandrachinta@gmail.com>
Date: Fri, 6 Apr 2018 08:01:14 +0530
Subject: [PATCH] 30822: Fixed infinite loop and also removed an extra call to
 forward-line

---
 lisp/progmodes/python.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index afafd1b42c..3043428413 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3163,9 +3163,13 @@ python-shell-send-defun
                        (beginning-of-line 1))
                    (> (current-indentation) 0)))
        (when (not arg)
-         (while (and (forward-line -1)
-                     (looking-at (python-rx decorator))))
-         (forward-line 1))
+         (while (and
+                 ;; Make sure forward-line actually moves Point
+                 (eq (forward-line -1) 0)
+                 ;; If Point is at a decorator, loop.
+                 ;; else, move one line down and exit the loop.
+                 (or (looking-at (python-rx decorator))
+                     (and (forward-line 1) nil)))))
        (point-marker))
      (progn
        (or (python-nav-end-of-defun)
-- 
2.16.2


  parent reply	other threads:[~2018-04-06  3:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14 20:05 bug#30822: 25.3; python-shell-send-defun sends only one line David Liu
2018-03-14 20:37 ` David Liu
2018-03-15  0:22   ` Noam Postavsky
2018-04-06  3:22 ` Nitish [this message]
2018-04-07  2:26   ` Noam Postavsky
2018-04-07  2:45     ` Nitish
2018-04-07  3:01       ` Noam Postavsky
2018-04-07  3:37         ` Nitish
2018-04-08 16:07           ` Noam Postavsky
2018-04-08 16:21             ` Nitish
2018-04-08 16:44           ` Noam Postavsky
2018-04-09  6:12             ` Andreas Röhler
2018-04-09 11:56               ` Noam Postavsky
2018-04-11 14:49                 ` Andreas Röhler
2018-04-11 14:57                   ` Noam Postavsky
2018-04-11 17:29                     ` Andreas Röhler
2018-04-11 17:33                       ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='2TBX-5tQa3z6kWZxs4hPoDxkagXwe0NxEwDdjzHU_uRqsVBbVca1oB6AQQr2QIbJYeTPfxylVs5gQpYKILklEds9P_Pj-9ck9unIMByTS_w=@protonmail.com' \
    --to=nitishch@protonmail.com \
    --cc=30822@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.