diff options
author | secondlife | 2009-02-24 11:01:02 +0000 |
---|---|---|
committer | secondlife | 2009-02-24 11:01:02 +0000 |
commit | 68f378e337bb3c57883745f2b75cdbe35a8e5e03 (patch) | |
tree | 524f02756216519245cebb2300658af6b8576799 /auto_source.js | |
parent | c5a2eac9a05f4697b4818811a5f7b25bf8fe3241 (diff) | |
download | vimperator-plugins-68f378e337bb3c57883745f2b75cdbe35a8e5e03.tar.bz2 |
-command で、source 後に自動実行してもらいたいコマンドを記述できるように
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@30493 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'auto_source.js')
-rw-r--r-- | auto_source.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/auto_source.js b/auto_source.js index df82079..f8c83ff 100644 --- a/auto_source.js +++ b/auto_source.js @@ -25,6 +25,8 @@ var PLUGIN_INFO = 監視を開始: - :aso taro.js - :autoso[urce] taro.js + - :autoso[urce] -c[ommand] 'colorscheme mycolors' taro.js + - :autoso[urce] -c[ommand] 'js alert("reload!")' taro.js 監視を中止: - :aso! taro.js - :autoso[urce]! taro.js @@ -62,7 +64,7 @@ var PLUGIN_INFO = return cur.path; } - function startWatching (filepath) { + function startWatching (filepath, command) { if (exists(filepath)) throw 'The file has already been watched: ' + filepath; let last = firstTime ? null : getFileModifiedTime(filepath); @@ -73,13 +75,17 @@ var PLUGIN_INFO = liberator.log('sourcing: ' + filepath); last = current; io.source(filepath); + if (command) { + liberator.log('command execute: ' + command); + liberator.execute(command); + } } } catch (e) { liberator.echoerr('Error! ' + filepath); killWatcher(filepath); } }, interval); - liberator.log('filepath: ' + filepath) + liberator.log('filepath: ' + filepath + (command ? ('; command: ' + command) : '')); files.push({handle: handle, path: filepath}); } @@ -94,11 +100,14 @@ var PLUGIN_INFO = ['autoso[urce]', 'aso'], 'Sourcing automatically when the specified file is modified.', function (arg, bang) { - (bang ? killWatcher : startWatching)(expandPath(arg[0])); + (bang ? killWatcher : startWatching)(expandPath(arg[0]), arg['-command']); }, { bang: true, argCount: '1', + options: [ + [['-command', '-c'], commands.OPTION_STRING] + ], completer: function (context, args) { if (args.bang) { context.title = ['Path']; |