diff options
Diffstat (limited to 'elisp/geiser-mode.el')
-rw-r--r-- | elisp/geiser-mode.el | 20 |
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. |