Skip to content

Commit

Permalink
more generic public API
Browse files Browse the repository at this point in the history
this commit makes it possible to use EROS with any other evaluation
function as long as it returns a string.  Thus other languages may set
up support for EROS.
  • Loading branch information
andreyorst committed Mar 19, 2023
1 parent a9a92bd commit 72cf2f8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions eros.el
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
;;; eros.el --- Evaluation Result OverlayS for Emacs Lisp -*- lexical-binding: t; -*-

;; Copyright (C) 2016-2018 Tianxiang Xiong
;; Copyright (C) 2016-2021 Tianxiang Xiong

;; Author: Tianxiang Xiong <[email protected]>
;; Keywords: convenience, lisp
;; Package-Requires: ((emacs "24.4"))
;; URL: https://github.com/xiongtx/eros
;; Version: 0.1.0
;; Version: 0.2.0

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -232,16 +232,17 @@ This function also removes itself from `pre-command-hook'."
(remove-hook 'pre-command-hook #'eros--remove-result-overlay 'local)
(remove-overlays nil nil 'category 'result))

(defun eros--eval-overlay (value point)
"Make overlay for VALUE at POINT."
(eros--make-result-overlay (format "%S" value)
:where point
:duration eros-eval-result-duration)
value)


;; API

;;;###autoload
(defun eros-eval-overlay (string point)
"Make overlay for STRING value at POINT."
(eros--make-result-overlay string
:where point
:duration eros-eval-result-duration))

;;;###autoload
(defun eros-eval-last-sexp (eval-last-sexp-arg-internal)
"Wrapper for `eval-last-sexp' that overlays results."
Expand All @@ -250,19 +251,18 @@ This function also removes itself from `pre-command-hook'."
(setq eros--last-result result)
(when (get-buffer eros--inspect-buffer-name)
(eros-inspect-last-result))
(eros--eval-overlay
result
(eros-eval-overlay
(format "%S" result)
(point))))

;;;###autoload
(defun eros-eval-defun (edebug-it)
"Wrapper for `eval-defun' that overlays results."
(interactive "P")
(eros--eval-overlay
(eval-defun edebug-it)
(save-excursion
(end-of-defun)
(point))))
(let ((value (eval-defun edebug-it))
(point (save-excursion (end-of-defun) (point))))
(eros-eval-overlay (format "%S" value) point)
value))

(defun eros-inspect-last-result ()
"Inspect the result of last `eros-eval-'."
Expand Down

0 comments on commit 72cf2f8

Please sign in to comment.