my-emacs-d/lisp/round-number-to-decimals.el
Gergely Polonkai 2191b1ac64 Move round-number-to-decimals binding to init.el
It is nowwtogether with all the other bindings.
2017-04-04 22:25:56 +02:00

18 lines
515 B
EmacsLisp

(defun get-number-at-point ()
(interactive)
(skip-chars-backward "0123456789.-")
(or (looking-at "[0123456789.-]+")
(error "No number at point"))
(string-to-number (match-string 0)))
(defun round-number-at-point-to-decimals (decimal-count)
(interactive "NDecimal count: ")
(let ((mult (expt 10 decimal-count)))
(replace-match (number-to-string
(/
(fround
(*
mult
(get-number-at-point)))
mult)))))