diff options
-rw-r--r-- | core/args.lua | 9 | ||||
-rw-r--r-- | doc/08_Preferences.md | 12 | ||||
-rw-r--r-- | init.lua | 6 |
3 files changed, 8 insertions, 19 deletions
diff --git a/core/args.lua b/core/args.lua index f0cdba65..bbf4a074 100644 --- a/core/args.lua +++ b/core/args.lua @@ -96,13 +96,8 @@ for i = 1, #arg do end end if not lfs.attributes(userhome) then lfs.mkdir(userhome) end -if not lfs.attributes(userhome..'/init.lua') then - local f = io.open(userhome..'/init.lua', 'w') - if f then - f:write("_M.textadept = require('textadept')\n") - f:close() - end -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') diff --git a/doc/08_Preferences.md b/doc/08_Preferences.md index dede2bd6..fa41f4c6 100644 --- a/doc/08_Preferences.md +++ b/doc/08_Preferences.md @@ -9,12 +9,9 @@ At this point it is assumed you are at least familiar with the basics of Textadept executes a *~/.textadept/init.lua*, your user-init file, on startup. If this file does not exist, Textadept creates it for you. You can use the file -to indicate what you want Textadept to do when the application starts. At first, -it simply loads a module that contains most of Textadept's functionality. -However, you are not restricted to just loading modules. You can run any Lua -code you desire. It is important to realize that Textadept will not load -anything you do not tell it to. If your *~/.textadept/init.lua* exists and is -empty, no modules are loaded (pretty much rendering Textadept useless). +to indicate what you want Textadept to do when the application starts, such as +loading additional modules. However, you are not restricted to just loading +modules. You can run any Lua code you desire. ## Modules @@ -39,8 +36,6 @@ from module's [LuaDoc][]. For example, to disable character autopairing with typeover and stripping whitespace on save, your *~/.textadept/init.lua* might look like: - _M.textadept = require 'textadept' - _M.textadept.editing.AUTOPAIR = false _M.textadept.editing.TYPEOVER_CHARS = false _M.textadept.editing.STRIP_WHITESPACE_ON_SAVE = false @@ -103,7 +98,6 @@ Suppose you created or downloaded a generic module called `foo` that you wanted to load along with the default modules Your *~/.textadept/init.lua* would contain the following: - _M.textadept = require 'textadept' _M.foo = require 'foo' Language-specific modules are loaded automatically by Textadept when a source @@ -9,8 +9,8 @@ package.path = table.concat({ local so = not WIN32 and '/?.so;' or '/?.dll;' package.cpath = _USERHOME..so.._USERHOME..'/modules'..so..package.cpath -local user_init, exists = _USERHOME..'/init.lua', lfs.attributes -local ok, err = pcall(dofile, user_init) -if ok or not exists(user_init) then require('textadept') else gui.print(err) end +_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 |