« HDD交換してホームディレクトリを別パーティションに移動 | ホーム | RSSのdescriptionがmarkdown記法のままだ »

2008年6月24日

Vimperatorと、ウェブアプリやUserscriptのショートカットキーを共存させるfeedSomeKeys.jsプラグイン

Vimperatorと、ウェブアプリやUserscriptのショートカットキーを共存させるfeedSomeKeys.jsプラグイン

現在は出来ることは基本的に変わらないけどより簡易な記述が可能になったfeedSomeKeys_2.jsがあるのでそっちを使うと良いです。と今更ながら追記。

#vimperator@IRCNet で id:trapezoid と id:otsune から ex_autocmd.js が無くてもLocationChangeで出来るよ。と教わったので関連部分を直しました。Thx!!

どうも feedSomeKeys.js を使っている人がいないようなので書く。

Vimperatorを使っていると、ウェブアプリケーションやUserscriptのショートカットキーがVimperotarとバッティングして使えない。ということがよくある。

こういう場合、基本的にはC-qでPATH THROUGHモード(Vimperatorのキーバインドを無効化する)にすることで一応解決するんだけど、はっきり言ってめんどくさいし、今どっちのモードだったか忘れててギャー!ってなるし、関係ないキーまで無効化されるのはやだ(tabopenやタブ切り替えのキーは常に使いたい!)。

ということで、feedSomeKeys.js の登場です。

feedSomeKeys.js は、任意のURLで任意のキーをスルーする(Vimperatorで処理せずにブラウザに渡す)ためのPlugin(URLの指定には ex_autocmd.js を併用する必要がある)

具体的には、以下のようなことができる。

  • Gmailのショートカットキーを使いつつ、Vimperatorも使う
  • livedoor Readerで j,k,a,s,v,p を使いつつ、Vimperatorも使う
  • Tumblr + LDRize + ReblogCommand 環境で t (Reblogキー) を i に置き替えて使う(Vimperatorの t も使いたいから)

autoIgnoreKey.js などで自動的にPATH THROUGHモードに切り替えるのと違って、その他のVimperatorのキーバインドは生かしたまま、指定したキーだけをスルーできるのが特徴。

.vimperatorrc の設定方法

詳しくはソースコード上のコメントでしっかり解説されているのでそれを読んでもらうとして、簡単に言うとコマンドは2つだけ。:fmap でスルーするキーを指定する。:fmapc で全ての指定を削除して元に戻す。

:f[eed]map lhs           -> lhsのキーマップをそのままWebコンテンツへ
:f[eed]map lhs [num]rhs  -> lhsのキーマップをrhsへ変換してWebコンテンツへ
                            [num]はフレームの番号(省略時はトップウィンドウへイベントが送られる)
:fmapc
:feedmapclear            -> 全てを無に帰して元に戻す

URLごとに指定するには、ex_autocmd.jsを併用して以下のように記述する。

autocmd LocationChange .* :fmapc
autocmd LocationChange http://reader\.livedoor\.com/reader/ :fmap j

:fmapc を先に書かないと端からクリアされて正しく動作しないので注意。

実例

retlet-vimperatorrcから抜粋。
以下を ~/.vimperator/plugin/ にインストールしておくこと。

:fmap 関連よりも手前に autocmd LocationChange .* :fmapc を記述すること。

上の記法はVimperator 1.2preからの対応なので、stable版である1.1使ってる人は使えません。 だそうで、1.1を使いたい人はex_autocmd.jsと併用するのがいいです。その場合.vimperatorrcの記述が多少変わるのでDiffを参考に。

Gmail

  • :fmap の部分はjavascriptを使って一括指定できる
  • フレームに分けられているので、何番目のフレームにキーを渡すか指定する("4"の部分)
  • 正規表現が使えるので、GoogleAppsのURLにも対応させる
js <<EOF
autocommands.add('LocationChange',/mail\.google\.com\/(mail|a)\//,[
  'js plugins.feedKey.setup(',
  '"c / y j k n p o u e x s r a # [ ] z ? gi gs gt gd ga gc".split(/ +/).map(function(i) [i, "4" + i])',
  ');'
].join(''));
EOF

livedoor Reader

js <<EOF
autocommands.add('LocationChange',/reader\.livedoor\.com\/reader\//,
  'js plugins.feedKey.setup("j k s a p v c <Space> <S-Space> z Z < > q w b i".split(/ +/));');
EOF
  • LDRize と同じ感覚で使いたいので、o で現在のitemを開く&次のitemに移動させる
  • J,K を Space,S-Space 互換にする
autocmd LocationChange http://reader\.livedoor\.com/reader/ :fmap o vj
autocmd LocationChange http://reader\.livedoor\.com/reader/ :fmap J <Space>
autocmd LocationChange http://reader\.livedoor\.com/reader/ :fmap K <S-Space>
  • feedSomeKeys.js と関係ないけど、LDR表示中のみリンクをバックグラウンドで開くようにする。o連打でバックグラウンドにタブを開いておいて後から見る。みたいな使い方。
  • jsじゃなくてset!でpref設定できるらしいので直した。
autocmd LocationChange (?!http://reader\.livedoor\.com/reader/) set! browser.tabs.loadDivertedInBackground=false
autocmd LocationChange http://reader\.livedoor\.com/reader/ set! browser.tabs.loadDivertedInBackground=true

Tumblr (Minibuffer + LDRize + ReblogCommand)

  • ldrize_cooperation.js 使っていればjavascript部分の指定は不要
  • ReblogCommand のtキーはVimperatorでも使用頻度が高いので、iキーに置き替える
js <<EOF
autocommands.add('LocationChange',/.*\.tumblr\.com\//,
  'js plugins.feedKey.setup("j k p o".split(/ +/));');
EOF
autocmd LocationChange http://.*\.tumblr\.com/ :fmap i tj

以上。
PATH THROUGHモードとか使っていいのは小学生までだよねー。

トラックバック(4)

トラックバックURL: http://retlet.net/cgi-bin/mt5/mt-tb.cgi/35

retlet.net - Vimperator¤È¡¢¥¦¥§¥Ö¥¢¥×¥ê¤äUserscript¤Î¥·¥ç¡¼¥È¥«¥Ã¥È¥­¡¼¤ò¶¦Â¸... 続きを読む

retlet.net - Vimperatorと、ウェブアプリやUserscriptのショートカットキーを共存させるfeedSomeKeys.jsプラグ... 続きを読む

Vimperatorを使いつつlivedoor ReaderやGmailなどのWebアプリのショートカットを利用できるようにするプラグイン「feedSo... 続きを読む

treating toenail fungus - treating toenail fungus (2013年6月12日 07:03)

Vimperatorと、ウェブアプリやUserscriptのショートカットキーを共存させるfeedSomeKeys.jsプラグイン - retlet.net 続きを読む

コメント(995)

I am going to go ahead and save this content for my brother for a coming up study project for class. This is a attractive site by the way. Where did you find the theme for this web page?

I really enjoy this template you've got going on on your internet site. What is the name of the template by the way? I was thinking of using this style for the site I am going to put together for my class project.

This is a interesting article by the way. I am going to go ahead and bookmark this article for my sister to read later on tomorrow. Keep up the first-rate work.

The style that you write make it very easy to read. And the theme you use, wow. It truly is a really good combination. And I am wondering what's the name of the template you use?

I was looking online for some info since yesterday night and I at long last found this! This is a wonderful site by the way, except it seems to be a little bit off place in my att phone.

I was checking using the web for some info since yesterday night and I at long last found what i was looking for! This is a wonderful site by the way, however it looks a slight hard to see from my smart phone.

I really enjoy this template you've got going on on your web site. What is the name of the theme by the way? I was thinking of using this style for the site I am going to create for my school project.

Just to let you know, this post seems a little bit weird from my android phone. Who knows perhaps it is just my phone. Great post by the way.

Just to let you know, this post appears a little bit odd from my smart phone. Who knows maybe it really is just my mobile phone. Great article by the way.

Just to let you know, this post seems a little bit funny from my android phone. Who knows maybe it really is just my mobile phone. Great article by the way.

I am going to go ahead and save this content for my sister for their study project for class. This is a pretty web page by the way. Where do you acquire the template for this web page?

good evening, I’m a college English major and I’m learning a lot about writing by reading world wide web. I in fact enjoy your style of writing. It’s very easy to understand but with brilliant details. Your choice of words makes it easy to read and understand. That’s a huge portion of writing. Your viewers have to be able to understand what you’re saying and it has to be worthy of note. You need to challenge your viewers , so they will come back for more. You do a decent job with all of these tittle. Thx!

The post is very appealing, you made some valid points and the matter is on point. I have made a decision to add your site to my bookmarks so I can go back to it at another time.

My sister bookmarked this site for me and I have been going through it for the past couple hours. This is really going to help me and my classmates for our class project. By the way, I enjoy the way you write.

Just to let you know, this post seems a little bit weird from my smart phone. Who knows perhaps it is just my phone. Great article by the way.

Hey man, was just looking through the net looking for some info and came across your post. I am impressed by the info that you have on this blogsite. It shows how well you understand this topic. bookmarked this page, will come back for more. You, my friend, ROCK!!!

I really enjoy this design you have got going on on your blog. What is the name of the design by the way? I was thinking of using this style for the blog I am going to put together for my class project.

I love visiting your content for the reason that you often give us huge posts about computers and technology. outstanding writeup… astounding Job once again. I plan to put this web site in my favorites list. I think I shall subscribe to the web site feed also…

I had this post bookmarked some time previously but my computer crashed. I have since gotten a new one and it took me a while to locate this! I also in fact like the theme though.

I would like to thank you for the endeavors you have made in writing this article. I am trusting the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own blog now. Actually the blogging is spreading its wings rapidly. Your write up is a fine representative of it.

But yeah Many thanks for taking the time to talk about this, I think strongly about it and in reality like learning more on this topic. If viable, as you gain expertise, would you mind updating your web site with more information? It is extremely helpful for me.

I am going to go ahead and bookmark this post for my brother for a research project for school. This is a attractive site by the way. Where do you obtain the theme for this website?

Hi. I just noticed that your internet site looks like it has a few code errors at the very top of your content’s page. I’m not sure if everybody is getting this same bugginess when browsing your blog? I am employing a totally different browser than most people, referred to as Opera, so that is what might be causing it? I just wanted to make sure you know. Thank you for posting some great postings and I’ll try to return back with a completely different browser to check things out!

Wow in actual fact a huge post. I like this.I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him. Overall, Lots of huge information and inspiration, both of which we all need!

I was exploring online for some info since yesterday night and I at long last found what i was looking for! This is a fantastic web site by the way, although it seems a little difficult to read on my i phone.

The style that you write make it very trouble-free to read. And the design you use, wow. It really is a really decent combination. And I am wondering what is the name of the template you use?

The style that you write make it very easy to read. And the theme you use, wow. It is a really decent combination. And I am wondering what's the name of the template you use?

Contrary to many views, better researched articles still fetch in reviewers like me. You demonstrated clear understanding of the subject matter and my sentiments are now complete after reading your post. Please hold up the solid work and i will subscribe to your rss feed to be advised of any future postings.

I was checking via the web for some information since yesterday night and I at long last found this! This is a impressive web site by the way, except it is a little difficult to read on my i phone.

I was looking via a search engine for some info since yesterday night and I at last found what i was looking for! This is a cool blog by the way, but it seems a little difficult to read from my i phone.

Hi, I just read texts on your website and I became interested in the topic. I like your page and I am thinking whether I could use your words in my work? Would it be doable? If yes, please contact with me. Thanks.

This is some useful material. It took me some time to unearth this site but it was worth the time. I noticed this article was hidden in google and not the first spot. This web site has a ton of first-rate stuff and it doesn't deserve to be burried in the searches like that. By the way I am going to save this website to my favorites.

This is some helpful material. It took me some time to come across this blog but it was worth the time. I noticed this page was buried in yahoo and not the number one spot. This web site has a lot of fine stuff and it does not deserve to be burried in the search engines like that. By the way I'm going to add this webpage to my list of favorites.

Nicely done! - I looked at the Wiki on this and it did not have as detailed info - thanks!

My bro bookmarked this web publication for me and I have been reading through it for the past couple hrs. This is really going to help me and my friends for our class project. By the way, I like the way you write.

This is some high-quality stuff. It took me a while to find this website but it was worth the time. I noticed this article was buried in google and not the first spot. This webpage has a ton of beneficial stuff and it doesn't deserve to be burried in the searches like that. By the way I'm going to add this website to my favorites.

I really enjoy this theme you've got going on on your internet site. What is the name of the template by the way? I was thinking of using this style for the website I am going to put together for my class room project.

Took me time for you to read all the notes, but I truly enjoyed the editorial. It proved to be in actual fact helpful to me and I’m sure to all of the commenters right here! It’s usually great when you can not just be informed, but additionally engaged! I’m certain you had enjoyable writing this write-up.

This is a attention-grabbing post by the way. I am going to go ahead and bookmark this post for my sis to check out later on tomorrow. Keep up the fine work.

Hi - actually great internet site you have created. I enjoyed reading this posting. I did want to publish a remark to tell you that the design of this content is very aesthetically delightful. I used to be a graphic designer, now I am a copy editor. I have always enjoyed functioning with information processing systems and am trying to learn code in my free time.

Your website came up in my research and I’m taken by what you have written on this topic. I am presently extending my enquiry and thus cannot contribute further, nonetheless, I have bookmarked your world-wide-web website and will be returning to keep up with any next updates. Just Now love it and gives thanks for tolerating my remark.

I was researching on the web for some information since yesterday night and I finally found what i was looking for! This is a impressive web site by the way, however it is a little hard to navigate on my android phone.

I am going to go ahead and bookmark this post for my sister for their research project for school. This is a pretty web site by the way. Where did you get a hold the theme for this webpage?

Ive got to say, the layout alone made me come back to this webpage again. But now that Ive check out what youve got to say, Ive got to share it with the world!

I am going to go ahead and save this page for my sister for the study project for class. This is a good-looking site by the way. Where do you obtain the theme for this website?

Thank you for posting this content. I’m certainly frustrated with struggling to search out relevant and brilliant commentary on this subject. Everybody now goes to the very far extremes to either drive home their viewpoint that either: everyone else in the planet is wrong, or two that everyone but them does not really understand the situation. Many thank you for your succinct, applicable insight.

Appreciate writing this. I love the net because you can study something new every day. I’ll share this with my friends, thank you!

This is a interesting post by the way. I am going to go ahead and save this post for my brother to check out later on tomorrow. Keep up the fine work.

I am going to go ahead and save this article for my brother for a coming up research project for school. This is a attractive blog by the way. Where did you find the theme for this website?

I’m often to blogging and i in reality respect your content. The content has actually peaks my interest. I’m going to bookmark your content and preserve checking for brand new information.