aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/gui.lua1
-rw-r--r--core/init.lua10
-rw-r--r--doc/14_Appendix.md7
-rw-r--r--init.lua2
-rw-r--r--modules/textadept/keys.lua3
-rw-r--r--modules/textadept/mime_types.lua3
-rw-r--r--src/textadept.c4
7 files changed, 13 insertions, 17 deletions
diff --git a/core/gui.lua b/core/gui.lua
index 59ad72d5..b8b2071e 100644
--- a/core/gui.lua
+++ b/core/gui.lua
@@ -192,7 +192,6 @@ function gui.set_theme(name, ...)
for j = 1, #props, 2 do buffer.property[props[j]] = props[j + 1] end
end
gui.goto_view(current_view)
--- if not RESETTING then reset() end
theme = name
end
diff --git a/core/init.lua b/core/init.lua
index f4b96961..83c6bed5 100644
--- a/core/init.lua
+++ b/core/init.lua
@@ -35,9 +35,6 @@ if jit then module, package.searchers, bit32 = nil, package.loaders, bit end
-- @field _CHARSET (string)
-- The character set encoding of the filesystem.
-- This is used when [working with files](io.html).
--- @field RESETTING (bool)
--- If [`reset()`](#reset) has been called, this flag is `true` while the Lua
--- state is being re-initialized.
-- @field WIN32 (bool)
-- If Textadept is running on Windows, this flag is `true`.
-- @field OSX (bool)
@@ -108,11 +105,10 @@ local quit
-- files that use them will reload those modules instead.
-- This function is useful for modifying user scripts (such as
-- *~/.textadept/init.lua* and *~/.textadept/modules/textadept/keys.lua*) on
--- the fly without having to restart Textadept. `_G.RESETTING` is set to `true`
--- when re-initing the Lua State. Any scripts that need to differentiate between
--- startup and reset can utilize this variable.
+-- the fly without having to restart Textadept. `arg` is set to `nil` when
+-- reinitializing the Lua State. Any scripts that need to differentiate between
+-- startup and reset can test `arg`.
-- @class function
--- @see RESETTING
-- @name reset
local reset
diff --git a/doc/14_Appendix.md b/doc/14_Appendix.md
index 3a8d85a0..56b6761c 100644
--- a/doc/14_Appendix.md
+++ b/doc/14_Appendix.md
@@ -152,6 +152,7 @@ Textadept 7 introduces API changes and a completely new theme implementation.
Old API |Change |New API
----------------------------------|:------:|-------
**_G** | |
+RESETTING |Removed |N/A<sup>\*</sup>
buffer\_new() |Renamed |\_G.[buffer.new()][]
**_M.textadept** | |
filter\_through |Removed |N/A
@@ -168,7 +169,7 @@ contextmenu |Removed |N/A
**_M.textadept.run** | |
MARK\_ERROR\_BACK |Renamed |[ERROR\_COLOR][]
**_M.textadept.snapopen** |Removed |N/A
-open |Changed |\_G.[io.snapopen()][]<sup>\*</sup>
+open |Changed |\_G.[io.snapopen()][]<sup>†</sup>
**events** | |
handlers |Removed |N/A
**gui** | |
@@ -177,7 +178,9 @@ select\_theme |Removed |N/A
**io** | |
try\_encodings |Renamed |[encodings][]
-<sup>\*</sup>Changed arguments too.
+<sup>\*</sup>`arg` is `nil` when resetting.
+
+<sup>†</sup>Changed arguments too.
[buffer.new()]: api/buffer.html#new
[filter\_through()]: api/_M.textadept.editing.html#filter_through
diff --git a/init.lua b/init.lua
index 2c2344cb..be783218 100644
--- a/init.lua
+++ b/init.lua
@@ -13,4 +13,4 @@ _M.textadept = require('textadept')
local ok, err = pcall(dofile, _USERHOME..'/init.lua')
if not ok and lfs.attributes(_USERHOME..'/init.lua') then gui.print(err) end
-if not RESETTING then args.process(arg) end
+if arg then args.process(arg) end
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index 810d6ee0..d0b161d1 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -290,8 +290,7 @@ local function constantize_menu_buffer_functions()
for _, f in ipairs(menu_buffer_functions) do buffer[f] = buffer[f] end
end
events.connect(events.BUFFER_NEW, constantize_menu_buffer_functions)
--- Scintilla's first buffer does not have this.
-if not RESETTING then constantize_menu_buffer_functions() end
+constantize_menu_buffer_functions() -- for the first buffer
local _M, keys, buffer, view = _M, keys, buffer, view
local m_editing, utils = _M.textadept.editing, M.utils
diff --git a/modules/textadept/mime_types.lua b/modules/textadept/mime_types.lua
index be21824e..19b5fcbc 100644
--- a/modules/textadept/mime_types.lua
+++ b/modules/textadept/mime_types.lua
@@ -110,8 +110,7 @@ local function set_lexer_functions()
buffer.get_style_name = get_style_name
end
events.connect(events.BUFFER_NEW, set_lexer_functions, 1)
--- Scintilla's first buffer does not have these.
-if not RESETTING then set_lexer_functions() end
+set_lexer_functions() -- for the first buffer
-- Auto-detect lexer on file open or save as.
events.connect(events.FILE_OPENED, function() buffer:set_lexer() end)
diff --git a/src/textadept.c b/src/textadept.c
index 270adc89..644af3f3 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -1378,11 +1378,11 @@ static int lL_dofile(lua_State *L, const char *filename) {
static int lreset(lua_State *L) {
lL_event(L, "reset_before", -1);
lL_init(L, 0, NULL, TRUE);
- lua_pushboolean(L, TRUE), lua_setglobal(L, "RESETTING");
l_setglobalview(L, focused_view);
l_setglobaldoc(L, SS(focused_view, SCI_GETDOCPOINTER, 0, 0));
+ lua_pushnil(L), lua_setglobal(L, "arg");
lL_dofile(L, "init.lua");
- lua_pushnil(L), lua_setglobal(L, "RESETTING");
+ lua_getfield(L, LUA_REGISTRYINDEX, "ta_arg"), lua_setglobal(L, "arg");
lL_event(L, "reset_after", -1);
return 0;
}