[Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.105,3.106
Barry Warsaw
python-dev@python.org
Mon, 22 May 2000 22:47:46 -0700
Update of /cvsroot/python/python/dist/src/Misc
In directory slayer.i.sourceforge.net:/tmp/cvs-serv28065
Modified Files:
python-mode.el
Log Message:
(py-execute-region): Based on suggestions by Francois Pinard and Skip
Montanaro, handle execution of indented regions by inserting an "if
1:" in front of the block. This better preserves things like triple
quoted strings and commented regions. This patch resolves PR#264.
Index: python-mode.el
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v
retrieving revision 3.105
retrieving revision 3.106
diff -C2 -r3.105 -r3.106
*** python-mode.el 1999/08/10 21:49:00 3.105
--- python-mode.el 2000/05/23 05:47:43 3.106
***************
*** 9,13 ****
;; Keywords: python languages oop
! (defconst py-version "$Revision: 3.105 $"
"`python-mode' version number.")
--- 9,13 ----
;; Keywords: python languages oop
! (defconst py-version "$Revision: 3.106 $"
"`python-mode' version number.")
***************
*** 1279,1287 ****
(format "python-%d" sn)))
(make-temp-name "python-")))
! (file (expand-file-name temp py-temp-directory)))
! (write-region start end file nil 'nomsg)
(cond
;; always run the code in its own asynchronous subprocess
(async
(let* ((buf (generate-new-buffer-name py-output-buffer))
;; TBD: a horrible hack, but why create new Custom variables?
--- 1279,1299 ----
(format "python-%d" sn)))
(make-temp-name "python-")))
! (file (expand-file-name temp py-temp-directory))
! (cur (current-buffer))
! (buf (get-buffer-create file)))
! ;; Write the contents of the buffer, watching out for indented regions.
! (save-excursion
! (goto-char start)
! (when (/= (py-point 'bol) (py-point 'boi))
! (set-buffer buf)
! (insert "if 1:\n"))
! (insert-buffer-substring cur start end))
(cond
;; always run the code in its own asynchronous subprocess
(async
+ ;; User explicitly wants this to run in its own async subprocess
+ (save-excursion
+ (set-buffer buf)
+ (write-region (point-min) (point-max) file nil 'nomsg))
(let* ((buf (generate-new-buffer-name py-output-buffer))
;; TBD: a horrible hack, but why create new Custom variables?
***************
*** 1291,1294 ****
--- 1303,1307 ----
(pop-to-buffer buf)
(py-postprocess-output-buffer buf)
+ ;; TBD: clean up the temporary file!
))
;; if the Python interpreter shell is running, queue it up for
***************
*** 1296,1299 ****
--- 1309,1315 ----
(proc
;; use the existing python shell
+ (save-excursion
+ (set-buffer buf)
+ (write-region (point-min) (point-max) file nil 'nomsg))
(if (not py-file-queue)
(py-execute-file proc file)
***************
*** 1307,1311 ****
" -" ""))))
;; otherwise either run it synchronously in a subprocess
! (shell-command-on-region start end cmd py-output-buffer)
;; shell-command-on-region kills the output buffer if it never
;; existed and there's no output from the command
--- 1323,1330 ----
" -" ""))))
;; otherwise either run it synchronously in a subprocess
! (save-excursion
! (set-buffer buf)
! (shell-command-on-region (point-min) (point-max)
! cmd py-output-buffer))
;; shell-command-on-region kills the output buffer if it never
;; existed and there's no output from the command
***************
*** 1317,1321 ****
(if err-p
(pop-to-buffer py-exception-buffer)))
! )))
)))
--- 1336,1342 ----
(if err-p
(pop-to-buffer py-exception-buffer)))
! ))
! ;; TBD: delete the buffer
! )
)))