diff Misc/python-mode.el @ 6731:21656204dd4f legacy-trunk

(py-jump-on-exception): Variable which if t, means that if an exception occurs in a synchronous Python subprocess, the mode will automatically jump to the innermost exception.
author Barry Warsaw <barry@python.org>
date Wed, 03 Dec 1997 05:25:48 +0000
parents 9c9a87b5bb17
children e97b8237591c
line wrap: on
line diff
--- a/Misc/python-mode.el	Wed Dec 03 05:03:44 1997 +0000
+++ b/Misc/python-mode.el	Wed Dec 03 05:25:48 1997 +0000
@@ -238,6 +238,12 @@
   :type 'boolean
   :group 'python)
 
+(defcustom py-jump-on-exception t
+  "*Jump to innermost exception frame in *Python Output* buffer.
+When this variable is non-nil and ane exception occurs when running
+Python code synchronously in a subprocess, jump immediately to the
+source code of the innermost frame.")
+
 (defcustom py-backspace-function 'backward-delete-char-untabify
   "*Function called by `py-electric-backspace' when deleting backwards."
   :type 'function
@@ -1043,15 +1049,21 @@
       (set-buffer curbuf))))
 
 (defun py-postprocess-output-buffer (buf)
-  (save-excursion
-    (set-buffer buf)
-    (beginning-of-buffer)
-    (while (re-search-forward py-traceback-line-re nil t)
-      (let ((file (match-string 1))
-	    (line (string-to-int (match-string 2))))
-	(py-highlight-line (py-point 'bol) (py-point 'eol) file line))
+  (let (line file bol)
+    (save-excursion
+      (set-buffer buf)
+      (beginning-of-buffer)
+      (while (re-search-forward py-traceback-line-re nil t)
+	(setq file (match-string 1)
+	      line (string-to-int (match-string 2))
+	      bol (py-point 'bol))
+	(py-highlight-line bol (py-point 'eol) file line))
+      (when (and py-jump-on-exception line)
+	(beep)
+	(py-jump-to-exception file line))
       )))
 
+
 
 ;;; Subprocess commands