1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 10:18:00 +01:00

add :finish command

This commit is contained in:
Doug Kearns
2008-09-02 13:31:33 +00:00
parent cae090dd6b
commit 34085658e6
3 changed files with 35 additions and 7 deletions

1
NEWS
View File

@@ -1,6 +1,7 @@
<pre> <pre>
2008-08-16: 2008-08-16:
* version 2.0 (probably) * version 2.0 (probably)
* add :finish command
* new events BookmarkPost, ShellCmdPost, QuitPre * new events BookmarkPost, ShellCmdPost, QuitPre
* add 'cdpath' option * add 'cdpath' option
* allow :dialog to open the cookies manager * allow :dialog to open the cookies manager

View File

@@ -166,6 +166,15 @@ liberator.IO = function () //{{{
completer: function (filter) { return liberator.completion.file(filter, true); } completer: function (filter) { return liberator.completion.file(filter, true); }
}); });
liberator.commands.add(["fini[sh]"],
"Stop sourcing a script file",
function ()
{
// this command is only used in :source
liberator.echoerr("E168: :finish used outside of a sourced file");
},
{ argCount: "0" });
liberator.commands.add(["pw[d]"], liberator.commands.add(["pw[d]"],
"Print the current directory name", "Print the current directory name",
function () function ()
@@ -689,8 +698,12 @@ lookup:
var heredoc = ""; var heredoc = "";
var heredocEnd = null; // the string which ends the heredoc var heredocEnd = null; // the string which ends the heredoc
str.split("\n").forEach(function (line) var lines = str.split("\n");
for (let i = 0; i < lines.length; i++)
{ {
let line = lines[i];
if (heredocEnd) // we already are in a heredoc if (heredocEnd) // we already are in a heredoc
{ {
if (heredocEnd.test(line)) if (heredocEnd.test(line))
@@ -706,12 +719,18 @@ lookup:
} }
else else
{ {
// check for a heredoc
var [count, cmd, special, args] = liberator.commands.parseCommand(line); var [count, cmd, special, args] = liberator.commands.parseCommand(line);
var command = liberator.commands.get(cmd); var command = liberator.commands.get(cmd);
if (command && command.name == "javascript")
if (command && command.name == "finish")
{ {
break;
}
else if (command && command.name == "javascript")
{
// check for a heredoc
var matches = args.match(/(.*)<<\s*([^\s]+)$/); var matches = args.match(/(.*)<<\s*([^\s]+)$/);
if (matches) if (matches)
{ {
heredocEnd = new RegExp("^" + matches[2] + "$", "m"); heredocEnd = new RegExp("^" + matches[2] + "$", "m");
@@ -729,7 +748,7 @@ lookup:
liberator.execute(line); liberator.execute(line);
} }
} }
}); }
// if no heredoc-end delimiter is found before EOF then // if no heredoc-end delimiter is found before EOF then
// process the heredoc anyway - Vim compatible ;-) // process the heredoc anyway - Vim compatible ;-)

View File

@@ -74,9 +74,17 @@ function hello2() {
are only available within the scope of the script. are only available within the scope of the script.
The _.vimperatorrc_ file in your home directory and any files in The _.vimperatorrc_ file in your home directory and any files in
_\~/.vimperator/plugin/_ are always sourced at startup. _\~/.vimperator/plugin/_ are always sourced at startup. \~ is supported as a
\~ is supported as a shortcut for the _$HOME_ directory. If [!] is shortcut for the _$HOME_ directory. If [!] is specified, errors are not
specified, errors are not printed. printed.
________________________________________________________________________________
|:fini| |:finish|
||:fini[sh]|| +
________________________________________________________________________________
Stop sourcing a script file. This can only be called from within a Vimperator
script file.
________________________________________________________________________________ ________________________________________________________________________________
section:Profiling[profile,profiling] section:Profiling[profile,profiling]