From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marc Tfardy Newsgroups: gmane.emacs.help Subject: Re: Quick math calc on any buffer Date: Wed, 25 Feb 2009 00:29:29 +0100 Message-ID: <70je6rFa1ksvU1@mid.individual.net> References: <866ac838-c9b2-4507-acca-08df9ddf5b94@l1g2000yqj.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1235518998 7873 80.91.229.12 (24 Feb 2009 23:43:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Feb 2009 23:43:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 25 00:44:32 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lc6wt-0001ud-Gp for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Feb 2009 00:44:27 +0100 Original-Received: from localhost ([127.0.0.1]:58578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lc6vY-0003r3-P8 for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Feb 2009 18:43:04 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!newshub.sdsu.edu!feeder.erje.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-X-Trace: individual.net bBAozOds1KZ975MgxY3cfQO4UaRikQ0I91EAGjVr4qUI1ncmAm Cancel-Lock: sha1:eoeITXosbBctxXS9DVtLx98wJyE= User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) In-Reply-To: Original-Xref: news.stanford.edu gnu.emacs.help:167043 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:62341 Archived-At: Chetan schrieb: > Scott Frazer writes: > >> On Feb 21, 11:42 am, Rodrigo Lazo wrote: >>> 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. >>> >> (defun my-calc-result (beg end) >> (interactive "r") >> (insert " = " (calc-eval (buffer-substring beg end)))) > This makes me wonder, is there a rewriter of math expressions, > something like a macro that can rewrite the arithmetic expression as > regular lisp function calls? Yes. See my last post before. The call: (math-read-exprs "2 + 3") gives: ((+ 2 3)) This was my attempt in my version of my-calc-result. reagrds Marc