diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-17 00:44:11 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-17 00:44:11 +0100 |
commit | 4814d02ad67edb086b8ccd8ad6a6798fe780b968 (patch) | |
tree | f0d2e45fe5cc4020f0b5d3ea8c9dd063f9bfa243 /elisp | |
parent | f574939e5db2f64eab21493bb70ac6605f76646f (diff) | |
download | geiser-4814d02ad67edb086b8ccd8ad6a6798fe780b968.tar.gz geiser-4814d02ad67edb086b8ccd8ad6a6798fe780b968.tar.bz2 |
Separate commands for evaluation and compilation.
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/geiser-autodoc.el | 7 | ||||
-rw-r--r-- | elisp/geiser-compile.el | 2 | ||||
-rw-r--r-- | elisp/geiser-completion.el | 6 | ||||
-rw-r--r-- | elisp/geiser-doc.el | 4 | ||||
-rw-r--r-- | elisp/geiser-edit.el | 6 | ||||
-rw-r--r-- | elisp/geiser-eval.el | 28 | ||||
-rw-r--r-- | elisp/geiser-mode.el | 77 | ||||
-rw-r--r-- | elisp/geiser-syntax.el | 4 |
8 files changed, 82 insertions, 52 deletions
diff --git a/elisp/geiser-autodoc.el b/elisp/geiser-autodoc.el index 7a63ef4..3c23b32 100644 --- a/elisp/geiser-autodoc.el +++ b/elisp/geiser-autodoc.el @@ -74,9 +74,10 @@ when `geiser-autodoc-display-module-p' is on." (cdr geiser-autodoc--last) (cdr pr)) (setq geiser-autodoc--last-funs funs) - (geiser-eval--send `(:gs ((:ge arguments) ,@(mapcar (lambda (f) (list 'quote (car f))) - funs))) - 'geiser-autodoc--function-args-cont) + (geiser-eval--send + `(:eval ((:ge arguments) + ,@(mapcar (lambda (f) (list 'quote (car f))) funs))) + 'geiser-autodoc--function-args-cont) "")))) (defun geiser-autodoc--function-args-cont (ret) diff --git a/elisp/geiser-compile.el b/elisp/geiser-compile.el index bb85637..2c51425 100644 --- a/elisp/geiser-compile.el +++ b/elisp/geiser-compile.el @@ -76,7 +76,7 @@ (msg (format "%s %s ..." msg path))) (message msg) (geiser-compile--display-result - msg (geiser-eval--send/wait `(:gs ((:ge ,op) ,path) (geiser eval)))))) + msg (geiser-eval--send/wait `(:eval ((:ge ,op) ,path) (geiser eval)))))) ;;; User commands: diff --git a/elisp/geiser-completion.el b/elisp/geiser-completion.el index 22b36a1..fd22044 100644 --- a/elisp/geiser-completion.el +++ b/elisp/geiser-completion.el @@ -145,10 +145,10 @@ terminates a current completion." ;;; Completion functionality: (defsubst geiser-completion--symbol-list (prefix) - (geiser-eval--send/result `(:gs ((:ge completions) ,prefix)))) + (geiser-eval--send/result `(:eval ((:ge completions) ,prefix)))) (defsubst geiser-completion--module-list () - (geiser-eval--send/result '(:gs ((:ge all-modules))))) + (geiser-eval--send/result '(:eval ((:ge all-modules))))) (defvar geiser-completion--symbol-list-func (completion-table-dynamic 'geiser-completion--symbol-list)) @@ -178,7 +178,7 @@ terminates a current completion." (completing-read (or prompt "Module name: ") (geiser-completion--module-list) nil nil - (or default (geiser-syntax--buffer-module)) + (or default (format "%s" (or (geiser-syntax--buffer-module) "("))) (or history geiser-completion--module-history)))) (defun geiser--respecting-message (format &rest format-args) diff --git a/elisp/geiser-doc.el b/elisp/geiser-doc.el index 6bb1d10..3a1759c 100644 --- a/elisp/geiser-doc.el +++ b/elisp/geiser-doc.el @@ -53,10 +53,10 @@ ;;; Docstrings: (defun geiser-doc--get-docstring (symbol) - (geiser-eval--send/result `(:gs ((:ge docstring) ',symbol)))) + (geiser-eval--send/result `(:eval ((:ge docstring) ',symbol)))) (defun geiser-doc--get-module-children (module) - (geiser-eval--send/result `(:gs ((:ge module-children) (quote (:scm ,module)))))) + (geiser-eval--send/result `(:eval ((:ge module-children) (quote (:scm ,module)))))) ;;; Auxiliary functions: diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el index 5d6ca46..fad08b6 100644 --- a/elisp/geiser-edit.el +++ b/elisp/geiser-edit.el @@ -95,7 +95,7 @@ (let* ((symbol (geiser-completion--read-symbol "Edit symbol: " nil geiser-edit--symbol-history)) - (cmd `(:gs ((:ge symbol-location) ',symbol)))) + (cmd `(:eval ((:ge symbol-location) ',symbol)))) (geiser-edit--try-edit symbol (geiser-eval--send/wait cmd)))) (defun geiser-edit-symbol-at-point (&optional arg) @@ -104,7 +104,7 @@ With prefix, asks for the symbol to edit." (interactive "P") (let* ((symbol (or (and (not arg) (symbol-at-point)) (geiser-completion--read-symbol "Edit symbol: "))) - (cmd `(:gs ((:ge symbol-location) ',symbol))) + (cmd `(:eval ((:ge symbol-location) ',symbol))) (marker (point-marker))) (geiser-edit--try-edit symbol (geiser-eval--send/wait cmd)) (when marker (ring-insert find-tag-marker-ring marker)))) @@ -119,7 +119,7 @@ With prefix, asks for the symbol to edit." (defun geiser-edit-module (module) "Asks for a module and opens it in a new buffer." (interactive (list (geiser-completion--read-module))) - (let ((cmd `(:gs ((:ge module-location) (quote (:scm ,module)))))) + (let ((cmd `(:eval ((:ge module-location) (quote (:scm ,module)))))) (geiser-edit--try-edit module (geiser-eval--send/wait cmd)))) diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el index b1bd83b..4566d0b 100644 --- a/elisp/geiser-eval.el +++ b/elisp/geiser-eval.el @@ -38,22 +38,30 @@ ((eq code :f) "#f") ((eq code :t) "#t") ((listp code) - (cond ((eq (car code) :gs) (geiser-eval--gs (cdr code))) + (cond ((eq (car code) :eval) (geiser-eval--eval (cdr code))) + ((eq (car code) :comp) (geiser-eval--comp (cdr code))) + ((eq (car code) :module) (geiser-eval--module (cadr code))) ((eq (car code) :ge) (geiser-eval--ge (cadr code))) ((eq (car code) :scm) (cadr code)) (t (concat "(" (mapconcat 'geiser-eval--scheme-str code " ") ")")))) ((symbolp code) (format "%s" code)) (t (format "%S" code)))) -(defsubst geiser-eval--gs (code) - (concat "((@ (geiser eval) eval-in) (quote " - (geiser-eval--scheme-str (nth 0 code)) - ") (quote " - (or (and (nth 1 code) - (geiser-eval--scheme-str (nth 1 code))) - (geiser-syntax--buffer-module) - "#f") - "))")) +(defsubst geiser-eval--eval (code) + (geiser-eval--scheme-str + `((@ (geiser eval) eval-in) (quote ,(nth 0 code)) (:module ,(nth 1 code))))) + +(defsubst geiser-eval--comp (code) + (geiser-eval--scheme-str + `((@ (geiser eval) compile-in) (quote ,(nth 0 code)) (:module ,(nth 1 code))))) + +(defsubst geiser-eval--module (code) + (geiser-eval--scheme-str + (cond ((or (eq code '(())) (null code)) + `(quote ,(or (geiser-syntax--buffer-module) :f))) + ((listp code) `(quote ,code)) + ((stringp code) (:scm code)) + (t (error "Invalid module spec: %S" code))))) (defsubst geiser-eval--ge (proc) (format "(@ (geiser emacs) ge:%s)" proc)) diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el index cd7a5a6..3c2f1a9 100644 --- a/elisp/geiser-mode.el +++ b/elisp/geiser-mode.el @@ -70,16 +70,9 @@ (newline)) (geiser-mode--pop-to-buffer))) - -;;; Evaluation commands: - -(defun geiser-send-region (start end &optional and-go) - "Send the current region to the Geiser REPL. -With prefix, goes to the REPL buffer afterwards (as -`geiser-send-region-and-go')" - (interactive "rP") +(defun geiser-eval--send-region (compile start end and-go) (let* ((str (buffer-substring-no-properties start end)) - (code `(:gs (:scm ,str))) + (code `(,(if compile :comp :eval) (:scm ,str))) (ret (geiser-eval--send/wait code)) (err (geiser-eval--retort-error ret))) (when and-go @@ -90,31 +83,57 @@ With prefix, goes to the REPL buffer afterwards (as (message (format "=> %s" (geiser-eval--retort-result ret))) (geiser-eval--display-error err (geiser-eval--retort-output ret))))) -(defun geiser-send-region-and-go (start end) - "Send the current region to the Geiser REPL and visit it afterwads." + +;;; Evaluation commands: + +(defun geiser-eval-region (start end &optional and-go) + "Eval the current region in the Geiser REPL. +With prefix, goes to the REPL buffer afterwards (as +`geiser-eval-region-and-go')" + (interactive "rP") + (geiser-eval--send-region nil start end and-go)) + +(defun geiser-eval-region-and-go (start end) + "Eval the current region in the Geiser REPL and visit it afterwads." (interactive "r") - (geiser-send-region start end t)) + (geiser-eval-region start end t)) -(defun geiser-send-definition (&optional and-go) - "Send the current definition to the Geiser REPL. +(defun geiser-eval-definition (&optional and-go) + "Eval the current definition in the Geiser REPL. With prefix, goes to the REPL buffer afterwards (as -`geiser-send-definition-and-go')" +`geiser-eval-definition-and-go')" (interactive "P") (save-excursion (end-of-defun) (let ((end (point))) (beginning-of-defun) - (geiser-send-region (point) end and-go)))) + (geiser-eval-region (point) end and-go)))) + +(defun geiser-eval-definition-and-go () + "Eval the current definition in the Geiser REPL and visit it afterwads." + (interactive) + (geiser-eval-definition t)) -(defun geiser-send-definition-and-go () - "Send the current definition to the Geiser REPL and visit it afterwads." +(defun geiser-eval-last-sexp () + "Eval the previous sexp in the Geiser REPL." (interactive) - (geiser-send-definition t)) + (geiser-eval-region (save-excursion (backward-sexp) (point)) (point))) + +(defun geiser-compile-definition (&optional and-go) + "Compile the current definition in the Geiser REPL. +With prefix, goes to the REPL buffer afterwards (as +`geiser-eval-definition-and-go')" + (interactive "P") + (save-excursion + (end-of-defun) + (let ((end (point))) + (beginning-of-defun) + (geiser-eval--send-region t (point) end and-go)))) -(defun geiser-send-last-sexp () - "Send the previous sexp to the Geiser REPL." +(defun geiser-compile-definition-and-go () + "Compile the current definition in the Geiser REPL and visit it afterwads." (interactive) - (geiser-send-region (save-excursion (backward-sexp) (point)) (point))) + (geiser-compile-definition t)) ;;; Geiser mode: @@ -159,11 +178,13 @@ interacting with the Geiser REPL is at your disposal. (define-key geiser-mode-map "\M-." 'geiser-edit-symbol-at-point) (define-key geiser-mode-map "\M-," 'geiser-edit-pop-edit-symbol-stack) -(define-key geiser-mode-map "\M-\C-x" 'geiser-send-definition) -(define-key geiser-mode-map "\C-x\C-e" 'geiser-send-last-sexp) -(define-key geiser-mode-map "\C-c\M-e" 'geiser-send-definition-and-go) -(define-key geiser-mode-map "\C-c\C-r" 'geiser-send-region) -(define-key geiser-mode-map "\C-c\M-r" 'geiser-send-region-and-go) +(define-key geiser-mode-map "\M-\C-x" 'geiser-eval-definition) +(define-key geiser-mode-map "\C-x\C-e" 'geiser-eval-last-sexp) +(define-key geiser-mode-map "\C-c\M-e" 'geiser-eval-definition-and-go) +(define-key geiser-mode-map "\C-c\C-r" 'geiser-eval-region) +(define-key geiser-mode-map "\C-c\M-r" 'geiser-eval-region-and-go) +(define-key geiser-mode-map "\C-c\M-c" 'geiser-compile-definition) +(define-key geiser-mode-map "\C-c\C-c" 'geiser-compile-definition-and-go) (geiser-mode--triple-chord ?d ?a 'geiser-autodoc-mode) (geiser-mode--triple-chord ?d ?d 'geiser-doc-symbol-at-point) @@ -171,8 +192,6 @@ interacting with the Geiser REPL is at your disposal. (geiser-mode--triple-chord ?e ?m 'geiser-edit-module) -(define-key geiser-mode-map "\C-c\M-c" 'geiser-compile-definition) -(define-key geiser-mode-map "\C-c\C-c" 'geiser-compile-definition-and-go) (define-key geiser-mode-map "\C-c\C-t" 'geiser-trace-procedure) (define-key geiser-mode-map "\C-c\C-x" 'geiser-expand-current-form) diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el index 6577152..2c69a5c 100644 --- a/elisp/geiser-syntax.el +++ b/elisp/geiser-syntax.el @@ -40,7 +40,7 @@ (save-excursion (goto-char (point-min)) (when (re-search-forward geiser-syntax--module-definition-re nil t) - (match-string-no-properties 1)))))) + (car (read-from-string (match-string-no-properties 1)))))))) ;;; Indentation: @@ -48,6 +48,8 @@ (let ((defuns '(catch))) (mapc (lambda (d) (put d 'scheme-indent-function 'defun)) defuns))) +(geiser-syntax--setup-scheme-indent) + ;;; Code parsing: |