diff --git a/NEWS b/NEWS index a2f884e2..cd3ae91f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@
2008-08-16:
* version 2.0 (probably)
+ * add :finish command
* new events BookmarkPost, ShellCmdPost, QuitPre
* add 'cdpath' option
* allow :dialog to open the cookies manager
diff --git a/content/io.js b/content/io.js
index fd571f81..5517bd41 100644
--- a/content/io.js
+++ b/content/io.js
@@ -166,6 +166,15 @@ liberator.IO = function () //{{{
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]"],
"Print the current directory name",
function ()
@@ -689,8 +698,12 @@ lookup:
var 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.test(line))
@@ -706,12 +719,18 @@ lookup:
}
else
{
- // check for a heredoc
var [count, cmd, special, args] = liberator.commands.parseCommand(line);
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]+)$/);
+
if (matches)
{
heredocEnd = new RegExp("^" + matches[2] + "$", "m");
@@ -729,7 +748,7 @@ lookup:
liberator.execute(line);
}
}
- });
+ }
// if no heredoc-end delimiter is found before EOF then
// process the heredoc anyway - Vim compatible ;-)
diff --git a/locale/en-US/repeat.txt b/locale/en-US/repeat.txt
index 572566c3..7c93802d 100644
--- a/locale/en-US/repeat.txt
+++ b/locale/en-US/repeat.txt
@@ -74,9 +74,17 @@ function hello2() {
are only available within the scope of the script.
The _.vimperatorrc_ file in your home directory and any files in
-_\~/.vimperator/plugin/_ are always sourced at startup.
-\~ is supported as a shortcut for the _$HOME_ directory. If [!] is
-specified, errors are not printed.
+_\~/.vimperator/plugin/_ are always sourced at startup. \~ is supported as a
+shortcut for the _$HOME_ directory. If [!] is specified, errors are not
+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]