From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Rettke Subject: [PATCH] ob-R.el: Add customizable R command primary prompt setting Date: Fri, 22 Aug 2014 20:30:19 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a11c361f68b6921050141e5c2 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XL09u-0003G0-0O for emacs-orgmode@gnu.org; Fri, 22 Aug 2014 21:30:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XL09s-0007M6-Ql for emacs-orgmode@gnu.org; Fri, 22 Aug 2014 21:30:21 -0400 Received: from mail-ob0-x229.google.com ([2607:f8b0:4003:c01::229]:51428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XL09s-0007Il-IZ for emacs-orgmode@gnu.org; Fri, 22 Aug 2014 21:30:20 -0400 Received: by mail-ob0-f169.google.com with SMTP id uz6so7216468obc.0 for ; Fri, 22 Aug 2014 18:30:19 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "emacs-orgmode@gnu.org" --001a11c361f68b6921050141e5c2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 "=E2=84=9D> ". 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 "^\\([ ]*[=E2=84=9D>+\\.][ ]?\\)+\\([[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 =3Doptions(prompt=3D"=E2=84=9D>= ")=3D, 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 "=E2=84=9D>"). 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 --001a11c361f68b6921050141e5c2 Content-Type: application/octet-stream; name="0001-ob-R.el-Add-customizable-R-command-primary-prompt-se.patch" Content-Disposition: attachment; filename="0001-ob-R.el-Add-customizable-R-command-primary-prompt-se.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hz69sbx20 RnJvbSBmNzhkYzhjMGU0OGI5YTc3ODM1ZDM2MTFiNGQxNWFiOTJmMTkxMTc3IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBHcmFudCBSZXR0a2UgPGdjckB3aXNkb21hbmR3b25kZXIuY29t PgpEYXRlOiBGcmksIDIyIEF1ZyAyMDE0IDIwOjI3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