From: Fabián Ezequiel Gallina Date: Sat, 27 Dec 2014 07:01:32 +0000 (-0300) Subject: python.el: Fix message when sending region. X-Git-Tag: emacs-24.4.90~97 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7e9dfde;p=emacs.git 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. --- 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.