[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] ob-R.el: Add customizable R command primary prompt setting
From: |
Grant Rettke |
Subject: |
[O] [PATCH] ob-R.el: Add customizable R command primary prompt setting |
Date: |
Fri, 22 Aug 2014 20:30:19 -0500 |
list/ob-R.el (org-babel-R-command-primary-prompt,
org-babel-R-evaluate-session): Former adds customizable prompt value
the latter utilizes it.
My R prompt looks like this "ℝ> ". Babel needs to know more how to
handle various situations so the
regex used in `org-babel-R-evaluate-session' to identify the prompt
looks like this "^\\([ ]*[ℝ>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)".
It is required to handle various R prompt situations correctly. It
may change over time to handle more situations. The
user doesn't need to know about those details. The user only cares
about the R prompt alone. For example, when
they set the prompt in R it looks like this =options(prompt="ℝ> ")=,
it is very simple. It should be this simple for bable, too.
This change adds a user customizable variable for the prompt from user
perspective `org-babel-R-command-primary-prompt'. That variable is
utilized in `org-babel-R-evaluate-session' where the full regular
expression to match the prompt is constructed. This makes it very
easy to handle a custom prompt since from the R side of things, the
value of `org-babel-R-command-primary-prompt' is the only thing that
the user needs to know to set. Via custom it looks like this
'(org-babel-R-command-primary-prompt "ℝ>").
TINYCHANGE
---
lisp/ob-R.el | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 41b943c..1cb675b 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -87,6 +87,11 @@ this variable.")
:version "24.1"
:type 'string)
+(defcustom org-babel-R-command-primary-prompt ">"
+ "User configurable portion of the primary prompt."
+ :group 'org-babel
+ :type 'string)
+
(defvar ess-local-process-name) ; dynamically scoped
(defun org-babel-edit-prep:R (info)
(let ((session (cdr (assoc :session (nth 2 info)))))
@@ -413,6 +418,7 @@ last statement in BODY, as elisp."
(list body org-babel-R-eoe-indicator)
"\n"))
(inferior-ess-send-input)))))) "\n"))))
+ (concat "^\\([ ]*["
org-babel-R-command-primary-prompt "+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)")
line)
(defun org-babel-R-process-value-result (result column-names-p)
"R-specific processing of return value.
--
1.9.2
0001-ob-R.el-Add-customizable-R-command-primary-prompt-se.patch
Description: Binary data
- [O] [PATCH] ob-R.el: Add customizable R command primary prompt setting,
Grant Rettke <=