diff options
-rw-r--r-- | core/ui.lua | 4 | ||||
-rw-r--r-- | doc/manual.md | 13 | ||||
-rw-r--r-- | src/textadept.c | 1 |
3 files changed, 8 insertions, 10 deletions
diff --git a/core/ui.lua b/core/ui.lua index a5827cef..a19785c9 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -74,13 +74,11 @@ end -- buffer is already open in a view, the message is printed to that view. -- Otherwise the view is split (unless `ui.tabs` is `true`) and the message -- buffer is displayed before being printed to. --- At this time, `ui.print()` cannot be used until Textadept is fully --- initialized. (That is, not until `events.INITIALIZED` is emitted.) -- @param buffer_type String type of message buffer. -- @param ... Message strings. -- @usage ui._print(_L['[Message Buffer]'], message) -- @name _print -function ui._print(buffer_type, ...) pcall(_print, buffer_type, ...) end +function ui._print(buffer_type, ...) _print(buffer_type, ...) end --- -- Prints the given string messages to the message buffer. diff --git a/doc/manual.md b/doc/manual.md index c1c6fec4..d49f2b1e 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -941,10 +941,9 @@ mind: module names that match the name of a lexer in the *lexers/* directory unless you are creating a language module. * Do not call any functions that create buffers and views (e.g. `ui.print()`, - `io.open_file()`, and `buffer.new()`) at file-level scope. This will result in - hard errors as Textadept initializes. Those types of function calls must occur - within functions (e.g. in a key binding, menu item, or - [`events.INITIALIZED`][] event handler). + `io.open_file()`, and `buffer.new()`) at file-level scope. Those types of + function calls must occur within functions (e.g. in a key binding, menu item, + or [`events.INITIALIZED`][] event handler). * Additional documentation on creating language modules can be found in the the [language module API documentation][]. @@ -979,9 +978,9 @@ later section. Note: Do not call any functions that create buffers and views (e.g. `ui.print()`, `io.open_file()`, and `buffer.new()`) at the file-level scope of -*~/.textadept/init.lua*. This will result in hard errors as Textadept -initializes. Those types of function calls must occur within functions (e.g. in -a key binding, menu item, or [`events.INITIALIZED`][] event handler). +*~/.textadept/init.lua*. Those types of function calls must occur within +functions (e.g. in a key binding, menu item, or [`events.INITIALIZED`][] event +handler). [`events.INITIALIZED`]: api.html#events.INITIALIZED diff --git a/src/textadept.c b/src/textadept.c index 0aef64b8..a8a29c7c 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -1100,6 +1100,7 @@ static int lbuffer_delete(lua_State *L) { /** `_G.buffer_new()` Lua function. */ static int lbuffer_new(lua_State *L) { + if (initing) luaL_error(L, "cannot create buffers during initialization"); new_buffer(0); lua_getfield(L, LUA_REGISTRYINDEX, "ta_buffers"); return (lua_rawgeti(L, -1, lua_rawlen(L, -1)), 1); |