.emacs-my
changeset 517 6889ad2dbd35
parent 516 efa00a6ef34e
child 519 bdc19bd3820f
child 523 1c216ab8a926
--- 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.