From 7e9dfded9314a1bedc339a7b7807341a2371f235 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Sat, 27 Dec 2014 04:01:32 -0300 Subject: [PATCH] python.el: Fix message when sending region. * lisp/progmodes/python.el (python-shell-send-region): Rename argument send-name from nomain. Fix message. (python-shell-send-buffer): Rename argument send-name from arg. --- lisp/ChangeLog | 8 ++++++++ lisp/progmodes/python.el | 27 +++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5c5dae15e4d..30697ec1a2a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2014-12-27 Fabián Ezequiel Gallina + + python.el: Fix message when sending region. + + * progmodes/python.el (python-shell-send-region): Rename argument + send-name from nomain. Fix message. + (python-shell-send-buffer): Rename argument send-name from arg. + 2014-12-27 Fabián Ezequiel Gallina python.el: Cleanup temp files even with eval errors. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d9422e5b6c0..4a4e320cd65 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2577,23 +2577,30 @@ the python shell: (line-beginning-position) (line-end-position)))) (buffer-substring-no-properties (point-min) (point-max))))) -(defun python-shell-send-region (start end &optional nomain) - "Send the region delimited by START and END to inferior Python process." - (interactive "r") - (let* ((string (python-shell-buffer-substring start end nomain)) +(defun python-shell-send-region (start end &optional send-main) + "Send the region delimited by START and END to inferior Python process. +When optional argument SEND-MAIN is non-nil, allow execution of +code inside blocks delimited by \"if __name__== '__main__':\". +When called interactively SEND-MAIN defaults to nil, unless it's +called with prefix argument." + (interactive "r\nP") + (let* ((string (python-shell-buffer-substring start end (not send-main))) (process (python-shell-get-or-create-process)) - (_ (string-match "\\`\n*\\(.*\\)" string))) - (message "Sent: %s..." (match-string 1 string)) + (original-string (buffer-substring-no-properties start end)) + (_ (string-match "\\`\n*\\(.*\\)" original-string))) + (message "Sent: %s..." (match-string 1 original-string)) (python-shell-send-string string process))) -(defun python-shell-send-buffer (&optional arg) +(defun python-shell-send-buffer (&optional send-main) "Send the entire buffer to inferior Python process. -With prefix ARG allow execution of code inside blocks delimited -by \"if __name__== '__main__':\"." +When optional argument SEND-MAIN is non-nil, allow execution of +code inside blocks delimited by \"if __name__== '__main__':\". +When called interactively SEND-MAIN defaults to nil, unless it's +called with prefix argument." (interactive "P") (save-restriction (widen) - (python-shell-send-region (point-min) (point-max) (not arg)))) + (python-shell-send-region (point-min) (point-max) send-main))) (defun python-shell-send-defun (arg) "Send the current defun to inferior Python process. -- 2.39.2