summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorChaos Eternal <chaos@shlug.org>2017-08-20 22:23:38 +0800
committerJose Antonio Ortega Ruiz <jao@gnu.org>2017-08-28 02:54:04 +0200
commit87d8ad28396dd82920d55837cc6e8265b3f5991d (patch)
tree80097cab68a660b784d3a177a530cce8041899ad /elisp
parentc8caccbadb56fd20ac77d770b03bbe2307014038 (diff)
downloadgeiser-guile-87d8ad28396dd82920d55837cc6e8265b3f5991d.tar.gz
geiser-guile-87d8ad28396dd82920d55837cc6e8265b3f5991d.tar.bz2
Add geiser-mode-eval-to-buffer-transformer
geiser-mode-eval-to-buffer-transformer will take 2 argments: errstring and result when eval-to-buffer, the result will be transformed by this procedure e.g. (setq geiser-mode-eval-to-buffer-transformer (lambda (estring x) (let ((l (length x)) (p (seq-position x ?\n))) (if (and p (< (+ 1 p) l)) (format "\n#| %s%s\n |#" estring x) (format ";;=> %s%s" estring x)))))
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-mode.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index 0d00662..927a9b9 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -72,6 +72,16 @@ active when `geiser-mode' is activated in a buffer."
:group 'geiser-mode
:type 'string)
+(geiser-custom--defcustom geiser-mode-eval-to-buffer-transformer nil
+ "When `geiser-mode-eval-last-sexp-to-buffer', the result will be transformed using this function
+default behavior is just prepend with `geiser-mode-eval-to-buffer-prefix'
+takes two arguments: `msg' and `is-error?'
+`msg' is the result string going to be transformed,
+`is-error?' is a bool indicate whether the result is an error msg
+"
+ :group 'geiser-mode
+ :type 'function)
+
;;; Evaluation commands:
@@ -149,6 +159,10 @@ With a prefix, revert the effect of `geiser-mode-eval-last-sexp-to-buffer' "
(setq bosexp (point))
(forward-sexp)
(point)))
+ (ret-transformer (or geiser-mode-eval-to-buffer-transformer
+ (lambda (msg is-error?)
+ (format "%s%s%s" geiser-mode-eval-to-buffer-prefix
+ (if is-error? "ERROR" "") msg))))
(ret (save-excursion
(geiser-eval-region bosexp ;beginning of sexp
eosexp ;end of sexp
@@ -161,12 +175,10 @@ With a prefix, revert the effect of `geiser-mode-eval-last-sexp-to-buffer' "
geiser-mode-eval-last-sexp-to-buffer))
(str (geiser-eval--retort-result-str ret (when will-eval-to-buffer ""))))
(cond ((not will-eval-to-buffer) str)
- (err (insert (format "%sERROR:%s"
- geiser-mode-eval-to-buffer-prefix
- (geiser-eval--error-str err))))
+ (err (insert (funcall ret-transformer (geiser-eval--error-str err) t)))
((string= "" str))
(t (push-mark)
- (insert (format "%s%s" geiser-mode-eval-to-buffer-prefix str))))))
+ (insert (funcall ret-transformer str nil))))))
(defun geiser-compile-definition (&optional and-go)
"Compile the current definition in the Geiser REPL.