diff options
author | Barry Warsaw <barry@python.org> | 1996-09-30 23:00:40 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1996-09-30 23:00:40 (GMT) |
commit | 7a73ef852f504a4c6110eeefb22150a2121c68e4 (patch) | |
tree | 0d1281dbcba061b2ac3873068aeadb28d1ddf60a /Misc | |
parent | 24611f80e8d48efcdf469fde00729ff6c1ca4128 (diff) | |
download | cpython-7a73ef852f504a4c6110eeefb22150a2121c68e4.zip cpython-7a73ef852f504a4c6110eeefb22150a2121c68e4.tar.gz cpython-7a73ef852f504a4c6110eeefb22150a2121c68e4.tar.bz2 |
(py-process-filter): Make sure current-buffer is restored, even in the
event of error. Can't use new Emacs primitive save-current-buffer, so
use unwind-protect instead.
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/python-mode.el | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el index b9971f9..1d53043 100644 --- a/Misc/python-mode.el +++ b/Misc/python-mode.el @@ -932,42 +932,47 @@ See the `\\[py-shell]' docs for additional warnings." ;; read_process_output has update_mode_lines++ for a similar ;; reason? beats me ... - ;; BAW - we want to check to see if this still applies - (if (eq curbuf pbuf) ; mysterious ugly hack - (set-buffer (get-buffer-create "*scratch*"))) - - (set-buffer pbuf) - (let* ((start (point)) - (goback (< start pmark)) - (goend (and (not goback) (= start (point-max)))) - (buffer-read-only nil)) - (goto-char pmark) - (insert string) - (move-marker pmark (point)) - (setq file-finished - (and py-file-queue - (equal ">>> " - (buffer-substring - (prog2 (beginning-of-line) (point) - (goto-char pmark)) - (point))))) - (if goback (goto-char start) - ;; else - (if py-scroll-process-buffer - (let* ((pop-up-windows t) - (pwin (display-buffer pbuf))) - (set-window-point pwin (point))))) - (set-buffer curbuf) - (if file-finished - (progn - (py-delete-file-silently (car py-file-queue)) - (setq py-file-queue (cdr py-file-queue)) - (if py-file-queue - (py-execute-file pyproc (car py-file-queue))))) - (and goend - (progn (set-buffer pbuf) - (goto-char (point-max)))) - ))) + (unwind-protect + ;; make sure current buffer is restored + ;; BAW - we want to check to see if this still applies + (progn + ;; mysterious ugly hack + (if (eq curbuf pbuf) + (set-buffer (get-buffer-create "*scratch*"))) + + (set-buffer pbuf) + (let* ((start (point)) + (goback (< start pmark)) + (goend (and (not goback) (= start (point-max)))) + (buffer-read-only nil)) + (goto-char pmark) + (insert string) + (move-marker pmark (point)) + (setq file-finished + (and py-file-queue + (equal ">>> " + (buffer-substring + (prog2 (beginning-of-line) (point) + (goto-char pmark)) + (point))))) + (if goback (goto-char start) + ;; else + (if py-scroll-process-buffer + (let* ((pop-up-windows t) + (pwin (display-buffer pbuf))) + (set-window-point pwin (point))))) + (set-buffer curbuf) + (if file-finished + (progn + (py-delete-file-silently (car py-file-queue)) + (setq py-file-queue (cdr py-file-queue)) + (if py-file-queue + (py-execute-file pyproc (car py-file-queue))))) + (and goend + (progn (set-buffer pbuf) + (goto-char (point-max)))) + )) + (set-buffer curbuf)))) (defun py-execute-buffer () "Send the contents of the buffer to a Python interpreter. |