aboutsummaryrefslogtreecommitdiffstats
path: root/editors/emacs/sol-mode.el
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-12 18:52:52 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-07-12 18:52:52 -0300
commit90cb51a907a0f78b83cb66f497f6dc0f24f01706 (patch)
tree379e7e79a3e7c6d0e1520ab153a581689060bb4b /editors/emacs/sol-mode.el
parent19ba625e0345a88da6c29ab91a3ba2d7a8462065 (diff)
downloadSOL-90cb51a907a0f78b83cb66f497f6dc0f24f01706.tar.gz
SOL-90cb51a907a0f78b83cb66f497f6dc0f24f01706.zip
repl session commands: load, reset, quit; emacs load-file binding
Diffstat (limited to 'editors/emacs/sol-mode.el')
-rw-r--r--editors/emacs/sol-mode.el31
1 files changed, 22 insertions, 9 deletions
diff --git a/editors/emacs/sol-mode.el b/editors/emacs/sol-mode.el
index f46c0dd..0b9579d 100644
--- a/editors/emacs/sol-mode.el
+++ b/editors/emacs/sol-mode.el
@@ -15,8 +15,10 @@
;; heads, variables, references (#Name), literals, delimiters.
;; - Navigation: imenu over Relations, Rules and Queries;
;; beginning/end-of-defun over top-level forms.
-;; - An inferior Sol REPL (`run-sol') and `sol-run-buffer' to execute
-;; the current file.
+;; - An inferior Sol REPL (`run-sol'); `sol-load-file' (C-c C-l) loads
+;; the current file into the session, `sol-send-line' (C-c C-e)
+;; sends the statement at point, `sol-run-buffer' (C-c C-k) runs the
+;; file in a compilation buffer.
;; - Eglot wiring: `sol lsp' serves diagnostics, so admission errors
;; (totality, schemas, integrity) appear while typing.
;;
@@ -246,15 +248,25 @@ With ARG, repeat that many times. Returns non-nil on success."
(inferior-sol-mode)))
(pop-to-buffer inferior-sol-buffer))
+(defun sol--send (statement)
+ "Send STATEMENT to the REPL, starting it if needed."
+ (run-sol)
+ (with-current-buffer inferior-sol-buffer
+ (goto-char (point-max))
+ (insert statement)
+ (comint-send-input)))
+
(defun sol-send-line ()
"Send the current line (one statement) to the REPL."
(interactive)
- (let ((statement (string-trim (or (thing-at-point 'line t) ""))))
- (run-sol)
- (with-current-buffer inferior-sol-buffer
- (goto-char (point-max))
- (insert statement)
- (comint-send-input))))
+ (sol--send (string-trim (or (thing-at-point 'line t) ""))))
+
+(defun sol-load-file ()
+ "Load the current file into the REPL session with :load.
+The load is atomic: a rejected file changes nothing in the session."
+ (interactive)
+ (when (buffer-modified-p) (save-buffer))
+ (sol--send (format ":load %s" buffer-file-name)))
(defun sol-run-buffer ()
"Run the current file with sol, showing answers in a compilation buffer."
@@ -279,7 +291,8 @@ With ARG, repeat that many times. Returns non-nil on success."
(defvar sol-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-z") #'run-sol)
- (define-key map (kbd "C-c C-l") #'sol-send-line)
+ (define-key map (kbd "C-c C-l") #'sol-load-file)
+ (define-key map (kbd "C-c C-e") #'sol-send-line)
(define-key map (kbd "C-c C-k") #'sol-run-buffer)
(define-key map (kbd "C-c C-j") #'imenu)
map)