[Python-checkins] python/dist/src/Misc python-mode.el,4.9,4.10

bwarsaw@sourceforge.net bwarsaw@sourceforge.net
Mon, 22 Apr 2002 09:23:31 -0700


Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv24429

Modified Files:
	python-mode.el 
Log Message:
(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.


Index: python-mode.el
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v
retrieving revision 4.9
retrieving revision 4.10
diff -C2 -d -r4.9 -r4.10
*** python-mode.el	22 Apr 2002 15:29:27 -0000	4.9
--- python-mode.el	22 Apr 2002 16:23:29 -0000	4.10
***************
*** 1360,1367 ****
  	(set-buffer buf)
  	(python-mode)
- 	(setq shell py-which-shell)
  	(when needs-if
  	  (insert "if 1:\n"))
! 	(insert-buffer-substring cur start end)))
      (cond
       ;; always run the code in its own asynchronous subprocess
--- 1360,1373 ----
  	(set-buffer buf)
  	(python-mode)
  	(when needs-if
  	  (insert "if 1:\n"))
! 	(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
       ;; always run the code in its own asynchronous subprocess
***************
*** 1393,1400 ****
        (setq py-exception-buffer (cons file (current-buffer))))
       (t
!       ;; TBD: a horrible hack, buy why create new Custom variables?
!       (let ((cmd (concat shell
! 			 (if (string-equal py-which-bufname "JPython")
! 			     " -" ""))))
  	;; otherwise either run it synchronously in a subprocess
  	(save-excursion
--- 1399,1405 ----
        (setq py-exception-buffer (cons file (current-buffer))))
       (t
!       ;; TBD: a horrible hack, but why create new Custom variables?
!       (let ((cmd (concat shell (if (string-equal py-which-bufname "JPython")
! 				   " -" ""))))
  	;; otherwise either run it synchronously in a subprocess
  	(save-excursion