Adding new prompt patterns - nonsequitur/inf-ruby GitHub Wiki

If you wish to add other interpreter prompt patterns, so they're recognized here's an example (for Chef-Shell). Note that inf-ruby-first-prompt-pattern has to be distinct from inf-ruby-prompt-pattern for history in the chef shell to work properly (the below does achieve).

Code completion is implemented by evaluating strings in the same process, and if the REPL has already been sent an incomplete expression, completion will both fail to work and mess up said expression.

(add-hook 'inf-ruby-mode-hook
          (lambda() (let ((p "\\|\\(^chef \\(([\\.[:digit:]]+)>\\)? *\\)"))
                       (setq inf-ruby-first-prompt-pattern (concat inf-ruby-first-prompt-pattern p))
                       (setq inf-ruby-prompt-pattern (concat inf-ruby-prompt-pattern p)))))

; some quick sample tests
;(string-match inf-ruby-first-prompt-pattern "chef (13.2.20)> ")
;(string-match inf-ruby-prompt-pattern "chef (13.2.20)> ")
;(string-match inf-ruby-prompt-pattern "chef >     ")