lib/textbringer/commands/files.rb in textbringer-0.2.5 vs lib/textbringer/commands/files.rb in textbringer-0.2.6
- old
+ new
@@ -61,11 +61,11 @@
define_command(:revert_buffer_with_encoding, doc: <<~EOD) do
Revert the contents of the current buffer from the file on disk
using the specified encoding.
If the specified encoding is not valid, fall back to ASCII-8BIT.
EOD
- |encoding = read_from_minibuffer("File encoding: ")|
+ |encoding = read_encoding("File encoding: ")|
unless yes_or_no?("Revert buffer from file?")
message("Cancelled")
next
end
Buffer.current.revert(encoding)
@@ -102,12 +102,12 @@
message("Wrote #{Buffer.current.file_name}")
end
define_command(:set_buffer_file_encoding,
doc: "Set the file encoding of the current buffer.") do
- |enc = read_from_minibuffer("File encoding: ",
- default: Buffer.current.file_encoding.name)|
+ |enc = read_encoding("File encoding: ",
+ default: Buffer.current.file_encoding.name)|
Buffer.current.file_encoding = enc
end
define_command(:set_buffer_file_format,
doc: "Set the file format of the current buffer.") do
@@ -119,10 +119,12 @@
define_command(:pwd, doc: "Show the current working directory.") do
message(Dir.pwd)
end
define_command(:chdir, doc: "Change the current working directory.") do
- |dir_name = read_file_name("Change directory: ")|
+ |dir_name = read_file_name("Change directory: ",
+ default: Buffer.current.file_name &&
+ File.dirname(Buffer.current.file_name))|
Dir.chdir(dir_name)
end
end
end