# HG changeset patch # User Oleksandr Gavenko # Date 1292334844 -7200 # Node ID 6889ad2dbd357e8d9787f334d2915388060bff46 # Parent efa00a6ef34eb0af82b64ea85b2c77aa5b8895e5 Add 'my-calc-eval-region' func. diff -r efa00a6ef34e -r 6889ad2dbd35 .emacs-my --- a/.emacs-my Thu Dec 09 12:32:50 2010 +0200 +++ b/.emacs-my Tue Dec 14 15:54:04 2010 +0200 @@ -659,6 +659,19 @@ (setq-default calc-group-digits t) (setq-default calc-group-char "'") +(defun my-calc-eval-region (arg beg end) + "Calculate the region and display the result in the echo area. +With prefix ARG non-nil, insert the result at the end of region." + (interactive "P\nr") + (require 'calc) + (let* ((expr (buffer-substring-no-properties beg end)) + (result (calc-eval expr))) + (if (null arg) + (message "%s = %s" expr result) + (goto-char end) + (save-excursion + (insert result))))) + ;;; ---------------------------------------------------------------- ;;; TeX, LaTeX.