unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* calc-embedded keep equation
@ 2014-02-05  9:27 henry atting
  2014-02-05 13:17 ` Tim Visher
       [not found] ` <mailman.13797.1391606271.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: henry atting @ 2014-02-05  9:27 UTC (permalink / raw)
  To: help-gnu-emacs

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

? 

 henry


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: calc-embedded keep equation
  2014-02-05  9:27 calc-embedded keep equation henry atting
@ 2014-02-05 13:17 ` Tim Visher
       [not found] ` <mailman.13797.1391606271.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Tim Visher @ 2014-02-05 13:17 UTC (permalink / raw)
  To: henry atting; +Cc: emacs

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: calc-embedded keep equation
       [not found] ` <mailman.13797.1391606271.10748.help-gnu-emacs@gnu.org>
@ 2014-02-07  7:35   ` henry atting
  0 siblings, 0 replies; 3+ messages in thread
From: henry atting @ 2014-02-07  7:35 UTC (permalink / raw)
  To: help-gnu-emacs


> (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 " = "))))

This is great! Tim, thanks.

henry


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-07  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05  9:27 calc-embedded keep equation henry atting
2014-02-05 13:17 ` Tim Visher
     [not found] ` <mailman.13797.1391606271.10748.help-gnu-emacs@gnu.org>
2014-02-07  7:35   ` henry atting

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).