Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9981d22

Browse files
committed
(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.
1 parent 27ee115 commit 9981d22

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

Misc/python-mode.el

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ the Emacs bell is also rung as a warning."
238238
:type 'boolean
239239
:group 'python)
240240

241+
(defcustom py-jump-on-exception t
242+
"*Jump to innermost exception frame in *Python Output* buffer.
243+
When this variable is non-nil and ane exception occurs when running
244+
Python code synchronously in a subprocess, jump immediately to the
245+
source code of the innermost frame.")
246+
241247
(defcustom py-backspace-function 'backward-delete-char-untabify
242248
"*Function called by `py-electric-backspace' when deleting backwards."
243249
:type 'function
@@ -1043,15 +1049,21 @@ Electric behavior is inhibited inside a string or comment."
10431049
(set-buffer curbuf))))
10441050

10451051
(defun py-postprocess-output-buffer (buf)
1046-
(save-excursion
1047-
(set-buffer buf)
1048-
(beginning-of-buffer)
1049-
(while (re-search-forward py-traceback-line-re nil t)
1050-
(let ((file (match-string 1))
1051-
(line (string-to-int (match-string 2))))
1052-
(py-highlight-line (py-point 'bol) (py-point 'eol) file line))
1052+
(let (line file bol)
1053+
(save-excursion
1054+
(set-buffer buf)
1055+
(beginning-of-buffer)
1056+
(while (re-search-forward py-traceback-line-re nil t)
1057+
(setq file (match-string 1)
1058+
line (string-to-int (match-string 2))
1059+
bol (py-point 'bol))
1060+
(py-highlight-line bol (py-point 'eol) file line))
1061+
(when (and py-jump-on-exception line)
1062+
(beep)
1063+
(py-jump-to-exception file line))
10531064
)))
10541065

1066+
10551067

10561068
;;; Subprocess commands
10571069

0 commit comments

Comments
 (0)