emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] support change ob-php.el default PHP command and specifying command options
@ 2020-02-20 15:21 stardiviner
  2020-02-20 17:48 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: stardiviner @ 2020-02-20 15:21 UTC (permalink / raw)
  To: Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 621 bytes --]


I first created a very simple ob-php.el because it does not exist in Org Mode.
But it's really just a very simple code. Now a friend of mine is using it, I
wish to improve it. Seems current ob-php.el does not support some cases like PHP
code "include <file>".

Current patch is a more flexible solution. Might provide some freedom for user to adopt.

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-contrib-lisp-ob-php.el-Support-change-evaluate-comma.patch --]
[-- Type: text/x-patch, Size: 1824 bytes --]

From b158232fdc418437aebe2baacabeef289e0537c3 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 20 Feb 2020 23:14:15 +0800
Subject: [PATCH] contrib/lisp/ob-php.el: Support change evaluate command
 specify options.

* contrib/lisp/ob-php.el (org-babel-php-command): Add new customizable
option `org-babel-php-command` to change default command.

* contrib/lisp/ob-php.el (org-babel-php-command-options): Add new
customizable option `org-babel-php-command-options` to specify
command options.

* contrib/lisp/ob-php.el (org-babel-execute:php): Use new commands in
execute function.
---
 contrib/lisp/ob-php.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/contrib/lisp/ob-php.el b/contrib/lisp/ob-php.el
index 1befbd248..43aede26c 100644
--- a/contrib/lisp/ob-php.el
+++ b/contrib/lisp/ob-php.el
@@ -21,6 +21,16 @@ (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
@@ -29,10 +39,9 @@ (defcustom ob-php:inf-php-buffer "*php*"
 ;;;###autoload
 (defun org-babel-execute:php (body params)
   "Orgmode Babel PHP evaluate function for `BODY' with `PARAMS'."
-  (let* ((cmd "php")
+  (let* ((cmd (concat org-babel-php-command " " org-babel-php-command-options))
          (body (concat "<?php\n" body "\n?>")))
-    (org-babel-eval cmd body)
-    ))
+    (org-babel-eval cmd body)))
 
 ;;;###autoload
 (eval-after-load "org"
-- 
2.25.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 515 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] support change ob-php.el default PHP command and specifying command options
  2020-02-20 15:21 [PATCH] support change ob-php.el default PHP command and specifying command options stardiviner
@ 2020-02-20 17:48 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2020-02-20 17:48 UTC (permalink / raw)
  To: stardiviner; +Cc: Org Mode

Hi Stardiviner,

stardiviner <numbchild@gmail.com> writes:

> I first created a very simple ob-php.el because it does not exist in Org Mode.
> But it's really just a very simple code. Now a friend of mine is using it, I
> wish to improve it. Seems current ob-php.el does not support some cases like PHP
> code "include <file>".
>
> Current patch is a more flexible solution. Might provide some
> freedom for user to adopt.

Applied, thanks.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-20 17:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-20 15:21 [PATCH] support change ob-php.el default PHP command and specifying command options stardiviner
2020-02-20 17:48 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).