197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/textbringer/utils.rb', line 197
def read_file_name(prompt, default: nil)
f = ->(s) {
s = File.expand_path(s) if s.start_with?("~")
Dir.glob(s + "*").map { |file|
if File.directory?(file) && !file.end_with?(?/)
file + "/"
else
file
end
}
}
initial_value = default&.sub(%r"\A#{Regexp.quote(Dir.pwd)}/", "")
ignore_case = CONFIG[:read_file_name_completion_ignore_case]
file = read_from_minibuffer(prompt, completion_proc: f,
initial_value: initial_value,
completion_ignore_case: ignore_case)
File.expand_path(file)
end
|