Module: InteractiveEditing

Defined in:
lib/utility_belt/interactive_editor.rb

Instance Method Summary collapse

Instance Method Details

#edit_interactively(editor = InteractiveEditor.sensible_editor) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/utility_belt/interactive_editor.rb', line 42

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.



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

def emacs
  handling_jruby_bug {edit_interactively(:emacs)}
end

#handling_jruby_bug(&block) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/utility_belt/interactive_editor.rb', line 50

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."
    puts "(http://jira.codehaus.org/browse/JRUBY-2049)"
  else
    yield
  end
end

#mateObject



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

def mate
  edit_interactively(:mate)
end

#viObject



60
61
62
# File 'lib/utility_belt/interactive_editor.rb', line 60

def vi
  handling_jruby_bug {edit_interactively(:vim)}
end