forked from mirrors/org-mode
Call eval-after-load with a symbol rather than a string to avoid potential name conflicts with files that do not provide the feature (e.g., if a user configures speedbar in a file named "speedbar.el") Reported-by: John Foerch <jjfoerch@gmail.com> Ref: https://orgmode.org/list/CAEeGWGKfrV7w9qtPRpAhFtiOCH-+8_ydEe11EoMAkUkbTq1fuA@mail.gmail.com
58 lines
1.4 KiB
EmacsLisp
58 lines
1.4 KiB
EmacsLisp
;;; ob-php.el --- Execute PHP within org-mode blocks.
|
|
;; Copyright 2016 stardiviner
|
|
|
|
;; Author: stardiviner <numbchild@gmail.com>
|
|
;; Maintainer: stardiviner <numbchild@gmail.com>
|
|
;; Keywords: org babel php
|
|
;; URL: https://github.com/stardiviner/ob-php
|
|
;; Created: 04th May 2016
|
|
;; Version: 0.0.1
|
|
;; Package-Requires: ((org "8"))
|
|
|
|
;;; Commentary:
|
|
;;
|
|
;; Execute PHP within org-mode blocks.
|
|
|
|
;;; Code:
|
|
(require 'org)
|
|
(require 'ob)
|
|
|
|
(defgroup ob-php nil
|
|
"org-mode blocks for PHP."
|
|
:group 'org)
|
|
|
|
(defcustom org-babel-php-command "php"
|
|
"The command to execute babel body code."
|
|
:group 'ob-php
|
|
:type 'string)
|
|
|
|
(defcustom org-babel-php-command-options nil
|
|
"The php command options to use when execute code."
|
|
:group 'ob-php
|
|
:type 'string)
|
|
|
|
(defcustom ob-php:inf-php-buffer "*php*"
|
|
"Default PHP inferior buffer."
|
|
:group 'ob-php
|
|
:type 'string)
|
|
|
|
;;;###autoload
|
|
(defun org-babel-execute:php (body params)
|
|
"Orgmode Babel PHP evaluate function for `BODY' with `PARAMS'."
|
|
(let* ((cmd (concat org-babel-php-command " " org-babel-php-command-options))
|
|
(body (concat "<?php\n" body "\n?>")))
|
|
(org-babel-eval cmd body)))
|
|
|
|
;;;###autoload
|
|
(eval-after-load 'org
|
|
'(add-to-list 'org-src-lang-modes '("php" . php)))
|
|
|
|
(defvar org-babel-default-header-args:php '())
|
|
|
|
(add-to-list 'org-babel-default-header-args:php
|
|
'(:results . "output"))
|
|
|
|
(provide 'ob-php)
|
|
|
|
;;; ob-php.el ends here
|