Add utility function/binding to evaluate math in place

This commit is contained in:
Adam Goldsmith 2022-08-07 22:45:08 -04:00
parent 8e089fef9b
commit 88fa55e297

View File

@ -334,6 +334,18 @@
(add-hook 'yaml-mode-hook
(lambda () (setq-local show-trailing-whitespace t))))
(use-package calc
:bind ("C-x M-e" . calc-eval-in-place)
:init
(defun calc-eval-in-place ()
(interactive)
(let ((result (calc-eval (buffer-substring-no-properties (point) (mark)))))
(if (stringp result)
(progn
(delete-region (point) (mark))
(insert result))
(apply 'user-error "Error at charater %d: %s" result)))))
;;;; external packages (required)
(use-package auto-package-update :ensure
:commands auto-package-update-cli