branch: elpa/inf-ruby
commit a85ae010c678efab205edcff4858f65938b7fc43
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
Handle different prompts, not just the IRB default
* The regexp is adapted from Rinari.
* Fixes #6.
---
inf-ruby.el | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index 6bd299d95f..612bb04b6e 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -27,10 +27,24 @@
(defvar inf-ruby-default-implementation "ruby"
"Which Ruby implementation to use if none is specified.")
-(defvar inf-ruby-first-prompt-pattern "^irb(.*)[0-9:]+0> *"
+(defconst inf-ruby-prompt-format
+ (mapconcat
+ #'identity
+ '("\\(^%s> .*\\)" ; Simple
+ "\\(^\\(irb([^)]+)" ; IRB default
+ "\\(\[[0-9]+\] \\)?[Pp]ry ?([^)]+)" ; Pry
+ "\\(jruby-\\|JRUBY-\\)?[1-9]\\.[0-9]\\.[0-9]+\\(-?p?[0-9]+\\)?" ; RVM
+ ;; Statement and nesting counters, common to the last three.
+ "\\) ?[0-9:]* ?%s *\\)")
+ "\\|")
+ "Format string for the prompt regexp pattern.
+Two placeholders: first char in the Simple prompt, and the last
+graphical char in all other prompts.")
+
+(defvar inf-ruby-first-prompt-pattern (format inf-ruby-prompt-format ">" ">")
"First prompt regex pattern of Ruby interpreter.")
-(defvar inf-ruby-prompt-pattern "^\\(irb(.*)[0-9:]+[>*\"'] *\\)+"
+(defvar inf-ruby-prompt-pattern (format inf-ruby-prompt-format "[?>]"
"[\]>*\"'/`]")
"Prompt regex pattern of Ruby interpreter.")
(defvar inf-ruby-mode-hook nil