summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1997-12-03 05:25:48 (GMT)
committerBarry Warsaw <barry@python.org>1997-12-03 05:25:48 (GMT)
commit9981d2226daa51ff3a46cb48f5276ae0e0fe5731 (patch)
tree9d75f1f852c7b5927b102be6aa35ee790d3b6615 /Misc
parent27ee115fd7fb0e8acef695ebf00ac942a32009ac (diff)
downloadcpython-9981d2226daa51ff3a46cb48f5276ae0e0fe5731.zip
cpython-9981d2226daa51ff3a46cb48f5276ae0e0fe5731.tar.gz
cpython-9981d2226daa51ff3a46cb48f5276ae0e0fe5731.tar.bz2
(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.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/python-mode.el26
1 files changed, 19 insertions, 7 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index 045d9b0..3ea1f3b 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -238,6 +238,12 @@ the Emacs bell is also rung as a warning."
: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 @@ Electric behavior is inhibited inside a string or comment."
(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