aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/file_io.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2014-05-23 22:20:13 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2014-05-23 22:20:13 -0400
commitf7296a1f9acf04c91420a9bd011f3726f394eaf7 (patch)
tree86dd0fd6d93a056e438e1bb8771466be4061f048 /core/file_io.lua
parent085af1b75d4e9f12e3f095416ed5c0190ff36a2e (diff)
Renamed `io.set_buffer_encoding()` to `buffer:set_encoding()`.
Diffstat (limited to 'core/file_io.lua')
-rw-r--r--core/file_io.lua13
1 files changed, 5 insertions, 8 deletions
diff --git a/core/file_io.lua b/core/file_io.lua
index 6b860e3b..6c66632e 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -191,13 +191,8 @@ function io.reload_file()
buffer.mod_time = lfs.attributes(buffer.filename, 'modification')
end
----
--- Converts the current buffer's contents to encoding *encoding*.
--- @param encoding The string encoding to set. Valid encodings are ones that GNU
--- iconv accepts.
--- @usage io.set_buffer_encoding('ASCII')
--- @name set_buffer_encoding
-function io.set_buffer_encoding(encoding)
+-- LuaDoc is in core/.buffer.luadoc.
+local function set_encoding(buffer, encoding)
assert(buffer.encoding, _L['Cannot change binary file encoding'])
local pos, first_visible_line = buffer.current_pos, buffer.first_visible_line
local text = buffer:get_text()
@@ -211,7 +206,9 @@ function io.set_buffer_encoding(encoding)
buffer.encoding, buffer.encoding_bom = encoding, io.boms[encoding]
end
-- Sets the default buffer encoding.
-events_connect(events.BUFFER_NEW, function() buffer.encoding = 'UTF-8' end)
+events_connect(events.BUFFER_NEW, function()
+ buffer.set_encoding, buffer.encoding = set_encoding, 'UTF-8'
+end)
---
-- Saves the current buffer to its file.