org-babel-matlab.el 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ;;; org-babel-matlab.el --- org-babel support for matlab evaluation
  2. ;; Copyright (C) Dan Davison
  3. ;; Author: Dan Davison
  4. ;; Keywords: literate programming, reproducible research
  5. ;; Homepage: http://orgmode.org
  6. ;; Version: 0.01
  7. ;;; License:
  8. ;; This program is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation; either version 3, or (at your option)
  11. ;; any later version.
  12. ;;
  13. ;; This program is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;;
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  20. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. ;; Boston, MA 02110-1301, USA.
  22. ;;; Commentary:
  23. ;; Functions that are common to org-babel support for matlab and
  24. ;; octave are in org-babel-octave.el
  25. ;;; Requirements:
  26. ;; Matlab
  27. ;; matlab.el required for interactive emacs sessions and matlab-mode
  28. ;; major mode for source code editing buffer
  29. ;; http://matlab-emacs.sourceforge.net/
  30. ;;; Code:
  31. (require 'matlab)
  32. (require 'org-babel-octave)
  33. (org-babel-add-interpreter "matlab")
  34. (add-to-list 'org-babel-tangle-langs '("matlab" "m" "#!/usr/bin/env matlab"))
  35. (defvar org-babel-matlab-shell-command "matlab -nosplash"
  36. "Shell command to use to run matlab as an external process.")
  37. (defun org-babel-expand-body:matlab (body params &optional processed-params) body)
  38. (defvar org-babel-matlab-with-emacs-link nil
  39. "If non-nil use matlab-shell-run-region for session
  40. evaluation. This will use EmacsLink if (matlab-with-emacs-link)
  41. evaluates to a non-nil value.")
  42. (defun org-babel-execute:matlab (body params)
  43. "Execute a block of matlab code with org-babel."
  44. (org-babel-execute:octave body params 'matlab))
  45. (defun org-babel-prep-session:matlab (session params)
  46. (org-babel-prep-session:octave session params 'matlab))
  47. (defun org-babel-matlab-initiate-session (&optional session params)
  48. "Create matlab inferior process buffer.
  49. If there is not a current inferior-process-buffer in SESSION
  50. then create. Return the initialized session."
  51. (org-babel-octave-initiate-session session params 'matlab))
  52. (provide 'org-babel-matlab)
  53. ;;; org-babel-matlab.el ends here