diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index c6e53d32..ae7c57af 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -1036,11 +1036,12 @@ function Commands() //{{{ addDefaultCommand(new Command(["so[urce]"], function(args) { - if (/[^\\]\s/.test(args)) - { - vimperator.echoerr("E172: Only one file name allowed"); - return; - } + // FIXME: implement proper filename quoting + //if (/[^\\]\s/.test(args)) + //{ + // vimperator.echoerr("E172: Only one file name allowed"); + // return; + //} vimperator.source(args); }, diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index 36ebdf56..a4ead5cd 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -32,6 +32,9 @@ const vimperator = (function() //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + const RC_FILE = "~/.vimperatorrc"; + const PLUGIN_DIR = "~/.vimperator/plugin"; + var modes = { // main modes NONE: 0, @@ -101,6 +104,47 @@ const vimperator = (function() //{{{ vimperator.echo("-- " + str_mode + str_extended + " --"); } + function expandPath(path) + { + const WINDOWS = navigator.platform == "Win32"; + + // TODO: proper pathname separator translation like Vim + if (WINDOWS) + path = path.replace('/', '\\', 'g'); + + // expand "~" to HOME (USERPROFILE or HOMEDRIVE\HOMEPATH on Windows if HOME is not set) + if (/^~/.test(path)) + { + var home = environment_service.get("HOME"); + + if (WINDOWS && !home) + { + home = environment_service.get("USERPROFILE"); + if (!home) + home = environment_service.get("HOMEDRIVE") + environment_service.get("HOMEPATH"); + } + + path = path.replace("~", home); + } + + // expand any $ENV vars + var env_vars = path.match(/\$\w+\b/g); // this is naive but so is Vim and we like to be compatible + + if (env_vars) + { + var expansion; + + for (var i = 0; i < env_vars.length; i++) + { + expansion = environment_service.get(env_vars[i].replace("$", "")); + if (expansion) + path = path.replace(env_vars[i], expansion); + } + } + + return path; + } + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -125,7 +169,7 @@ const vimperator = (function() //{{{ count: -1 // parsed count from the input buffer }, - /** + /** * @param type can be: * "submit": when the user pressed enter in the command line * "change" @@ -403,33 +447,12 @@ const vimperator = (function() //{{{ .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); }, + // files which end in .js are sourced as pure javascript files, // no need (actually forbidden) to add: js <