[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-guile 8377f5e 028/284: Refactoring of the eval/comp
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-guile 8377f5e 028/284: Refactoring of the eval/compile procedures. |
Date: |
Sun, 1 Aug 2021 18:29:10 -0400 (EDT) |
branch: elpa/geiser-guile
commit 8377f5e282cf318a2af9fa8864aaf15ff2fb22ef
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Refactoring of the eval/compile procedures.
---
geiser/emacs.scm | 46 ++++++++++++++++++++--------------------------
1 file changed, 20 insertions(+), 26 deletions(-)
diff --git a/geiser/emacs.scm b/geiser/emacs.scm
index 3c66eb2..382958d 100644
--- a/geiser/emacs.scm
+++ b/geiser/emacs.scm
@@ -58,26 +58,34 @@
(cons 'msg (if msg (apply format (cons #f (cons msg margs))) '()))
(cons 'rest (or rest '())))))
-(define (ge:eval form module-name)
- "Evals @var{form} in the module designated by @var{module-name}.
-If @var{module-name} is @var{#f} or resolution fails, the current module is
used instead.
-The result is a list of the form ((RESULT . <form-value>) (OUTPUT . <string>))
-if no evaluation error happens, or ((ERROR (KEY . <error-key>) <error-arg>...))
-in case of errors. Each error arg is a cons (NAME . VALUE), where NAME includes
-SUBR, MSG and REST."
+(define (evaluate form module evaluator)
(let ((module (or (and (list? module-name)
(resolve-module module-name))
(current-module))))
(catch #t
(lambda ()
(let ((result #f))
- (let ((output
- (with-output-to-string
- (lambda ()
- (set! result (eval form module))))))
+ (let ((output (with-output-to-string
+ (lambda ()
+ (set! result (evaluator form module))))))
(write-result result output))))
write-error)))
+(define (eval-compile form module)
+ (save-module-excursion
+ (lambda ()
+ (set-current-module module)
+ (compile form))))
+
+(define (ge:eval form module-name)
+ "Evals @var{form} in the module designated by @var{module-name}.
+If @var{module-name} is @var{#f} or resolution fails, the current module is
used instead.
+The result is a list of the form ((RESULT . <form-value>) (OUTPUT . <string>))
+if no evaluation error happens, or ((ERROR (KEY . <error-key>) <error-arg>...))
+in case of errors. Each error arg is a cons (NAME . VALUE), where NAME includes
+SUBR, MSG and REST."
+ (evaluate form module-name eval))
+
(define (ge:compile form module-name)
"Compiles @var{form} in the module designated by @var{module-name}.
If @var{module-name} is @var{#f} or resolution fails, the current module is
used instead.
@@ -85,21 +93,7 @@ The result is a list of the form ((RESULT . <form-value>)
(OUTPUT . <string>))
if no evaluation error happens, or ((ERROR (KEY . <error-key>) <error-arg>...))
in case of errors. Each error arg is a cons (NAME . VALUE), where NAME includes
SUBR, MSG and REST."
- (let ((module (or (and (list? module-name)
- (resolve-module module-name))
- (current-module))))
- (catch #t
- (lambda ()
- (let ((result #f))
- (let ((output
- (with-output-to-string
- (lambda ()
- (save-module-excursion
- (lambda ()
- (set-current-module module)
- (set! result (compile form))))))))
- (write-result result output))))
- write-error)))
+ (evaluate form module-name eval-compile))
(define (ge:compile-file path)
"Compile and load file, given its full @var{path}."
- [nongnu] elpa/geiser-guile 3398bc2 012/284: Inconsequential refactorings., (continued)
- [nongnu] elpa/geiser-guile 3398bc2 012/284: Inconsequential refactorings., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile af1c5a3 013/284: Small improvements., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile a461795 017/284: Better docstring., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 6f2ed87 018/284: Recognise empty doc string in Emacs side. Small refactorings., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 63c39be 019/284: Initial support for module name completion., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 06fabb2 020/284: Compile command adapted to new compiled-file-name behaviour., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 3432ccf 021/284: New command: module documentation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 08ba036 023/284: Separate commands for evaluation and compilation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile d18c35b 025/284: Fix in symbol help signature displaying., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 3655a74 026/284: (geiser eval) functionality moved to (geiser emacs)., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 8377f5e 028/284: Refactoring of the eval/compile procedures.,
Philip Kaludercic <=
- [nongnu] elpa/geiser-guile 2ac3f91 027/284: Play nice with (ice-9 history) by using WRITE to return values to Emacs., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 49842df 031/284: Correct stack in load/compile file retorts., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 4608da2 032/284: Partial support for stack trace display., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 943e58b 039/284: Miscellaneous little fixes., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 717f3d0 040/284: Fix for autodoc when point in a rest formal arg in define., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile ea9e341 041/284: Bug fix., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile acde425 043/284: Macro-expand commands., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 7fcb4ea 047/284: Autodoc enhancements:, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile eeda11c 050/284: Leave quasiquote alone in autodoc., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile af8296f 051/284: generic-methods implemented in scheme (no emacs side yet)., Philip Kaludercic, 2021/08/01