emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 7e9dfde: python.el: Fix message when sending regi


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] emacs-24 7e9dfde: python.el: Fix message when sending region.
Date: Sat, 27 Dec 2014 07:01:43 +0000

branch: emacs-24
commit 7e9dfded9314a1bedc339a7b7807341a2371f235
Author: Fabián Ezequiel Gallina <address@hidden>
Commit: Fabián Ezequiel Gallina <address@hidden>

    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 5c5dae1..30697ec 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
 2014-12-27  Fabián Ezequiel Gallina  <address@hidden>
 
+       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  <address@hidden>
+
        python.el: Cleanup temp files even with eval errors.
 
        * progmodes/python.el (python-shell-send-file): Make file-name
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d9422e5..4a4e320 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]