Fix org recursive loading issue.
[ob-php.git] / ob-php.el
blobf6644c923fbac2d65128acf89efae36633170389
1 ;;; ob-php.el --- Execute PHP within org-mode source blocks.
2 ;; Copyright 2016 stardiviner
4 ;; Author: stardiviner <numbchild@gmail.com>
5 ;; Maintainer: stardiviner <numbchild@gmail.com>
6 ;; Keywords: org babel php
7 ;; URL: https://repo.or.cz/ob-php.git
8 ;; Created: 04th May 2016
9 ;; Version: 0.0.1
10 ;; Package-Requires: ((org "8"))
12 ;;; Commentary:
14 ;; Execute PHP within org-mode blocks.
16 ;;; Code:
17 (require 'ob)
19 (defgroup ob-php nil
20 "org-mode blocks for PHP."
21 :group 'org)
23 (defcustom org-babel-php-command "php"
24 "The command to execute babel body code."
25 :group 'ob-php
26 :type 'string)
28 (defcustom org-babel-php-command-options nil
29 "The php command options to use when execute code."
30 :group 'ob-php
31 :type 'string)
33 (defcustom ob-php:inf-php-buffer "*php*"
34 "Default PHP inferior buffer."
35 :group 'ob-php
36 :type 'string)
38 ;;;###autoload
39 (defun org-babel-execute:php (body params)
40 "Orgmode Babel PHP evaluate function for `BODY' with `PARAMS'."
41 (let* ((cmd (concat org-babel-php-command " " org-babel-php-command-options))
42 (code (if (string-match-p "<\\?\\(?:php\\|=\\)\\_>" body)
43 body
44 (concat "<?php\n\n" body))))
45 (org-babel-eval cmd code)))
47 ;;;###autoload
48 (eval-after-load 'org
49 '(add-to-list 'org-src-lang-modes '("php" . php)))
51 (defvar org-babel-default-header-args:php '())
53 (add-to-list 'org-babel-default-header-args:php
54 '(:results . "output"))
56 (provide 'ob-php)
58 ;;; ob-php.el ends here