Skip to content

Instantly share code, notes, and snippets.

@dov
Created May 15, 2018 08:09
Show Gist options
  • Save dov/af0fd180ecb2e49dfca5868e2d56ea2e to your computer and use it in GitHub Desktop.
Save dov/af0fd180ecb2e49dfca5868e2d56ea2e to your computer and use it in GitHub Desktop.
Elisp function to jump to the python exception line pointed at
(defun py-jump-exception-line ()
"This function parses the python exception stack and jumps to the line pointed at"
(interactive)
(save-selected-window
(let ((file nil)
(line nil)
(buffer (current-buffer)))
(beginning-of-line)
(forward-word)
(forward-char)
(forward-char)
(set-mark-command nil)
(search-forward "\"")
(backward-char)
(exchange-point-and-mark)
(setq file (buffer-substring-no-properties (point) (mark)))
(exchange-point-and-mark)
(forward-word)
(forward-word)
(backward-word)
(set-mark-command nil)
(forward-word)
(exchange-point-and-mark)
(setq line (buffer-substring-no-properties (point) (mark)))
(deactivate-mark)
(beginning-of-line)
(find-file-other-window file)
(goto-line (string-to-number line))
(recenter)
)))
(global-set-key (kbd "C-`") 'py-jump-exception-line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment