ob-vbnet.el 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ;;; ob-vbnet.el --- org-babel functions for VB.Net evaluation
  2. ;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
  3. ;; Author: thomas "at" friendlyvillagers.com based on ob-java.el by Eric Schulte
  4. ;; Keywords: literate programming, reproducible research
  5. ;; Homepage: http://orgmode.org
  6. ;; This file is not part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; Currently this only supports the external compilation and execution
  19. ;; of VB.Net code blocks (i.e., no session support).
  20. ;;; Code:
  21. (require 'ob)
  22. (defvar org-babel-tangle-lang-exts)
  23. (add-to-list 'org-babel-tangle-lang-exts '("vbnet" . "vb"))
  24. (defcustom org-babel-vbnet-command "mono"
  25. "Name of the mono command.
  26. May be either a command in the path, like mono
  27. or an absolute path name, like /usr/local/bin/mono
  28. parameters may be used, like mono -verbose"
  29. :group 'org-babel
  30. :version "24.3"
  31. :type 'string)
  32. (defcustom org-babel-vbnet-compiler "vbnc"
  33. "Name of the VB.Net compiler.
  34. May be either a command in the path, like vbnc
  35. or an absolute path name, like /usr/local/bin/vbnc
  36. parameters may be used, like vbnc /warnaserror+"
  37. :group 'org-babel
  38. :version "24.3"
  39. :type 'string)
  40. (defun org-babel-execute:vbnet (body params)
  41. (let* ((full-body (org-babel-expand-body:generic body params))
  42. (cmpflag (or (cdr (assq :cmpflag params)) ""))
  43. (cmdline (or (cdr (assq :cmdline params)) ""))
  44. (src-file (org-babel-temp-file "vbnet-src-" ".vb"))
  45. (exe-file (concat (file-name-sans-extension src-file) ".exe"))
  46. (compile
  47. (progn (with-temp-file src-file (insert full-body))
  48. (org-babel-eval
  49. (concat org-babel-vbnet-compiler " " cmpflag " " src-file)
  50. ""))))
  51. (let ((results (org-babel-eval (concat org-babel-vbnet-command " " cmdline " " exe-file) "")))
  52. (org-babel-reassemble-table
  53. (org-babel-result-cond (cdr (assq :result-params params))
  54. (org-babel-read results)
  55. (let ((tmp-file (org-babel-temp-file "c-")))
  56. (with-temp-file tmp-file (insert results))
  57. (org-babel-import-elisp-from-file tmp-file)))
  58. (org-babel-pick-name
  59. (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
  60. (org-babel-pick-name
  61. (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
  62. (defun org-babel-prep-session:vbnet (session params)
  63. "Return an error because vbnet does not support sessions."
  64. (error "Sessions are not supported for VB.Net"))
  65. (provide 'ob-vbnet)
  66. ;;; ob-vbnet.el ends here