mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 09:31:39 -05:00
Add other-window option to ein:pytools-jump-to-source-command
This commit is contained in:
parent
7c04c3927f
commit
9ecca23f2e
1 changed files with 31 additions and 26 deletions
|
@ -48,7 +48,7 @@
|
||||||
kernel
|
kernel
|
||||||
(format "__import__('sys').path.append('%s')" ein:source-dir)))
|
(format "__import__('sys').path.append('%s')" ein:source-dir)))
|
||||||
|
|
||||||
(defun ein:pytools-jump-to-source (kernel object)
|
(defun ein:pytools-jump-to-source (kernel object other-window)
|
||||||
(ein:log 'info "Jumping to the source of %s..." object)
|
(ein:log 'info "Jumping to the source of %s..." object)
|
||||||
(ein:kernel-execute
|
(ein:kernel-execute
|
||||||
kernel
|
kernel
|
||||||
|
@ -56,37 +56,42 @@
|
||||||
(list
|
(list
|
||||||
:output
|
:output
|
||||||
(cons
|
(cons
|
||||||
(lambda (object msg-type content)
|
(lambda (packed msg-type content)
|
||||||
(ein:case-equal msg-type
|
(let ((object (nth 0 packed))
|
||||||
(("stream")
|
(other-window (nth 1 packed)))
|
||||||
(ein:aif (plist-get content :data)
|
(ein:case-equal msg-type
|
||||||
(if (or (string-match "^WARNING: .*" it)
|
(("stream")
|
||||||
(string-match
|
(ein:aif (plist-get content :data)
|
||||||
"^Traceback (most recent call last):\n" it)
|
(if (or (string-match "^WARNING: .*" it)
|
||||||
(string-match "^.*<ipython-input-[^>\n]+>\n" it))
|
(string-match
|
||||||
(ein:log 'info
|
"^Traceback (most recent call last):\n" it)
|
||||||
"Jumping to the source of %s...Not found" object)
|
(string-match "^.*<ipython-input-[^>\n]+>\n" it))
|
||||||
(let* ((filename-lineno (split-string it "\n"))
|
|
||||||
(filename (car filename-lineno))
|
|
||||||
(lineno (string-to-number (cadr filename-lineno))))
|
|
||||||
(unless (equal filename "")
|
|
||||||
(find-file-other-window filename)
|
|
||||||
(goto-char (point-min))
|
|
||||||
(forward-line (1- lineno))
|
|
||||||
(ein:log 'info
|
(ein:log 'info
|
||||||
"Jumping to the source of %s...Done" object))))))
|
"Jumping to the source of %s...Not found" object)
|
||||||
(("pyerr")
|
(let* ((filename-lineno (split-string it "\n"))
|
||||||
(ein:log 'info
|
(filename (car filename-lineno))
|
||||||
"Jumping to the source of %s...Not found" object))))
|
(lineno (string-to-number (cadr filename-lineno))))
|
||||||
object))))
|
(unless (equal filename "")
|
||||||
|
(funcall (if other-window
|
||||||
|
#'find-file-other-window
|
||||||
|
#'find-file)
|
||||||
|
filename)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(forward-line (1- lineno))
|
||||||
|
(ein:log 'info
|
||||||
|
"Jumping to the source of %s...Done" object))))))
|
||||||
|
(("pyerr")
|
||||||
|
(ein:log 'info
|
||||||
|
"Jumping to the source of %s...Not found" object)))))
|
||||||
|
(list object other-window)))))
|
||||||
|
|
||||||
(defun ein:pytools-jump-to-source-command ()
|
(defun ein:pytools-jump-to-source-command (&optional other-window)
|
||||||
(interactive)
|
(interactive "P")
|
||||||
(let ((kernel (ein:pytools-get-kernel))
|
(let ((kernel (ein:pytools-get-kernel))
|
||||||
(object (ein:object-at-point)))
|
(object (ein:object-at-point)))
|
||||||
(assert (ein:kernel-ready-p kernel) nil "Kernel is not ready.")
|
(assert (ein:kernel-ready-p kernel) nil "Kernel is not ready.")
|
||||||
(assert object nil "Object at point not found.")
|
(assert object nil "Object at point not found.")
|
||||||
(ein:pytools-jump-to-source kernel object)))
|
(ein:pytools-jump-to-source kernel object other-window)))
|
||||||
|
|
||||||
(provide 'ein-pytools)
|
(provide 'ein-pytools)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue