ob-php.el 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ;;; ob-php.el --- Execute PHP within org-mode blocks.
  2. ;; Copyright 2016 stardiviner
  3. ;; Author: stardiviner <numbchild@gmail.com>
  4. ;; Maintainer: stardiviner <numbchild@gmail.com>
  5. ;; Keywords: org babel php
  6. ;; URL: https://github.com/stardiviner/ob-php
  7. ;; Created: 04th May 2016
  8. ;; Version: 0.0.1
  9. ;; Package-Requires: ((org "8"))
  10. ;;; Commentary:
  11. ;;
  12. ;; Execute PHP within org-mode blocks.
  13. ;;; Code:
  14. (require 'org)
  15. (require 'ob)
  16. (defgroup ob-php nil
  17. "org-mode blocks for PHP."
  18. :group 'org)
  19. (defcustom org-babel-php-command "php"
  20. "The command to execute babel body code."
  21. :group 'ob-php
  22. :type 'string)
  23. (defcustom org-babel-php-command-options nil
  24. "The php command options to use when execute code."
  25. :group 'ob-php
  26. :type 'string)
  27. (defcustom ob-php:inf-php-buffer "*php*"
  28. "Default PHP inferior buffer."
  29. :group 'ob-php
  30. :type 'string)
  31. ;;;###autoload
  32. (defun org-babel-execute:php (body params)
  33. "Orgmode Babel PHP evaluate function for `BODY' with `PARAMS'."
  34. (let* ((cmd (concat org-babel-php-command " " org-babel-php-command-options))
  35. (body (concat "<?php\n" body "\n?>")))
  36. (org-babel-eval cmd body)))
  37. ;;;###autoload
  38. (eval-after-load 'org
  39. '(add-to-list 'org-src-lang-modes '("php" . php)))
  40. (defvar org-babel-default-header-args:php '())
  41. (add-to-list 'org-babel-default-header-args:php
  42. '(:results . "output"))
  43. (provide 'ob-php)
  44. ;;; ob-php.el ends here