From: Fabián Ezequiel Gallina Date: Sat, 29 Dec 2012 12:33:33 +0000 (-0300) Subject: * progmodes/python.el (python-shell-send-region): Add blank lines X-Git-Tag: emacs-24.3.90~173^2~7^2~455 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=16768034b209fe12a6408866ac31688604b97375;p=emacs.git * progmodes/python.el (python-shell-send-region): Add blank lines for non sent code so backtraces remain correct. --- 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.