Last active
October 17, 2022 09:40
-
-
Save kobapan/329eb42f3709928c18eabe0143080fe2 to your computer and use it in GitHub Desktop.
リージョン選択範囲、もしくは現在行のLisp 式を(1つ)読み込み、評価した結果を、次行に挿入する
This file contains 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
(defun eval-print-region () | |
(interactive) | |
(let ((f (lambda (s e) | |
(print (eval (read (replace-regexp-in-string "," "" (buffer-substring s e)))) (current-buffer))))) | |
(if (region-active-p) | |
;; リージョン全体 | |
(funcall f (region-beginning) (region-end)) | |
;; カーソルのある行全体 | |
(progn (end-of-line) | |
(funcall f (point-at-bol) (point-at-eol)))))) | |
(define-key global-map (kbd "C-=") 'eval-print-region) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
テキストモードでふと「この計算式を評価したい」というときがある。
M-:としてミニバッファで評価しても、結果は見れるだけで、コピーされない。
そこで