From 61a462594d866768db730df0b14745b48eadecb4 Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 16 Mar 2010 11:46:38 +0000 Subject: :xhintdo 追加。コマンド名は変えたほうが良いかも git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37035 d0d07461-0603-4401-acd4-de1884942a52 --- x-hint.js | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'x-hint.js') diff --git a/x-hint.js b/x-hint.js index 8e0abfa..a6fb519 100755 --- a/x-hint.js +++ b/x-hint.js @@ -39,7 +39,7 @@ let PLUGIN_INFO = X-Hint Show the hints with given XPath. 指定のXPathでヒントを表示する。 - 1.0.0 + 1.1.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -110,13 +110,13 @@ let INFO = let last = {}; function xpath () - ((last.args && last.args.literalArg) || '//a') + (last.xpath || '//a') plugins.libly.$U.around( hints, 'show', function (next, [minor, filter, win]) { - if (last.args) { + if (last.xpath) { // save last.hintMode = this._hintModes[minor]; last.hintTags = last.hintMode.tags; @@ -144,7 +144,7 @@ let INFO = ['xh[int]'], description, function (args) { - last.args = args; + last.xpath = args.literalArg; hints.show(args[0]); }, { @@ -152,6 +152,39 @@ let INFO = }, true ); + + let (hintModeText = 'x-hint-do', js = null) { + hints.addMode( + 'x-hint-do', + 'X-Hint DO', + function (elem) { + let context = { + __proto__: elem, + $: elem + }; + try { + liberator.eval(js, context); + } catch (e) { + liberator.echoerr(e); + } + } + ); + + commands.addUserCommand( + ['xhintdo', 'xhdo'], + 'Run js-code with X-Hint', + function (args) { + last.xpath = args[0]; + js = args.literalArg; + hints.show(hintModeText); + }, + { + literal: 1 + }, + true + ); + } + })(); // vim:sw=2 ts=2 et si fdm=marker: -- cgit v1.2.3