From 16768034b209fe12a6408866ac31688604b97375 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Sat, 29 Dec 2012 09:33:33 -0300 Subject: [PATCH] * progmodes/python.el (python-shell-send-region): Add blank lines for non sent code so backtraces remain correct. --- lisp/ChangeLog | 5 +++++ lisp/progmodes/python.el | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d37ee561fc3..9a54639a30b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-12-29 Fabián Ezequiel Gallina + + * progmodes/python.el (python-shell-send-region): Add blank lines + for non sent code so backtraces remain correct. + 2012-12-29 Fabián Ezequiel Gallina * progmodes/python.el: Remove cl dependency. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 56a971f0c67..a427e95c037 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2008,7 +2008,14 @@ Returns the output. See `python-shell-send-string-no-output'." (defun python-shell-send-region (start end) "Send the region delimited by START and END to inferior Python process." (interactive "r") - (python-shell-send-string (buffer-substring start end) nil t)) + (python-shell-send-string + (concat + (let ((line-num (line-number-at-pos start))) + ;; When sending a region, add blank lines for non sent code so + ;; backtraces remain correct. + (make-string (1- line-num) ?\n)) + (buffer-substring start end)) + nil t)) (defun python-shell-send-buffer (&optional arg) "Send the entire buffer to inferior Python process. -- 2.39.5