Open alejandrogallo opened 1 year ago
Hey @alejandrogallo I was also thinking why wasn't there interactive interpreting feature for nix-mode. Just now, I went through python and ess way of evaluating lines.
Came up with an function:
(defun nix-eval-line ()
"Evaluates the line at point in nix-repl."
(interactive)
(let* ((start (line-beginning-position))
(end (line-end-position))
(msg (format "%s" (buffer-substring start end))))
(pop-to-buffer "*Nix-REPL*")
(insert msg)
(comint-send-input)
(other-window 1)))
With little more work, we can bring similar function like, nix-eval-buffer
, nix-eval-region
(I thing, line and region should be made as dwin)
Note: It does not start nix-repl, instead uses existing one. Let's see if author wants something like this.
Made a working nix-eval-dwim
variant:
(defun nix-eval-dwim ()
(interactive)
(let* ((start (line-beginning-position))
(end (line-end-position))
(region-string (buffer-substring (region-beginning) (region-end)))
(msg (format "%s" (if (use-region-p) region-string (buffer-substring start end)))))
(pop-to-buffer "*Nix-REPL*")
(insert msg)
(comint-send-input)
(other-window 1)))
Maybe I'm just missing something, but I could not find a functionality like this for instacne
is there something planned to send input and so on to the repl?