all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Quick math calc on any buffer
@ 2009-02-21 16:42 Rodrigo Lazo
  0 siblings, 0 replies; 12+ messages in thread
From: Rodrigo Lazo @ 2009-02-21 16:42 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

Is there a way to compute a math expression on any buffer? I mean, if I
have a buffer with the following expression

2 + 3 

I want to mark the region and compute the result

2 + 3 = 5

It doesn't seems too hard to do, I've looked on calculator.el for a
"computing" function I can call but I didn't find it. 

Regards

-- 

Rodrigo Lazo (rlazo)





^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <mailman.1378.1235234577.31690.help-gnu-emacs@gnu.org>]
* Re: Quick math calc on any buffer
@ 2009-02-24 15:25 Xavier Maillard
  0 siblings, 0 replies; 12+ messages in thread
From: Xavier Maillard @ 2009-02-24 15:25 UTC (permalink / raw)
  To: Marc Tfardy; +Cc: help-gnu-emacs

Hi,

   > (defun my-calc-result (beg end)
   >   (interactive "r")
   >   (insert " = " (calc-eval (buffer-substring beg end))))

   Great! Much more elegant than my last attempt:

   (defun my-calc-result2 (beg end)
      (interactive "r")
      (insert " = " (number-to-string (apply 'eval (math-read-exprs 
   (buffer-substring beg end))))))

This works partially and insert the result in the wrong place if
you mark the region in the inverse order -i.e beg is end and end
is beg.

Regards,
	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




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

end of thread, other threads:[~2009-02-25  0:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-21 16:42 Quick math calc on any buffer Rodrigo Lazo
     [not found] <mailman.1378.1235234577.31690.help-gnu-emacs@gnu.org>
2009-02-21 19:08 ` B. T. Raven
2009-02-21 19:50   ` Thierry Volpiatto
2009-02-21 22:53 ` Marc Tfardy
2009-02-21 23:37   ` Richard Riley
2009-02-22 12:45 ` Scott Frazer
2009-02-22 14:30   ` Rodrigo Lazo
2009-02-22 17:16   ` Marc Tfardy
2009-02-24 23:20   ` Chetan
2009-02-24 23:29     ` Marc Tfardy
2009-02-25  0:22       ` Chetan
  -- strict thread matches above, loose matches on Subject: below --
2009-02-24 15:25 Xavier Maillard

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.