Created
December 21, 2014 01:08
-
-
Save H2CO3/75a94ff15691f4b60ab9 to your computer and use it in GitHub Desktop.
Sparkling inline evaluation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; C-c C-e | |
(defun sparkling-eval-replace-expr (start end) | |
"Evaluate the contents of the selected region (or the region between START and END) as an expression and replace it with the result." | |
(interactive "r") | |
(call-process "spn" nil t nil "-e" (delete-and-extract-region start end)) | |
) | |
;; C-c C-r | |
(defun sparkling-eval-replace-stmt (start end) | |
"Evaluate the contents of the selected region (or the region between START and END) as statements and replace it with the result." | |
(interactive "r") | |
(call-process "spn" nil t nil "-t" "-r" (delete-and-extract-region start end)) | |
) | |
(defvar sparkling-eval-buffer-name "*sparkling-eval*") | |
;; C-M-e | |
(defun sparkling-eval-expr (start end) | |
"Evaluate the contents of the selected region (or the region between START and END) as an expression." | |
(interactive "r") | |
(call-process "spn" nil sparkling-eval-buffer-name nil "-e" (buffer-substring start end)) | |
(switch-to-buffer-other-window sparkling-eval-buffer-name) | |
) | |
;; C-M-r | |
(defun sparkling-eval-stmt (start end) | |
"Evaluate the contents of the selected region (or the region between START and END) as statements." | |
(interactive "r") | |
(call-process "spn" nil sparkling-eval-buffer-name nil "-t" "-r" (buffer-substring start end)) | |
(switch-to-buffer-other-window sparkling-eval-buffer-name) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment