Closed Xparx closed 7 years ago
Thanks for your interest in the package. This "check if REPL is running, if not start it; if running send code" part is hard coded at this moment.
The easiest (not-so-elegant) solution may be to wrap the eval-in-repl-python function in a custom function which first check for the REPL status, aborts if it's not running, and call eval-in-repl-python if it's running.
I think it's possible using the eir--matching-elements function (REPL checker) as a conditional. I'll think about this when I have time. https://github.com/kaz-yos/eval-in-repl/blob/master/eval-in-repl.el#L98
Thanks for your answer. I'll check back here and see if the feature is there. I'm no elisp person, otherwise I could have helped.
Can you test the following? Please put the following definition override right after (require 'eval-in-repl-python)
. This should check for REPL and only does stuff when it is running. I'll think about including this as a configurable option in the future (so I'll keep this open).
(defun eir-eval-in-python ()
"eval-in-repl for Python."
(interactive)
;; Define local variables
(let* ((script-window (selected-window)))
;;
;; Commented out
;; (eir-repl-start "*Python*" #'run-python)
;; Proceed only if REPL is active
(if (eir--matching-elements
"*Python*"
(mapcar #'buffer-name (buffer-list)))
;; Check if selection is present
(if (and transient-mark-mode mark-active)
;; If selected, send region
(eir-send-to-python (buffer-substring-no-properties (point) (mark)))
;; If not selected, do all the following
;; Move to the beginning of line
(beginning-of-line)
;; Set mark at current position
(set-mark (point))
;; Go to the end of statment
(python-nav-end-of-statement)
;; Go to the end of block
(python-nav-end-of-block)
;; Send region if not empty
(if (not (equal (point) (mark)))
;; Add one more character for newline unless at EOF
;; This does not work if the statement asks for an input.
(eir-send-to-python (buffer-substring-no-properties
(min (+ 1 (point)) (point-max))
(mark)))
;; If empty, deselect region
(setq mark-active nil))
;; Move to the next statement
(python-nav-forward-statement)
;; Switch to the shell
(python-shell-switch-to-shell)
;; Switch back to the script window
(select-window script-window)))))
Thanks! I will try it out as soon as I get time for my Emacs config again.
In version 0.9.0, I made the package minimally invasive to the current window configuration. The details are explained in the other issue thread.
Hi, Thanks for giving me the notice, and sorry for not getting back sooner. I just installed the latest version and tried out the python eval-in-repl. Seems to work great now. I installed it through el-get and created a recipe for it here.
Thanks for creating the el-get recipe!
Hi, I'm playing around with the python eval-in-repl and was wondering if there is a possibility to configure it so that when you press the key combo C- the line is sent but if you don't have the inferor mode buffer open the the buffer configuration will just stay as it is.
I usually have the buffers as I want them and this is changing that somewhat.