From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jay Belanger Newsgroups: gmane.emacs.help Subject: Re: Using calc's translations programaticaly Date: Mon, 22 Oct 2007 13:39:00 -0500 Message-ID: References: Reply-To: jay.p.belanger@gmail.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1193078444 24406 80.91.229.12 (22 Oct 2007 18:40:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Oct 2007 18:40:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 22 20:40:41 2007 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 1Ik2Cd-00078X-0A for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Oct 2007 20:40:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ik2CV-0001eq-2W for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Oct 2007 14:40:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.aset.psu.edu!news.glorb.com!feed.news.qwest.net!mpls-nntp-02.inet.qwest.net!news.more.net!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:xWgPZ/R6gIivCAzysL3znJZoUFY= Original-Lines: 48 Original-NNTP-Posting-Host: 150.243.64.6 Original-X-Trace: news.more.net 1193078343 150.243.64.6 (Mon, 22 Oct 2007 13:39:03 CDT) Original-NNTP-Posting-Date: Mon, 22 Oct 2007 13:39:03 CDT Original-Xref: shelby.stanford.edu gnu.emacs.help:153193 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:48695 Archived-At: > Calc has this great feature that automatically (and pretty > accurately) translates formulas written in one language to an other > language. For example if I have a LaTeX formula that I want to pass > to maxima (say) I can simply do "C-x * e d W C-x * e" and voila: the > formula is transformed to a form that maxima understands. Well, that's supposed to transform it to Maple, but perhaps that's close enough. > My question is how can I access this feature from elisp? Calc really isn't set up to do that, but perhaps something like (defun calc-change-lang (expr old-lang new-lang) (require 'calc-lang) (let (math-expr-opers math-expr-function-mapping math-expr-special-function-mapping math-expr-variable-mapping calc-language-input-filter calc-language-output-filter calc-vector-brackets calc-complex-format calc-radix-formatter calc-function-open calc-function-close calc-language calc-language-option) (calc-set-language old-lang) (let ((expr (math-read-expr expr))) (calc-set-language new-lang) (math-format-value expr)))) would work (the first `let' is to prevent the current language from being disturbed). The interesting (for this) values of old-lang and new-lang might be: nil (normal Calc language) 'c 'pascal 'fortran 'tex 'latex 'eqn 'math (Mathematica) 'maple Jay