Add utility function/binding to evaluate math in place
This commit is contained in:
parent
8e089fef9b
commit
88fa55e297
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user