diff --git a/content/bookmarks.js b/content/bookmarks.js index 94918b10..38f70c2d 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -322,7 +322,7 @@ function Bookmarks() //{{{ }, { bang: true, - completer: function (filter) completion.bookmark(filter), + completer: function (context) completion.bookmark(context.filter), options: [[["-tags", "-T"], commands.OPTION_LIST]] }); @@ -335,7 +335,7 @@ function Bookmarks() //{{{ liberator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", commandline.FORCE_SINGLELINE); }, - { completer: function (filter) completion.bookmark(filter) }); + { completer: function (context) completion.bookmark(context.filter) }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// @@ -623,8 +623,9 @@ function History() //{{{ }, { bang: true, - completer: function (filter) + completer: function (context) { + let filter = context.filter; var sh = getWebNavigation().sessionHistory; var completions = []; for (let i = sh.index - 1; i >= 0; i--) @@ -673,8 +674,9 @@ function History() //{{{ }, { bang: true, - completer: function (filter) + completer: function (context) { + let filter = context.filter; var sh = getWebNavigation().sessionHistory; var completions = []; for (let i = sh.index + 1; i < sh.count; i++) diff --git a/content/buffer.js b/content/buffer.js index 57c0c41b..edf158b3 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -512,7 +512,7 @@ function Buffer() //{{{ stylesheetSwitchAll(window.content, args); }, - { completer: function (filter) completion.alternateStylesheet(filter) }); + { completer: function (context) completion.alternateStylesheet(context.filter) }); commands.add(["re[load]"], "Reload current page", @@ -564,7 +564,7 @@ function Buffer() //{{{ { argCount: "?", bang: true, - completer: function (filter, bang, args, context) completion.file(context) + completer: function (context) completion.file(context) }); commands.add(["st[op]"], @@ -578,7 +578,7 @@ function Buffer() //{{{ { argCount: "?", bang: true, - completer: function (filter, bang, args, context) completion.url(context, "bhf") + completer: function (context) completion.url(context, "bhf") }); commands.add(["zo[om]"], diff --git a/content/commands.js b/content/commands.js index 5db8f0d2..f6ea3fd3 100644 --- a/content/commands.js +++ b/content/commands.js @@ -825,7 +825,7 @@ function Commands() //{{{ { argCount: "2", bang: true, - completer: function (filter) completion.userCommand(filter), + completer: function (context) completion.userCommand(context.filter), options: [ [["-nargs"], commandManager.OPTION_STRING, function (arg) /^[01*?+]$/.test(arg), ["0", "1", "*", "?", "+"]], @@ -873,7 +873,7 @@ function Commands() //{{{ }, { argCount: "1", - completer: function (filter) completion.userCommand(filter) + completer: function (context) completion.userCommand(context.filter) }); //}}} diff --git a/content/completion.js b/content/completion.js index 6933ec3d..5af617e7 100644 --- a/content/completion.js +++ b/content/completion.js @@ -1080,7 +1080,7 @@ function Completion() //{{{ if (args) { // XXX, XXX, XXX - compObject = command.completer.call(command, args.string, special, args, context); + compObject = command.completer.call(command, context, args, special, count); if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects compObject = { start: compObject[0], items: compObject[1] }; if (args.completions) diff --git a/content/events.js b/content/events.js index a384d60e..a15819f1 100644 --- a/content/events.js +++ b/content/events.js @@ -114,7 +114,7 @@ function AutoCommands() //{{{ { argCount: "3", bang: true, - completer: function (filter) completion.autocmdEvent(filter), + completer: function (context) completion.autocmdEvent(context.filter), literal: true }); @@ -127,7 +127,7 @@ function AutoCommands() //{{{ }, { argCount: "+", - completer: function (filter) completion.autocmdEvent(filter) + completer: function (context) completion.autocmdEvent(context.filter) } ); @@ -164,7 +164,7 @@ function AutoCommands() //{{{ { // TODO: Vim actually just displays "No matching autocommands" when no arg is specified argCount: "+", - completer: function (filter) completion.autocmdEvent(filter) + completer: function (context) completion.autocmdEvent(context.filter) } ); @@ -719,7 +719,7 @@ function Events() //{{{ }, { bang: true, - completer: function (filter) completion.macro(filter) + completer: function (context) completion.macro(context.filter) }); commands.add(["macros"], @@ -730,14 +730,14 @@ function Events() //{{{ var str = template.tabular(["Macro", "Keys"], [], events.getMacros(args.string)); liberator.echo(str, commandline.FORCE_MULTILINE); }, - { completer: function (filter) completion.macro(filter) }); + { completer: function (context) completion.macro(context.filter) }); commands.add(["pl[ay]"], "Replay a recorded macro", function (args) { events.playMacro(args.arguments[0]); }, { argCount: "1", - completer: function (filter) completion.macro(filter) + completer: function (context) completion.macro(context.filter) }); /////////////////////////////////////////////////////////////////////////////}}} diff --git a/content/io.js b/content/io.js index cdb30a99..c85e957a 100644 --- a/content/io.js +++ b/content/io.js @@ -208,7 +208,7 @@ function IO() //{{{ }, { argCount: "?", - completer: function (filter, bang, args, context) completion.file(context, true), + completer: function (context) completion.file(context, true), literal: true }); @@ -268,7 +268,7 @@ function IO() //{{{ { argCount: "?", bang: true, - completer: function (filter, bang, args, context) completion.file(context, true) + completer: function (context) completion.file(context, true) }); commands.add(["runt[ime]"], @@ -301,7 +301,7 @@ function IO() //{{{ { argCount: "1", bang: true, - completer: function (filter, bang, args, context) completion.file(context, true) + completer: function (context) completion.file(context, true) }); commands.add(["!", "run"], @@ -339,7 +339,7 @@ function IO() //{{{ }, { bang: true, - completer: function (filter) completion.shellCommand(filter) + completer: function (context) completion.shellCommand(filter) }); /////////////////////////////////////////////////////////////////////////////}}} diff --git a/content/liberator.js b/content/liberator.js index 533e7894..fcb3985a 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -202,7 +202,7 @@ const liberator = (function () //{{{ { argCount: "1", bang: true, - completer: function (filter) completion.dialog(filter) + completer: function (context) completion.dialog(context.filter) }); // TODO: move this @@ -257,10 +257,10 @@ const liberator = (function () //{{{ { argCount: "+", // NOTE: single arg may contain unescaped whitespace // TODO: add this as a standard menu completion function - completer: function (filter) + completer: function (context) { let completions = getMenuItems().map(function (item) [item.fullMenuPath, item.label]); - return [0, completion.filter(completions, filter)]; + return [0, completion.filter(completions, context.filter)]; } }); @@ -307,7 +307,7 @@ const liberator = (function () //{{{ }, { bang: true, - completer: function (filter) completion.help(filter) + completer: function (context) completion.help(context.filter) }); commands.add(["javas[cript]", "js"], @@ -334,7 +334,7 @@ const liberator = (function () //{{{ }, { bang: true, - completer: function (filter, bang, args, context) completion.javascript(context), + completer: function (context) completion.javascript(context), hereDoc: true }); @@ -461,12 +461,12 @@ const liberator = (function () //{{{ { argCount: "+", bang: true, - completer: function (filter) + completer: function (context) { - if (/^:/.test(filter)) - return completion.ex(filter); + if (/^:/.test(context.filter)) + return completion.ex(context); else - return completion.javascript(filter); + return completion.javascript(context); }, count: true }); diff --git a/content/mail.js b/content/mail.js index b7f5234b..07632bf9 100644 --- a/content/mail.js +++ b/content/mail.js @@ -684,7 +684,7 @@ function Mail() //{{{ SelectFolder(folder.URI); }, { - completer: function (filter) getFolderCompletions(filter), + completer: function (context) getFolderCompletions(context.filter), count: true }); @@ -726,12 +726,12 @@ function Mail() //{{{ commands.add(["copy[to]"], "Copy selected messages", function (args) { moveOrCopy(true, args.string); }, - { completer: function (filter) getFolderCompletions(filter) }); + { completer: function (context) getFolderCompletions(context.filter) }); commands.add(["move[to]"], "Move selected messages", function (args) { moveOrCopy(false, args.string); }, - { completer: function (filter) getFolderCompletions(filter) }); + { completer: function (context) getFolderCompletions(context.filter) }); commands.add(["empty[trash]"], "Empty trash of the current account", diff --git a/content/mappings.js b/content/mappings.js index 47b355e1..87e08c10 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -186,7 +186,7 @@ function Mappings() //{{{ const opts = { argCount: "2", - completer: function (filter) completion.userMapping(filter, modes), + completer: function (context) completion.userMapping(context.filter, modes), options: [ [["", ""], commands.OPTION_NOARG] ], @@ -245,7 +245,7 @@ function Mappings() //{{{ if (!found) liberator.echoerr("E31: No such mapping"); }, - { completer: function (filter) completion.userMapping(filter, modes) }); + { completer: function (context) completion.userMapping(context.filter, modes) }); } /////////////////////////////////////////////////////////////////////////////}}} diff --git a/content/options.js b/content/options.js index 97c9ac86..a44cc563 100644 --- a/content/options.js +++ b/content/options.js @@ -394,9 +394,9 @@ function Options() //{{{ { bang: true, count: true, - completer: function (filter, special, count) + completer: function (context, args, special, count) { - return commands.get("set").completer(filter, special, count, { scope: options.OPTION_SCOPE_LOCAL }); + return commands.get("set").completer(context.filter, special, count, { scope: options.OPTION_SCOPE_LOCAL }); } } ); @@ -410,9 +410,9 @@ function Options() //{{{ { bang: true, count: true, - completer: function (filter, special, count) + completer: function (context, args, special, count) { - return commands.get("set").completer(filter, special, count, { scope: options.OPTION_SCOPE_GLOBAL }); + return commands.get("set").completer(context.filter, special, count, { scope: options.OPTION_SCOPE_GLOBAL }); } } ); @@ -686,7 +686,7 @@ function Options() //{{{ }, { bang: true, - completer: function (filter, special, count, modifiers) + completer: function (context, args, special, count, modifiers) { var optionCompletions = []; diff --git a/content/style.js b/content/style.js index d8af138a..fb08a574 100644 --- a/content/style.js +++ b/content/style.js @@ -389,7 +389,7 @@ liberator.registerObserver("load_commands", function () }, { argCount: 1, - completer: function (filter) completion.colorScheme(filter) + completer: function (context) completion.colorScheme(context.filter) }); commands.add(["sty[le]"], @@ -430,7 +430,7 @@ liberator.registerObserver("load_commands", function () { argCount: "2", bang: true, - completer: function (filter, bang, args) { + completer: function (context, args, bang) { let compl = []; if (args.completeArg == 0) { @@ -467,12 +467,13 @@ liberator.registerObserver("load_commands", function () }, { argCount: "2", - completer: function (filter) [0, completion.filter( + // FIXME: Ugly. + completer: function (context) [0, completion.filter( [[i, <>{s.sites.join(",")}: {s.css.replace("\n", "\\n")}] for ([i, s] in styles.userSheets) ] .concat([[s, ""] for each (s in styles.sites)]) - , filter)], + , context.filter)], literal: true, options: [[["-index", "-i"], commands.OPTION_INT, null, function () [[k, v.name || v.sites.join(",") + " " + v.css] for ([k, v] in Iterator(styles.userNames))]], [["-name", "-n"], commands.OPTION_STRING, null, function () [[k, v.css] for ([k, v] in Iterator(styles.userNames))]]] @@ -513,9 +514,8 @@ liberator.registerObserver("load_commands", function () argCount: "2", bang: true, // TODO: add this as a standard highlight completion function? - // I agree. It could (should) be much more sophisticated. --Kris - completer: function (filter) [0, - completion.filter([[v.class, ""] for (v in highlight)], filter) + completer: function (context) [0, + completion.filter([[v.class, ""] for (v in highlight)], context.filter) ], hereDoc: true, literal: true, diff --git a/content/tabs.js b/content/tabs.js index 62a4e3e1..01759507 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -354,7 +354,7 @@ function Tabs() //{{{ { bang: true, count: true, - completer: function (filter) completion.buffer(filter) + completer: function (context) completion.buffer(context.filter) }); // TODO: this should open in a new tab positioned directly after the current one, not at the end @@ -368,7 +368,7 @@ function Tabs() //{{{ }, { argCount: "+", - completer: function (filter) completion.ex(filter) + completer: function (context) completion.ex(context.filter) }); commands.add(["tabl[ast]", "bl[ast]"], @@ -478,7 +478,7 @@ function Tabs() //{{{ { bang: true, count: true, - completer: function (filter) completion.buffer(filter) + completer: function (context) completion.buffer(context.filter) }); commands.add(["buffers", "files", "ls", "tabs"], @@ -548,7 +548,7 @@ function Tabs() //{{{ }, { bang: true, - completer: function (filter, bang, args, context) completion.url(context) + completer: function (context) completion.url(context) }); commands.add(["tabde[tach]"], @@ -618,7 +618,7 @@ function Tabs() //{{{ undoCloseTab(count - 1); }, { - completer: function (filter) + completer: function (context) { // get closed-tabs from nsSessionStore var ss = Components.classes["@mozilla.org/browser/sessionstore;1"] @@ -629,7 +629,7 @@ function Tabs() //{{{ { var url = undoItems[i].state.entries[0].url; var title = undoItems[i].title; - if (completion.match([url, title], filter, false)) + if (completion.match([url, title], context.filter, false)) completions.push([url, title]); } return [0, completions]; diff --git a/content/ui.js b/content/ui.js index 2be9b50c..af2746d5 100644 --- a/content/ui.js +++ b/content/ui.js @@ -500,7 +500,7 @@ function CommandLine() //{{{ if (str != null) command.action(str); }, - { completer: function (filter, bang, args, context) completion.javascript(context) }); + { completer: function (context) completion.javascript(context) }); }); commands.add(["mes[sages]"], diff --git a/content/vimperator.js b/content/vimperator.js index 5e0607d3..b4c11526 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -293,7 +293,7 @@ const config = { //{{{ }, { bang: true, - completer: function (filter, args, bang, context) completion.url(context) + completer: function (context) completion.url(context) }); commands.add(["redr[aw]"], @@ -345,7 +345,7 @@ const config = { //{{{ }, { argCount: "+", - completer: function (filter) completion.sidebar(filter) + completer: function (context) completion.sidebar(context.filter) }); commands.add(["winc[lose]", "wc[lose]"], @@ -364,7 +364,7 @@ const config = { //{{{ else liberator.open("about:blank", liberator.NEW_WINDOW); }, - { completer: function (filter, bang, args, context) completion.url(context) }); + { completer: function (context) completion.url(context) }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// OPTIONS /////////////////////////////////////////////////