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: Sun, 22 Feb 2009 18:16:51 +0100 Message-ID: <70dfk5Fok0uU1@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 1235324519 19701 80.91.229.12 (22 Feb 2009 17:41:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Feb 2009 17:41:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 22 18:43:16 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 1LbIMC-0004t3-3S for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Feb 2009 18:43:12 +0100 Original-Received: from localhost ([127.0.0.1]:45856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LbIKr-0008N6-Oo for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Feb 2009 12:41:49 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!newsserver.news.garr.it!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Original-X-Trace: individual.net y6cS8btllzBRv0rINuNCeQzVchAezKaPDfamgTxiYSc09Ctp3w Cancel-Lock: sha1:vGw6iOWC5n7cE4OHZaaYDEBt2XU= User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) In-Reply-To: <866ac838-c9b2-4507-acca-08df9ddf5b94@l1g2000yqj.googlegroups.com> Original-Xref: news.stanford.edu gnu.emacs.help:166958 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:62266 Archived-At: Scott Frazer schrieb: > 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)))) 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)))))) regards marc