mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:27:59 +01:00
trivial refactoring of :emenu and :chdir actions
This commit is contained in:
committed by
Kris Maglione
parent
39d6542e80
commit
89dc3c2078
@@ -194,17 +194,17 @@ function IO() //{{{
|
|||||||
"Change the current directory",
|
"Change the current directory",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.literalArg;
|
let arg = args.literalArg;
|
||||||
|
|
||||||
if (!args)
|
if (!arg)
|
||||||
{
|
{
|
||||||
args = "~";
|
arg = "~";
|
||||||
}
|
}
|
||||||
else if (args == "-")
|
else if (arg == "-")
|
||||||
{
|
{
|
||||||
if (oldcwd)
|
if (oldcwd)
|
||||||
{
|
{
|
||||||
args = oldcwd.path;
|
arg = oldcwd.path;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -213,14 +213,14 @@ function IO() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args = io.expandPath(args);
|
arg = io.expandPath(arg);
|
||||||
|
|
||||||
// go directly to an absolute path or look for a relative path
|
// go directly to an absolute path or look for a relative path
|
||||||
// match in 'cdpath'
|
// match in 'cdpath'
|
||||||
// TODO: handle ../ and ./ paths
|
// TODO: handle ../ and ./ paths
|
||||||
if (isAbsolutePath(args))
|
if (isAbsolutePath(arg))
|
||||||
{
|
{
|
||||||
if (io.setCurrentDirectory(args))
|
if (io.setCurrentDirectory(arg))
|
||||||
liberator.echomsg(io.getCurrentDirectory().path);
|
liberator.echomsg(io.getCurrentDirectory().path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -230,7 +230,7 @@ function IO() //{{{
|
|||||||
|
|
||||||
for (let [,dir] in Iterator(dirs))
|
for (let [,dir] in Iterator(dirs))
|
||||||
{
|
{
|
||||||
dir = joinPaths(dir, args);
|
dir = joinPaths(dir, arg);
|
||||||
|
|
||||||
if (dir.exists() && dir.isDirectory() && dir.isReadable())
|
if (dir.exists() && dir.isDirectory() && dir.isReadable())
|
||||||
{
|
{
|
||||||
@@ -243,7 +243,7 @@ function IO() //{{{
|
|||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
liberator.echoerr("E344: Can't find directory " + args.quote() + " in cdpath\n"
|
liberator.echoerr("E344: Can't find directory " + arg.quote() + " in cdpath\n"
|
||||||
+ "E472: Command failed");
|
+ "E472: Command failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,18 +289,18 @@ const liberator = (function () //{{{
|
|||||||
"Execute the specified menu item from the command line",
|
"Execute the specified menu item from the command line",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.literalArg;
|
let arg = args.literalArg;
|
||||||
let items = getMenuItems();
|
let items = getMenuItems();
|
||||||
|
|
||||||
if (!items.some(function (i) i.fullMenuPath == args))
|
if (!items.some(function (i) i.fullMenuPath == arg))
|
||||||
{
|
{
|
||||||
liberator.echoerr("E334: Menu not found: " + args);
|
liberator.echoerr("E334: Menu not found: " + arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let [,item] in Iterator(items))
|
for (let [,item] in Iterator(items))
|
||||||
{
|
{
|
||||||
if (item.fullMenuPath == args)
|
if (item.fullMenuPath == arg)
|
||||||
item.doCommand();
|
item.doCommand();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user