help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calc-embedded keep equation


From: Tim Visher
Subject: Re: calc-embedded keep equation
Date: Wed, 5 Feb 2014 08:17:01 -0500

On Wed, Feb 5, 2014 at 4:27 AM, henry atting <snd@online.de> wrote:
> Say I have an expression like
>
>  2 + 2
>
> I let calcutate it with calc-embedded
>
>  4
>
> The expression is replaced by the solution.
>
> Is it possible to keep the whole equation, something like
>
>  2 + 2 = 4
>
> ?

(defun replace-with-solved-equation (start-of-equation end-of-equation)
  (interactive "r")
  (if (not (region-active-p))
      (error "Requires an active region"))

  (let ((equation-string (buffer-substring start-of-equation end-of-equation)))
    (calc-embedded nil)
    (calc-embedded nil)
    (save-excursion
      (goto-char start-of-equation)
      (insert equation-string " = "))))

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail



reply via email to

[Prev in Thread] Current Thread [Next in Thread]