emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [babel-R][RFC] Customizing the R prompt for babel sessions approach,


From: Grant Rettke
Subject: [O] [babel-R][RFC] Customizing the R prompt for babel sessions approach, advice, discussion
Date: Wed, 27 Aug 2014 21:11:39 -0500

Good evening,

The `R' programming language lets you set a custom prompt by evaluating
this `R' code:

╭────
│ options(prompt="ℝ> ")
╰────

When you are using `ess' [1] you need to let it know that you are using
a different prompt than the defult by customizing the following value
like this:

╭────
│ (defcustom inferior-S-prompt "[]a-zA-Z0-9.[]*\\(?:[>+.] \\)*ℝ+> "
│   "Regexp used in S and R inferior and transcript buffers for prompt navigation.
│ Customise it to make `comint-previous-prompt' quiqly navigate to
│ interesting portions of the buffer.
│  "
│   :group 'ess-proc
│   :type 'string)
╰────

In order for `babel' to work correctly with the custom prompt currently
I make a change manually to ob-R.el in the function
`org-babel-R-evaluate-session' to modify the regex to look like this:

╭────
│ "^\\([ ]*[ℝ>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
╰────

Instead of making the change by hand I would like to add a new
customizable value to ob-R that contains the regex. The goal is to let
the user customize it themselves to accomodate any prompt. A couple of
weeks ago I posted a [patch] with that intent, and aaronecay provided
valuable feedback… but what I did wrong was both not discussing it with
anyone before I sent that patch and I also was too aggressive with the
change (it was a bad idea for the change).

Question:
• What do you think of such a change?
• Do you have a desired approach?
• Would you like a patch?
  • My change would be really basic, just add a new defcustom to store
    the regex and reference it in the session evalution function

It would change from this

╭────
│ (if (string-match
│      "^\\([ ]*[ℝ>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
│     (substring line (match-end 1))
│   line)
╰────

to this

╭────
│ (if (string-match
│      inferior-R-prompt line)
│     (substring line (match-end 1))
│   line)
╰────

╭────
│ emacs-version
╰────

╭────
│ 24.3.1
╰────

╭────
│ org-version
╰────

╭────
│ 8.2.7c
╰────

╭────
│ ess-version
╰────

╭────
│ 14.06
╰────

Kind regards,


[patch]
https://lists.gnu.org/archive/html/emacs-orgmode/2014-08/msg00753.html



Footnotes
─────────

[1] [http://ess.r-project.org/]

Grant Rettke | ACM, ASA, FSF
address@hidden | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop taking it seriously.” --Thompson

reply via email to

[Prev in Thread] Current Thread [Next in Thread]