From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xavier Maillard Newsgroups: gmane.emacs.help Subject: Re: Quick math calc on any buffer Date: Tue, 24 Feb 2009 16:25:07 +0100 Organization: GNU's Not UNIX! Message-ID: <200902241525.n1OFP7mP015275@zogzog.maillard.mobi> Reply-To: Xavier Maillard NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1235514406 24935 80.91.229.12 (24 Feb 2009 22:26:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Feb 2009 22:26:46 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Marc Tfardy Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 24 23:28:01 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 1Lc5ka-0005xK-J3 for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Feb 2009 23:27:40 +0100 Original-Received: from localhost ([127.0.0.1]:36911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lc5jF-0001oZ-Sw for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Feb 2009 17:26:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lc5iw-0001o9-Bd for help-gnu-emacs@gnu.org; Tue, 24 Feb 2009 17:25:58 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lc5iv-0001nq-OJ for help-gnu-emacs@gnu.org; Tue, 24 Feb 2009 17:25:57 -0500 Original-Received: from [199.232.76.173] (port=35640 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lc5iv-0001nn-HX for help-gnu-emacs@gnu.org; Tue, 24 Feb 2009 17:25:57 -0500 Original-Received: from ded1.conovae.com ([88.191.52.166]:48811 helo=mf1.conovae.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lc5iv-0008VR-92 for help-gnu-emacs@gnu.org; Tue, 24 Feb 2009 17:25:57 -0500 Original-Received: by mf1.conovae.net (Postfix, from userid 10) id 910C32613E7; Tue, 24 Feb 2009 23:24:58 +0100 (CET) Original-Received: from zogzog.maillard.mobi (IDENT:1000@localhost [127.0.0.1]) by zogzog.maillard.mobi (8.14.3/8.13.8) with ESMTP id n1OFP8Bc015276; Tue, 24 Feb 2009 16:25:08 +0100 Original-Received: (from xma@localhost) by zogzog.maillard.mobi (8.14.3/8.13.8/Submit) id n1OFP7mP015275; Tue, 24 Feb 2009 16:25:07 +0100 In-reply-to: message from Marc Tfardy on Sun, 22 Feb 2009 18:16:51 +0100 User-Agent: Rmail GNU emacs 23.0 on Slackware 12.2.0 Jabber-ID: xma01@jabber.fr Original-References: X-UUCPssh-Information: Please contact the ISP for more information X-UUCPssh: Found to be clean X-UUCPssh-SpamCheck: not spam, SpamAssassin (not cached, score=-4.399, required 6, autolearn=not spam, ALL_TRUSTED -1.80, BAYES_00 -2.60) X-UUCPssh-From: xma@gnu.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:62336 Archived-At: 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