@@ -26,7 +26,7 @@ class Modules
26
26
def commands
27
27
{
28
28
"back" => "Move back from the current context" ,
29
- "edit" => "Edit the current module with the preferred editor" ,
29
+ "edit" => "Edit the current module or a file with the preferred editor" ,
30
30
"advanced" => "Displays advanced options for one or more modules" ,
31
31
"info" => "Displays information about one or more modules" ,
32
32
"options" => "Displays global options or for one or more modules" ,
@@ -68,14 +68,14 @@ def local_editor
68
68
def cmd_edit_help
69
69
print_line "Usage: edit [file/to/edit.rb]"
70
70
print_line
71
- print_line "Edit a local file or the currently active module with #{ local_editor } "
72
- print_line "If a file path is specified it will automatically be reloaded after editing"
71
+ print_line "Edit the currently active module or a local file with #{ local_editor } . "
72
+ print_line "If a file path is specified, it will automatically be reloaded after editing. "
73
73
print_line "Otherwise, you can reload the active module with 'reload' or 'rerun'."
74
74
print_line
75
75
end
76
76
77
77
#
78
- # Edit the currently active module
78
+ # Edit the currently active module or a local file
79
79
#
80
80
def cmd_edit ( *args )
81
81
if args . length > 0
@@ -86,22 +86,32 @@ def cmd_edit(*args)
86
86
87
87
if path
88
88
editor = local_editor
89
+
89
90
if editor . nil?
90
- editor = 'vim '
91
+ editor = 'ed '
91
92
print_warning ( "LocalEditor or $VISUAL/$EDITOR should be set. Falling back on #{ editor } ." )
92
93
end
93
94
94
95
print_status ( "Launching #{ editor } #{ path } " )
95
96
system ( editor , path )
96
-
97
+
98
+ # XXX: This will try to reload *anything* and break on modules
97
99
if args . length > 0
98
- load args [ 0 ]
100
+ print_status ( "Reloading #{ path } " )
101
+ load path
99
102
end
100
103
else
101
104
print_error ( 'Nothing to edit -- try using a module first.' )
102
105
end
103
106
end
104
107
108
+ #
109
+ # Tab completion for the edit command
110
+ #
111
+ def cmd_edit_tabs ( str , words )
112
+ tab_complete_filenames ( str , words )
113
+ end
114
+
105
115
def cmd_advanced_help
106
116
print_line 'Usage: advanced [mod1 mod2 ...]'
107
117
print_line
0 commit comments