Module: InteractiveEditing

Defined in:
lib/utility_belt/interactive_editor.rb

Instance Method Summary collapse

Instance Method Details

#edit_interactively(editor = InteractiveEditor.sensible_editor) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/utility_belt/interactive_editor.rb', line 47

def edit_interactively(editor = InteractiveEditor.sensible_editor)
  unless IRB.conf[:interactive_editors] && IRB.conf[:interactive_editors][editor]
    IRB.conf[:interactive_editors] ||= {}
    IRB.conf[:interactive_editors][editor] = InteractiveEditor.new(editor)
  end
  IRB.conf[:interactive_editors][editor].edit_interactively
end

#emacsObject

TODO: Hardcore Emacs users use emacsclient or gnuclient to open documents in their existing sessions, rather than starting a brand new Emacs process.



75
76
77
# File 'lib/utility_belt/interactive_editor.rb', line 75

def emacs
  handling_jruby_bug {edit_interactively(:emacs)}
end

#handling_jruby_bug(&block) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/utility_belt/interactive_editor.rb', line 55

def handling_jruby_bug(&block)
  if RUBY_PLATFORM =~ /java/
    puts "JRuby IRB has a bug which prevents successful IRB vi/emacs editing."
    puts "The JRuby team is aware of this and working on it. But it might be unfixable."
    puts "(http://jira.codehaus.org/browse/JRUBY-2049)"
  else
    yield
  end
end

#mateObject



69
70
71
# File 'lib/utility_belt/interactive_editor.rb', line 69

def mate
  edit_interactively(:mate)
end

#viObject



65
66
67
# File 'lib/utility_belt/interactive_editor.rb', line 65

def vi
  handling_jruby_bug {edit_interactively(:vim)}
end