diff options
author | anekos | 2010-03-16 11:46:38 +0000 |
---|---|---|
committer | anekos | 2010-03-16 11:46:38 +0000 |
commit | 61a462594d866768db730df0b14745b48eadecb4 (patch) | |
tree | 44b20926f90115c48fb7c944772e4b60200f80cf /x-hint.js | |
parent | 455c8eed3c89d6c743c6a0e0ff17e59adbd5ded4 (diff) | |
download | vimperator-plugins-61a462594d866768db730df0b14745b48eadecb4.tar.bz2 |
:xhintdo 追加。コマンド名は変えたほうが良いかも
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37035 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'x-hint.js')
-rwxr-xr-x | x-hint.js | 41 |
1 files changed, 37 insertions, 4 deletions
@@ -39,7 +39,7 @@ let PLUGIN_INFO = <name lang="ja">X-Hint</name> <description>Show the hints with given XPath.</description> <description lang="ja">指定のXPathでヒントを表示する。</description> - <version>1.0.0</version> + <version>1.1.0</version> <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> <license>new BSD License (Please read the source code comments of this plugin)</license> <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license> @@ -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: |