summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-04-11 07:16:17 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-04-11 07:16:17 +0200
commit96f8693803a4f49770f3bd7a1b3dbad778522987 (patch)
treeff83dd2508b3c48c6056506a0d112ca28de6ff71 /elisp
parentd32d4e1a4480f236089fb27ce5f5c4968f1119e7 (diff)
downloadgeiser-chez-96f8693803a4f49770f3bd7a1b3dbad778522987.tar.gz
geiser-chez-96f8693803a4f49770f3bd7a1b3dbad778522987.tar.bz2
New flag to automatically start REPLs when geiser-mode is activated
When no live REPL is found, of course. The flag's imaginatively called geiser-mode-start-repl-p.
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-mode.el12
-rw-r--r--elisp/geiser-repl.el14
2 files changed, 20 insertions, 6 deletions
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index 77feeec..b6d083a 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -41,6 +41,12 @@ scheme buffers."
:group 'geiser-mode
:type 'boolean)
+(geiser-custom--defcustom geiser-mode-start-repl-p nil
+ "Whether a REPL should be automatically started if one is not
+active when `geiser-mode' is activated in a buffer."
+ :group 'geiser-mode
+ :type 'boolean)
+
(geiser-custom--defcustom geiser-mode-autodoc-p t
"Whether `geiser-autodoc-mode' gets enabled by default in Scheme buffers."
:group 'geiser-mode
@@ -258,7 +264,11 @@ interacting with the Geiser REPL is at your disposal.
(geiser-autodoc-mode (if geiser-mode 1 -1)))
(when geiser-mode-smart-tab-p
(geiser-smart-tab-mode (if geiser-mode 1 -1)))
- (geiser-syntax--add-kws))
+ (geiser-syntax--add-kws)
+ (when (and geiser-mode
+ geiser-mode-start-repl-p
+ (not (geiser-repl--connection*)))
+ (save-current-buffer (switch-to-geiser))))
(defun turn-on-geiser-mode ()
"Enable `geiser-mode' (in a Scheme buffer)."
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 0b4fe54..1d1b317 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -376,12 +376,15 @@ module command as a string")
(overlay-end comint-last-prompt-overlay)
t)))))
-(defun geiser-repl--connection ()
+(defun geiser-repl--connection* ()
(let ((buffer (geiser-repl--set-up-repl geiser-impl--implementation)))
- (or (and (buffer-live-p buffer)
- (get-buffer-process buffer)
- (with-current-buffer buffer geiser-repl--connection))
- (error "No Geiser REPL for this buffer (try M-x run-geiser)"))))
+ (and (buffer-live-p buffer)
+ (get-buffer-process buffer)
+ (with-current-buffer buffer geiser-repl--connection))))
+
+(defun geiser-repl--connection ()
+ (or (geiser-repl--connection*)
+ (error "No Geiser REPL for this buffer (try M-x run-geiser)")))
(setq geiser-eval--default-connection-function 'geiser-repl--connection)
@@ -677,6 +680,7 @@ buffer."
(defun switch-to-geiser (&optional ask impl buffer)
"Switch to running Geiser REPL.
+
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")