Skip to content

Commit

Permalink
(py-execute-region): Watch out for shell-command-on-region killing a
Browse files Browse the repository at this point in the history
zero sized output buffer.
  • Loading branch information
warsaw committed Mar 25, 1998
1 parent 69c70a2 commit 512af04
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Misc/python-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ Electric behavior is inhibited inside a string or comment."
(set-buffer curbuf))))

(defun py-postprocess-output-buffer (buf)
;; Highlight exceptions found in BUF
(let (line file bol)
(save-excursion
(set-buffer buf)
Expand Down Expand Up @@ -1257,10 +1258,15 @@ is inserted at the end. See also the command `py-clear-queue'."
(t
;; otherwise either run it synchronously in a subprocess
(shell-command-on-region start end py-python-command py-output-buffer)
(setq py-exception-buffer (current-buffer))
(py-postprocess-output-buffer py-output-buffer)
(pop-to-buffer py-output-buffer)
))))
;; shell-command-on-region kills the output buffer if it never
;; existed and there's no output from the command
(if (not (get-buffer py-output-buffer))
(message "No output.")
(setq py-exception-buffer (current-buffer))
(py-postprocess-output-buffer py-output-buffer)
(pop-to-buffer py-output-buffer)
))
)))

;; Code execution command
(defun py-execute-buffer (&optional async)
Expand Down

0 comments on commit 512af04

Please sign in to comment.