From 210068c7d552c35b958f0647bbb5bfa3cb8e4726 Mon Sep 17 00:00:00 2001 From: Andrew Whatson Date: Fri, 19 Jun 2020 16:44:54 +1000 Subject: Refactor to make repl/impl proj argument optional --- elisp/geiser-repl.el | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 82ee628..17dfd45 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -283,24 +283,27 @@ module command as a string") (and geiser-repl--repl (get-buffer-process geiser-repl--repl))) -(defun geiser-repl--repl/impl (impl proj &optional repls) - (catch 'repl - (dolist (repl (or repls geiser-repl--repls)) - (when (buffer-live-p repl) - (with-current-buffer repl - (when (and (eq geiser-impl--implementation impl) - (eq geiser-repl--project proj)) - (throw 'repl repl))))))) +(defun geiser-repl--repl/impl (impl &optional proj repls) + (let ((proj (or proj + geiser-repl--project + (geiser-repl--current-project))) + (repls (or repls + geiser-repl--repls))) + (catch 'repl + (dolist (repl repls) + (when (buffer-live-p repl) + (with-current-buffer repl + (when (and (eq geiser-impl--implementation impl) + (eq geiser-repl--project proj)) + (throw 'repl repl)))))))) (defun geiser-repl--set-up-repl (impl) (or (and (not impl) geiser-repl--repl) (setq geiser-repl--repl (let ((impl (or impl geiser-impl--implementation - (geiser-impl--guess))) - (proj (or geiser-repl--project - (geiser-repl--current-project)))) - (when impl (geiser-repl--repl/impl impl proj)))))) + (geiser-impl--guess)))) + (when impl (geiser-repl--repl/impl impl)))))) (defun geiser-repl--active-impls () (let ((act)) @@ -951,12 +954,11 @@ With prefix argument, ask for which one if more than one is running. If no REPL is running, execute `run-geiser' to start a fresh one." (interactive "P") (let* ((impl (or impl geiser-impl--implementation)) - (proj (geiser-repl--current-project)) (in-repl (eq major-mode 'geiser-repl-mode)) (in-live-repl (and in-repl (get-buffer-process (current-buffer)))) (repl (unless ask (if impl - (geiser-repl--repl/impl impl proj) + (geiser-repl--repl/impl impl) (or geiser-repl--repl (car geiser-repl--repls)))))) (cond (in-live-repl (when (and (not (eq repl buffer)) -- cgit v1.2.3