From f7296a1f9acf04c91420a9bd011f3726f394eaf7 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 23 May 2014 22:20:13 -0400 Subject: Renamed `io.set_buffer_encoding()` to `buffer:set_encoding()`. --- core/.buffer.luadoc | 8 ++++++++ core/file_io.lua | 13 +++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/.buffer.luadoc b/core/.buffer.luadoc index dd13b8e5..9170dc37 100644 --- a/core/.buffer.luadoc +++ b/core/.buffer.luadoc @@ -2697,6 +2697,14 @@ function new() end -- @param end_pos The end position of the range of text to get in *buffer*. function text_range(buffer, start_pos, end_pos) end +--- +-- Converts the current buffer's contents to encoding *encoding*. +-- @param buffer A buffer. +-- @param encoding The string encoding to set. Valid encodings are ones that GNU +-- iconv accepts. +-- @usage io.set_buffer_encoding('ASCII') +function set_encoding(buffer, encoding) end + --- -- Returns the buffer's lexer name. -- If *current* is `true`, returns the name of the lexer under the caret in 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. -- cgit v1.2.3