mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 10:37:59 +01:00
use parseArgs for 'editor' option
This commit is contained in:
1
NEWS
1
NEWS
@@ -8,6 +8,7 @@
|
|||||||
generous donation which made this behavior possible)
|
generous donation which made this behavior possible)
|
||||||
* IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just
|
* IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just
|
||||||
too unpredictable
|
too unpredictable
|
||||||
|
* :set editor now accepts quoting/escaping to use an editor with spaces in the path
|
||||||
* support for :%foo as a count for commands (not yet widely used)
|
* support for :%foo as a count for commands (not yet widely used)
|
||||||
* show informative message when a background tab was loaded, especially useful
|
* show informative message when a background tab was loaded, especially useful
|
||||||
with a hidden tab bar.
|
with a hidden tab bar.
|
||||||
|
|||||||
@@ -1296,7 +1296,7 @@ liberator.Buffer = function () //{{{
|
|||||||
// TODO: save return value in v:shell_error
|
// TODO: save return value in v:shell_error
|
||||||
var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
|
var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
|
||||||
var editor = liberator.options["editor"];
|
var editor = liberator.options["editor"];
|
||||||
var args = editor.split(" "); // FIXME: too simple
|
var args = liberator.commands.parseArgs(editor, [], "*", true).arguments;
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
liberator.echoerr("no editor specified");
|
liberator.echoerr("no editor specified");
|
||||||
|
|||||||
@@ -277,14 +277,16 @@ liberator.Commands = function () //{{{
|
|||||||
// [["-acceleration"], OPTION_FLOAT],
|
// [["-acceleration"], OPTION_FLOAT],
|
||||||
// [["-accessories"], OPTION_LIST, null, ["foo", "bar"]],
|
// [["-accessories"], OPTION_LIST, null, ["foo", "bar"]],
|
||||||
// [["-other"], OPTION_ANY]];
|
// [["-other"], OPTION_ANY]];
|
||||||
// argCount can be:
|
// @param argCount can be:
|
||||||
// "0": no arguments
|
// "0": no arguments
|
||||||
// "1": exactly one argument
|
// "1": exactly one argument
|
||||||
// "+": one or more aguments
|
// "+": one or more aguments
|
||||||
// "*": zero or more arguments
|
// "*": zero or more arguments
|
||||||
// "?": zero or one arguments
|
// "?": zero or one arguments
|
||||||
|
// @param allowUnknownOptions: -foo won't result in an error, if -foo isn't
|
||||||
|
// specified in "options"
|
||||||
// TODO: should it handle comments?
|
// TODO: should it handle comments?
|
||||||
parseArgs: function(str, options, argCount)
|
parseArgs: function(str, options, argCount, allowUnknownOptions)
|
||||||
{
|
{
|
||||||
// returns [count, parsed_argument]
|
// returns [count, parsed_argument]
|
||||||
function getNextArg(str)
|
function getNextArg(str)
|
||||||
@@ -396,7 +398,7 @@ liberator.Commands = function () //{{{
|
|||||||
args.arguments = []; // remaining arguments
|
args.arguments = []; // remaining arguments
|
||||||
|
|
||||||
var invalid = false;
|
var invalid = false;
|
||||||
var onlyArgumentsRemaining = false; // after a -- has been found
|
var onlyArgumentsRemaining = allowUnknownOptions || false; // after a -- has been found
|
||||||
var arg = null;
|
var arg = null;
|
||||||
var count = 0; // the length of the argument
|
var count = 0; // the length of the argument
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|||||||
@@ -748,7 +748,7 @@ liberator.Editor = function () //{{{
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var editor = liberator.options["editor"];
|
var editor = liberator.options["editor"];
|
||||||
var args = editor.split(" ");
|
var args = liberator.commands.parseArgs(editor, [], "*", true).arguments;
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
liberator.echoerr("no editor specified");
|
liberator.echoerr("no editor specified");
|
||||||
|
|||||||
Reference in New Issue
Block a user