mirror of https://github.com/python/cpython.git
(py-execute-region): If the line at the beginning of the region is a
#! line, use the command on that line as the shell command to use to execute the region. I.e. if the region looks like ---------------- #! /usr/bin/env python1.5 print 'hello world'.startswith('hello') ---------------- you'll get an exception! :) This closes SF bug #232398.
This commit is contained in:
parent
b2d5e62d65
commit
a0113cd5cd
|
@ -1359,10 +1359,16 @@ is inserted at the end. See also the command `py-clear-queue'."
|
||||||
(let ((needs-if (/= (py-point 'bol) (py-point 'boi))))
|
(let ((needs-if (/= (py-point 'bol) (py-point 'boi))))
|
||||||
(set-buffer buf)
|
(set-buffer buf)
|
||||||
(python-mode)
|
(python-mode)
|
||||||
(setq shell py-which-shell)
|
|
||||||
(when needs-if
|
(when needs-if
|
||||||
(insert "if 1:\n"))
|
(insert "if 1:\n"))
|
||||||
(insert-buffer-substring cur start end)))
|
(insert-buffer-substring cur start end)
|
||||||
|
;; Set the shell either to the #! line command, or to the
|
||||||
|
;; py-which-shell buffer local variable.
|
||||||
|
(goto-char (point-min))
|
||||||
|
(if (looking-at "^#!\\s *\\(.*\\)$")
|
||||||
|
(setq shell (match-string 1))
|
||||||
|
;; No useable #! line
|
||||||
|
(setq shell py-which-shell))))
|
||||||
(cond
|
(cond
|
||||||
;; always run the code in its own asynchronous subprocess
|
;; always run the code in its own asynchronous subprocess
|
||||||
(async
|
(async
|
||||||
|
@ -1392,10 +1398,9 @@ is inserted at the end. See also the command `py-clear-queue'."
|
||||||
(setq py-file-queue (append py-file-queue (list file)))
|
(setq py-file-queue (append py-file-queue (list file)))
|
||||||
(setq py-exception-buffer (cons file (current-buffer))))
|
(setq py-exception-buffer (cons file (current-buffer))))
|
||||||
(t
|
(t
|
||||||
;; TBD: a horrible hack, buy why create new Custom variables?
|
;; TBD: a horrible hack, but why create new Custom variables?
|
||||||
(let ((cmd (concat shell
|
(let ((cmd (concat shell (if (string-equal py-which-bufname "JPython")
|
||||||
(if (string-equal py-which-bufname "JPython")
|
" -" ""))))
|
||||||
" -" ""))))
|
|
||||||
;; otherwise either run it synchronously in a subprocess
|
;; otherwise either run it synchronously in a subprocess
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(set-buffer buf)
|
(set-buffer buf)
|
||||||
|
|
Loading…
Reference in New Issue