Browse files

Terminal is now focused when mvim is closed

Interactive_editor now support $EDITOR with complexe shell arguments
  • Loading branch information...
1 parent b10922e commit fb9e59740deae3adcb1ea1e34adb81206d86b417 @nel nel committed Dec 6, 2010
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/interactive_editor.rb
View
11 lib/interactive_editor.rb
@@ -5,6 +5,7 @@
require 'irb'
require 'fileutils'
require 'tempfile'
+require 'shellwords'
class InteractiveEditor
VERSION = '0.0.5'
@@ -24,11 +25,9 @@ def edit(file=nil)
end
mtime = File.stat(@file.path).mtime
- if (args = @editor.split(/\s+/)).size > 1
- Exec.system(args[0], *(args[1..-1] << @file.path))
- else
- Exec.system(@editor, @file.path)
- end
+ args = Shellwords.shellwords(@editor) #parse @editor as arguments could be complexe
+ args << @file.path
+ Exec.system(*args)
execute if mtime < File.stat(@file.path).mtime
end
@@ -69,7 +68,7 @@ module Editors
:emacs => nil,
:nano => nil,
:mate => 'mate -w',
- :mvim => 'mvim -g -f'
+ :mvim => 'mvim -g -f -c "au VimLeave * !open -a Terminal"'
}.each do |k,v|
define_method(k) do |*args|
InteractiveEditor.edit(v || k, *args)

0 comments on commit fb9e597

Please sign in to comment.