aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/args.lua9
-rw-r--r--core/file_io.lua9
-rw-r--r--core/keys.lua7
-rw-r--r--core/ui.lua5
4 files changed, 13 insertions, 17 deletions
diff --git a/core/args.lua b/core/args.lua
index 8b478aa9..907fd465 100644
--- a/core/args.lua
+++ b/core/args.lua
@@ -83,17 +83,16 @@ if WIN32 and not CURSES and #arg[0] > 0 then
end
-- Set `_G._USERHOME`.
-local userhome = os.getenv(not WIN32 and 'HOME' or 'USERPROFILE')..'/.textadept'
+_USERHOME = os.getenv(not WIN32 and 'HOME' or 'USERPROFILE')..'/.textadept'
for i = 1, #arg do
if (arg[i] == '-u' or arg[i] == '--userhome') and arg[i + 1] then
- userhome = arg[i + 1]
+ _USERHOME = arg[i + 1]
break
end
end
-if not lfs.attributes(userhome) then lfs.mkdir(userhome) end
-local f = io.open(userhome..'/init.lua', 'a+') -- ensure existence
+if not lfs.attributes(_USERHOME) then lfs.mkdir(_USERHOME) end
+local f = io.open(_USERHOME..'/init.lua', 'a+') -- ensure existence
if f then f:close() end
-_G._USERHOME = userhome
M.register('-u', '--userhome', 1, function() end, 'Sets alternate _USERHOME')
M.register('-f', '--force', 0, function() end, 'Forces unique instance')
diff --git a/core/file_io.lua b/core/file_io.lua
index d175bd7d..bced6219 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -21,7 +21,7 @@
-- Arguments:
--
-- * _`filename`_: The filename of the file being saved.
--- * _`saved_as`_: Whether or not the file was saved under a different
+-- * _`saved_as`_: Whether or not the file was saved under a different
-- filename.
-- @field _G.events.FILE_CHANGED (string)
-- Emitted when Textadept detects that an open file was modified externally.
@@ -304,9 +304,8 @@ events_connect(events.RESUME, update_modified_file)
-- Prompts the user to reload the current file if it has been externally
-- modified.
events_connect(events.FILE_CHANGED, function(filename)
- local msg = string.format('"%s"\n%s',
- buffer.filename:iconv('UTF-8', _CHARSET),
- _L['has been modified. Reload it?'])
+ local msg = ('"%s"\n%s'):format(buffer.filename:iconv('UTF-8', _CHARSET),
+ _L['has been modified. Reload it?'])
local button = ui.dialogs.msgbox{
title = _L['Reload?'], text = _L['Reload modified file?'],
informative_text = msg, icon = 'gtk-dialog-question',
@@ -423,7 +422,7 @@ function io.snapopen(paths, filter, exclude_FILTER, opts)
if type(paths) == 'string' then
if not filter then
filter = io.snapopen_filters[paths]
- if filter and type(exclude_FILTER) == "nil" then
+ if filter and exclude_FILTER == nil then
exclude_FILTER = filter ~= lfs.FILTER
end
end
diff --git a/core/keys.lua b/core/keys.lua
index 2f09d70f..783e59ce 100644
--- a/core/keys.lua
+++ b/core/keys.lua
@@ -91,8 +91,8 @@ local M = {}
-- ## Key Chains
--
-- Key chains are a powerful concept. They allow you to assign multiple key
--- bindings to one key sequence. By default, the `Esc` (`⎋` on Mac OSX | `Esc`
--- in curses) key cancels a key chain, but you can redefine it via
+-- bindings to one key sequence. By default, the `Esc` (`⎋` on Mac OSX | `Esc`
+-- in curses) key cancels a key chain, but you can redefine it via
-- [`keys.CLEAR`](). An example key chain looks like:
--
-- keys['aa'] = {
@@ -186,8 +186,7 @@ M.run_command = function(command, command_type)
end
end
end
- local _, result = xpcall(f, key_error, table.unpack(args, 2))
- return result
+ return select(2, xpcall(f, key_error, table.unpack(args, 2)))
end
-- Return codes for `key_command()`.
diff --git a/core/ui.lua b/core/ui.lua
index e05c1801..c6244ea2 100644
--- a/core/ui.lua
+++ b/core/ui.lua
@@ -422,9 +422,8 @@ events_connect(events.QUIT, function()
end)
-- Keeps track of and switches back to the previous buffer after buffer close.
-events_connect(events.BUFFER_BEFORE_SWITCH, function()
- view._prev_buffer = buffer
-end)
+events_connect(events.BUFFER_BEFORE_SWITCH,
+ function() view._prev_buffer = buffer end)
events_connect(events.BUFFER_DELETED, function()
local i = _BUFFERS[view._prev_buffer]
if i and _BUFFERS[buffer] ~= i then view:goto_buffer(i) end