From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: org-babel for matlab? Date: Fri, 27 Nov 2009 12:56:14 -0700 Message-ID: References: <4B0AC979.4090704@yahoo.co.uk> <4B0BAE68.6060109@gmail.com> <4B0ED1C4.80600@yahoo.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NE6vY-0003dl-Gl for emacs-orgmode@gnu.org; Fri, 27 Nov 2009 14:56:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NE6vU-0003ac-RW for emacs-orgmode@gnu.org; Fri, 27 Nov 2009 14:56:24 -0500 Received: from [199.232.76.173] (port=47684 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NE6vU-0003aR-OR for emacs-orgmode@gnu.org; Fri, 27 Nov 2009 14:56:20 -0500 Received: from mail-yw0-f172.google.com ([209.85.211.172]:55573) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NE6vT-0001YT-S8 for emacs-orgmode@gnu.org; Fri, 27 Nov 2009 14:56:20 -0500 Received: by ywh2 with SMTP id 2so1696092ywh.27 for ; Fri, 27 Nov 2009 11:56:19 -0800 (PST) In-Reply-To: <4B0ED1C4.80600@yahoo.co.uk> (Christopher Long's message of "Thu, 26 Nov 2009 12:06:44 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Christopher Long Cc: emacs-orgmode@gnu.org --=-=-= Hi Christopher, I do not know of anyone working on matlab support for org-babel. I am attaching a template file which contains instructions for adding support for a new language. Depending on your level of familiarity with elisp it could take anywhere from a couple of hours to a couple of days. We're still debugging some of the original language specific files :) Best of Luck! -- Eric --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-babel-template.el Content-Transfer-Encoding: quoted-printable ;;; org-babel-template.el --- org-babel functions for template evaluation ;; Copyright (C) your name here ;; Author: your name here ;; Keywords: literate programming, reproducible research ;; Homepage: http://orgmode.org ;; Version: 0.01 ;;; License: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; This file is not intended to ever be loaded by org-babel, rather it ;; is a template for use in adding new language support to Org-babel. ;; Good first steps are to copy this file to a file named by the ;; language you are adding, and then use `query-replace' to replace ;; all strings of "template" in this file with the name of your new ;; language. ;; ;; If you have questions as to any of the portions of the file defined ;; below please look to existing language support for guidance. ;; ;; If you are planning on adding a language to org-babel we would ask ;; that if possible you fill out the FSF copyright assignment form ;; available at http://orgmode.org/request-assign-future.txt as this ;; will simplify the eventual inclusion of your addition into ;; org-babel and possibly at some point into org-mode and Emacs ;; proper. ;;; Requirements: ;; Use this section to list the requirements of this language. Most ;; languages will require that at least the language be installed on ;; the user's system, and the Emacs major mode relevant to the ;; language be installed as well. ;;; Code: (require 'org-babel) ;; possibly require modes required for your language ;; Add this language to the list of supported languages. Org-babel ;; will match the string below against the declared language of the ;; source-code block. (org-babel-add-interpreter "template") ;; specify the name, file extension, and shebang line for this language (add-to-list 'org-babel-tangle-langs '("template" "template-extension" "#!/= usr/bin/env template")) ;; This is the main function which is called to evaluate a code ;; block. It should setup the source code block according to all of ;; the header arguments packaged into params, including... ;; - defining variables ;; - optionally starting up a session (depending on the value of the ;; :session) header argument ;; ;; This function will then evaluate the body of the source code and ;; return the results as emacs-lisp depending on the value of the ;; :results header argument ;; - output means that the output to STDOUT will be captured and ;; returned ;; - value means that the value of the last statement in the ;; source code block will be returned ;; ;; The most common first step in this function is the expansion of the ;; PARAMS argument using `org-babel-process-params'. ;; ;; Please feel free to not implement options which aren't appropriate ;; for your language (e.g. not all languages support interactive ;; "session" evaluation). Also you are free to define any new header ;; arguments which you feel may be useful -- all header arguments ;; specified by the user will be available in the PARAMS variable. (defun org-babel-execute:template (body params) "Execute a block of Template code with org-babel. This function is called by `org-babel-execute-src-block' via multiple-value-bind." (message "executing Template source code block") (let* ((processed-params (org-babel-process-params params)) ;; set the session if the session variable is non-nil (session (org-babel-template-initiate-session (first processed-par= ams))) ;; variables assigned for use in the block (vars (second processed-params)) (result-params (third processed-params)) ;; either OUTPUT or VALUE which should behave as described above (result-type (fourth processed-params)) (full-body (concat ;; prepend code to define all arguments passed to the = code block ;; (may not be appropriate for all languages) (mapconcat (lambda (pair) (format "%s=3D%s" (car pair) (org-babel-template-var-to-template (cdr pa= ir)))) vars "\n") "\n" body "\n"))) ;; actually execute the source-code block either in a session or ;; possibly by dropping it to a temporary file and evaluating the ;; file. ;;=20 ;; for session based evaluation the helpers defined in ;; `org-babel-comint' will probably be helpful. )) ;; This function should be used to assign any variables in params in ;; the context of the session environment. (defun org-babel-prep-session:template (session params) "Prepare SESSION according to the header arguments specified in PARAMS." ) (defun org-babel-template-var-to-template (var) "Convert an elisp var into a string of template source code specifying a var of the same value." ) (defun org-babel-template-table-or-string (results) "If the results look like a table, then convert them into an Emacs-lisp table, otherwise return the results as a string." ) (defun org-babel-template-initiate-session (&optional session) "If there is not a current inferior-process-buffer in SESSION then create. Return the initialized session." (unless (string=3D session "none") )) (provide 'org-babel-template) ;;; org-babel-template.el ends here --=-=-= Christopher Long writes: > Dear All, > > Has anyone started on a babel mode for matlab? Or is anyone else > interested > in making it happen? Or have a suggestion for a good template to > start from (babel-python? babel-R?) And anyone has an estimate of how > time consuming such a project would be? > > I'd like it to work on Windows and there isn't a console mode of Matlab > on windows, but you can evaluate code with EmacsLink and likely direct > all output to temporary files. > (I know EmacsLink was dropped in R2009a, but some of us are avoiding > upgrading > and hoping that Matlab will return EmacsLink in the future.) > > > Thanks, > > Stoph > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--