diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index cc835ca79ac..e99e6bda4b8 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1919,19 +1919,18 @@ Returns the output. See `python-shell-send-string-no-output'." | |||
| 1919 | 1919 | ||
| 1920 | (defun python-shell-send-buffer (&optional arg) | 1920 | (defun python-shell-send-buffer (&optional arg) |
| 1921 | "Send the entire buffer to inferior Python process. | 1921 | "Send the entire buffer to inferior Python process. |
| 1922 | 1922 | With prefix ARG allow execution of code inside blocks delimited | |
| 1923 | With prefix ARG include lines surrounded by \"if __name__ == '__main__':\"" | 1923 | by \"if __name__== '__main__':\"" |
| 1924 | (interactive "P") | 1924 | (interactive "P") |
| 1925 | (save-restriction | 1925 | (save-restriction |
| 1926 | (widen) | 1926 | (widen) |
| 1927 | (python-shell-send-region | 1927 | (let ((str (buffer-substring (point-min) (point-max)))) |
| 1928 | (point-min) | 1928 | (and |
| 1929 | (or (and | 1929 | (not arg) |
| 1930 | (not arg) | 1930 | (setq str (replace-regexp-in-string |
| 1931 | (save-excursion | 1931 | (python-rx if-name-main) |
| 1932 | (re-search-forward (python-rx if-name-main) nil t)) | 1932 | "if __name__ == '__main__ ':" str))) |
| 1933 | (match-beginning 0)) | 1933 | (python-shell-send-string str)))) |
| 1934 | (point-max))))) | ||
| 1935 | 1934 | ||
| 1936 | (defun python-shell-send-defun (arg) | 1935 | (defun python-shell-send-defun (arg) |
| 1937 | "Send the current defun to inferior Python process. | 1936 | "Send the current defun to inferior Python process. |