From 2463ff2c08f9fa685cd50f1e6515c1e2e53893d5 Mon Sep 17 00:00:00 2001 From: anekos Date: Thu, 4 Mar 2010 14:34:31 +0000 Subject: URLの補完候補に現在のバッファのURLとドメインを追加 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36933 d0d07461-0603-4401-acd4-de1884942a52 --- feedSomeKeys_3.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'feedSomeKeys_3.js') diff --git a/feedSomeKeys_3.js b/feedSomeKeys_3.js index c7736fd..fec1544 100755 --- a/feedSomeKeys_3.js +++ b/feedSomeKeys_3.js @@ -39,7 +39,7 @@ let PLUGIN_INFO = feedSomeKeys 3 feed some defined key events into the Web content キーイベントをWebコンテンツ側に送る - 1.6.1 + 1.7.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -477,14 +477,21 @@ let INFO = <> ]; } - function urlCompleter (context, args) { - let maps = findMappings({all: true}); - let uniq = {}; - return [ - (uniq[map.matchingUrls] = 1, [map.matchingUrls.source, map.names]) - for each (map in maps) - if (map.matchingUrls && !uniq[map.matchingUrls]) - ]; + function urlCompleter ({currentURL}) { + return function (context, args) { + let maps = findMappings({all: true}); + let uniq = {}; + let result = [ + (uniq[map.matchingUrls] = 1, [map.matchingUrls.source, map.names]) + for each (map in maps) + if (map.matchingUrls && !uniq[map.matchingUrls]) + ]; + if (currentURL) { + result.unshift([util.escapeRegex(buffer.URL), 'Current URL']); + result.unshift([util.escapeRegex(content.document.domain), 'Current domain']); + } + return result; + }; } @@ -556,7 +563,7 @@ let INFO = <> { literal: 0, options: [ - [['-urls', '-u'], commands.OPTION_STRING, regexpValidator, urlCompleter], + [['-urls', '-u'], commands.OPTION_STRING, regexpValidator, urlCompleter({currentURL: true})], [['-desc', '-description'], commands.OPTION_STRING], [['-frame', '-f'], commands.OPTION_INT], [ @@ -593,7 +600,7 @@ let INFO = <> bang: true, completer: function (context) { context.title = ['URL Pattern']; - context.completions = urlCompleter(context); + context.completions = urlCompleter({})(context); } }, true @@ -615,7 +622,7 @@ let INFO = <> { literal: 0, options: [ - [['-urls', '-u'], commands.OPTION_STRING, regexpValidator, urlCompleter], + [['-urls', '-u'], commands.OPTION_STRING, regexpValidator, urlCompleter({})], [['-ignoreurls', '-iu'], commands.OPTION_NOARG] ], completer: fmapCompleter -- cgit v1.2.3