aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2010-03-29 19:04:32 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2010-03-29 19:04:32 -0400
commit1177ef981b04a0c368ab4cbad5e0f6bfdd252cb6 (patch)
tree16feac1865912f20d3a5334a9a80c7849f6d4499
parent9583dadb72798bddcf14260d263a2b3b9ac451a3 (diff)
Use textadept.user_dofile() for user init.lua.
-rw-r--r--core/.textadept.lua2
-rw-r--r--core/init.lua2
-rw-r--r--init.lua13
3 files changed, 6 insertions, 11 deletions
diff --git a/core/.textadept.lua b/core/.textadept.lua
index ec6d9622..5fe9776d 100644
--- a/core/.textadept.lua
+++ b/core/.textadept.lua
@@ -131,5 +131,7 @@ function dialog(kind, ...) end
---
-- Calls 'dofile' on the given filename in the user's Textadept directory.
-- This is typically used for loading user files like key commands or snippets.
+-- Errors are printed to the Textadept message buffer.
-- @param filename The name of the file (not path).
+-- @return true if successful; false otherwise.
function user_dofile(filename) end
diff --git a/core/init.lua b/core/init.lua
index 7576e660..505a3b45 100644
--- a/core/init.lua
+++ b/core/init.lua
@@ -105,5 +105,7 @@ function textadept.user_dofile(filename)
if lfs.attributes(_USERHOME..'/'..filename) then
local ret, errmsg = pcall(dofile, _USERHOME..'/'..filename)
if not ret then textadept.print(errmsg) end
+ return ret
end
+ return false
end
diff --git a/init.lua b/init.lua
index c81f2766..05b1361f 100644
--- a/init.lua
+++ b/init.lua
@@ -4,23 +4,14 @@ local textadept = _G.textadept
local paths = {
_HOME..'/modules/?.lua',
- _HOME..'/modules/?/init.lua',
+ _HOME..'/modules/?/init.lua',
_USERHOME..'/modules/?.lua',
_USERHOME..'/modules/?/init.lua',
package.path
}
package.path = table.concat(paths, ';')
-local loaded_user_modules = false
-local user_init = _USERHOME..'/init.lua'
-local lfs = require 'lfs'
-if lfs.attributes(user_init) then
- local ret, errmsg = pcall(dofile, user_init)
- if not ret then error(errmsg) end
- loaded_user_modules = ret
-end
-
-if not loaded_user_modules then
+if not textadept.user_dofile('init.lua') then
-- Core extension modules to load on startup.
require 'ext/keys' -- provides key command support
require 'ext/find' -- provides functionality for find/replace