mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 17:32:25 +01:00
change :command to behave like Vim's and add :comclear and :delcommand
This commit is contained in:
6
NEWS
6
NEWS
@@ -1,6 +1,11 @@
|
|||||||
<pre>
|
<pre>
|
||||||
2008-06-xx:
|
2008-06-xx:
|
||||||
* version 1.2
|
* version 1.2
|
||||||
|
* IMPORTANT: changed :command to behave like Vim's version.
|
||||||
|
Eg. An alert command specified previously as
|
||||||
|
:command AlertMe alert(args)
|
||||||
|
should now be defined as
|
||||||
|
:command AlertMe :js alert(<args>)
|
||||||
* IMPORTANT: changed the default keybinding to temporarily disable all
|
* IMPORTANT: changed the default keybinding to temporarily disable all
|
||||||
Vimperator keybindings from <C-Q> to <C-Z>
|
Vimperator keybindings from <C-Q> to <C-Z>
|
||||||
* IMPORTANT: removed old :buffers! buffer window, as it was ugly and slightly broken
|
* IMPORTANT: removed old :buffers! buffer window, as it was ugly and slightly broken
|
||||||
@@ -10,6 +15,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
|
||||||
|
* add :comclear and :delcommand
|
||||||
* add a special version to :hardcopy to skip the Print dialog
|
* add a special version to :hardcopy to skip the Print dialog
|
||||||
* add :bl[ast], :bf[irst], :br[ewind] to go to first/last tab
|
* add :bl[ast], :bf[irst], :br[ewind] to go to first/last tab
|
||||||
* add :bn[ext], :bp[revious], :bN[ext] to switch to next/previous tab
|
* add :bn[ext], :bp[revious], :bN[ext] to switch to next/previous tab
|
||||||
|
|||||||
@@ -646,7 +646,11 @@ liberator.Commands = function () //{{{
|
|||||||
{
|
{
|
||||||
if (!liberator.commands.addUserCommand([cmd],
|
if (!liberator.commands.addUserCommand([cmd],
|
||||||
"User defined command",
|
"User defined command",
|
||||||
function (args, special, count, modifiers) { eval(rep); },
|
function (args, special, count, modifiers)
|
||||||
|
{
|
||||||
|
var replaced = rep.replace("<args>", args).replace("<lt>", "<");
|
||||||
|
liberator.execute(replaced);
|
||||||
|
},
|
||||||
null, special))
|
null, special))
|
||||||
{
|
{
|
||||||
liberator.echoerr("E174: Command already exists: add ! to replace it");
|
liberator.echoerr("E174: Command already exists: add ! to replace it");
|
||||||
@@ -660,13 +664,15 @@ liberator.Commands = function () //{{{
|
|||||||
var str = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
var str = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>Name</th><th>Args</th><th>Definition</th></tr>";
|
"<table><tr align=\"left\" class=\"hl-Title\"><th>Name</th><th>Args</th><th>Definition</th></tr>";
|
||||||
for (var i = 0; i < cmdlist.length; i++)
|
for (var i = 0; i < cmdlist.length; i++)
|
||||||
str += "<tr><td>" + cmdlist[i].name + "</td><td>" + "*" + "</td><td>" + cmdlist[i].isUserCommand + "</td></tr>";
|
str += "<tr><td>" + cmdlist[i].name + "</td><td>" + "*" + "</td><td>" + "...definition not implemented yet" + "</td></tr>";
|
||||||
str += "</table>";
|
str += "</table>";
|
||||||
liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
liberator.echo("No user-defined commands found");
|
liberator.echo("No user-defined commands found");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
/*options: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); }],
|
/*options: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); }],
|
||||||
@@ -674,6 +680,41 @@ liberator.Commands = function () //{{{
|
|||||||
[["-bar"], OPTION_NOARG]] */
|
[["-bar"], OPTION_NOARG]] */
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commandManager.add(["comc[lear]"],
|
||||||
|
"Delete all user-defined commands",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
if (args)
|
||||||
|
{
|
||||||
|
liberator.echoerr("E488: Trailing characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var commands = getUserCommands();
|
||||||
|
for (var i = 0; i < commands.length; i++)
|
||||||
|
removeUserCommand(commands[i].name);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: complete with user-defined commands
|
||||||
|
commandManager.add(["delc[ommand]"],
|
||||||
|
"Delete the specified user-defined command",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
if (!args)
|
||||||
|
{
|
||||||
|
liberator.echoerr("E471: Argument required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add getUserCommand, removeUserCommands, or similar, and make them 'public'?
|
||||||
|
var commands = getUserCommands(args);
|
||||||
|
|
||||||
|
if (commands.length == 1 && args == commands[0].name)
|
||||||
|
removeUserCommand(commands[0].name);
|
||||||
|
else
|
||||||
|
liberator.echoerr("E184: No such user-defined command: " + args);
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: remove preview window, or change it at least
|
// TODO: remove preview window, or change it at least
|
||||||
// commandManager.add(["pc[lose]"],
|
// commandManager.add(["pc[lose]"],
|
||||||
// "Close preview window on bottom of screen",
|
// "Close preview window on bottom of screen",
|
||||||
|
|||||||
@@ -200,9 +200,50 @@ ________________________________________________________________________________
|
|||||||
section:User-defined{nbsp}commands[user-commands]
|
section:User-defined{nbsp}commands[user-commands]
|
||||||
|
|
||||||
|:com| |:command|
|
|:com| |:command|
|
||||||
|
||:com[mand]|| +
|
||||||
|
________________________________________________________________________________
|
||||||
|
List all user-defined commands.
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
||:com[mand] {cmd}|| +
|
||||||
|
________________________________________________________________________________
|
||||||
|
List all user-defined commands that start with {cmd}.
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
||:com[mand][!] [{attr}...] {cmd} {rep}|| +
|
||:com[mand][!] [{attr}...] {cmd} {rep}|| +
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
Lists and defines commands. To be written - but it works similar to Vim's :command
|
Define a new user command. The name of the command is {cmd} and its relacement
|
||||||
|
text is {rep}. The command's attributes are {attr}. If a command with this
|
||||||
|
name already exists an error is reported unless [!] is specified, in which case
|
||||||
|
the command is redefined. Unlike Vim, the command may start with a lowercase
|
||||||
|
letter.
|
||||||
|
|
||||||
|
The replacement text {rep} is scanned for escape sequences and these are
|
||||||
|
replaced with values from the user entered command line. The resulting string
|
||||||
|
is then executed as an Ex command.
|
||||||
|
|
||||||
|
The valid escape sequences are:
|
||||||
|
`------`------------------------------------------------------------------------
|
||||||
|
<args> The command arguments exactly as supplied
|
||||||
|
<lt> A literal '<' character to allow for a literal copy of one of the escape sequences. Eg. <lt>args> will expand to a literal <args>
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Note: {attr} not implemented yet.
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|:comc| |:comclear|
|
||||||
|
||:comc[lear]|| +
|
||||||
|
________________________________________________________________________________
|
||||||
|
Delete all user-defined commands.
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|:delc| |:delcommand|
|
||||||
|
||:delc[ommand] {cmd}|| +
|
||||||
|
________________________________________________________________________________
|
||||||
|
Delete the user-defined command {cmd}.
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
// vim: set syntax=asciidoc:
|
// vim: set syntax=asciidoc:
|
||||||
|
|||||||
Reference in New Issue
Block a user