LoginSignup
12

More than 3 years have passed since last update.

Emacsユーザ向けChrome拡張機能を公開してみた

Last updated at Posted at 2019-12-21

この記事はEmacs Advent Calendar 2019 22日目の記事です

概要

EmacsキーバインドでChromeを操作できるExtensionを公開してみたので、その紹介になります。
Screen Shot 2019-12-21 at 10.03.02.png

背景

筆者は以前メインブラウザとしてChromeではなくFirefoxを使っていました。というのもFirefoxにはFiremacsというEmacsユーザ向けのアドオンがあり、Chromeにはそれに代わるものが無かったためです。しかし、ある破壊的なアップデートによりFirefoxのアドオンが軒並み使えなくなっため、Chromeへの移行を余儀なくされたという経緯があります。ただChromeにはEmacsキーバインドでタブ操作やスクローリングを行えるExtensionが当時存在しなかったため、VimiumというVimユーザ向けの拡張機能を入れ、設定でキーバインドをEmacs風に書き換えるという面倒なことを行なっていました。そこで、最初からEmacsキーバインドを使えるChrome Extensionがあったら便利なのではと考えたのが公開のきっかけです。

ちなみにVimiumをEmacs風に使う方法に関しては、下記が参考になります。
ChromeのvimiumでEmacsキーバインドにしてみる
Vimium を Emacs ライクにして幸せになる話

機能

Emacsキーバインドでブラウザの操作を行えます。例えばC-v/M-vでスクロールダウン/アップしたり、C-b/C-fでタブを左右に移動したりなどです。一例を上げると下記のようなキーバインドが使えます。また設定からキーを変更して、自分なりにカスタマイズすることも可能です。

# Navigating the current page
    <c-h>       show the help dialog for a list of all available keys
    <c-b>       scroll left
    <c-n>       scroll down
    <c-p>       scroll up
    <c-f>       scroll right
    <c-m-,>     scroll to top of the page
    <c-m-.>     scroll to bottom of the page
    <c-v>       scroll down half a page
    <m-v>       scroll up half a page
    <c-x><c-f>  open a link in the current tab
    <c-x><a-F>  open a link in a new tab
    <m-r>       reload
    <a-s>       view source
    <c-g><c-u>  copy the current url to the clipboard
    <c-g><c-l>  copy a link url to the clipboard
    <c-x>o      cycle forward to the next frame

# Manipulating tabs
    <c-b>          go one tab left
    <c-f>          go one tab right
    <c-x><up>      go to the first tab
    <c-x><down>    go to the last tab
    <c-g><c-t>     create tab
    <c-x>4         duplicate current tab
    <c-x>0         close current tab
    <c-g><c-r>     restore closed tab (i.e. unwind the 'x' command)
    <c-x>b         search through your open tabs
    <c-x>5         move current tab to new window
    <a-p>          pin/unpin current tab

実装

Extensionの実装としては、VimiumのソースコードをforkしてキーバインドをEmacs風に書き換えただけです。リポジトリは下記に公開してあるので、修正等必要そうな箇所があれば自由にPR等送って頂ければと思います。
https://github.com/maeda-kazuya/chromemacs

注意点

Chromeの仕様のせいか、一部のページ(Chromeの設定画面等)でキーバインドが効かない場合があります。原因は調査中ですが、何らかのショートカットキーと競合しているか、そもそも拡張機能が無効化されている可能性もあります。

まとめ

その他お気づきの点があれば、下記Github上のIssueに上げて頂ければと思います。元々は自分用に作成したExtensionですが、使いづらい部分等があれば随時改善していきたいと思います。
https://github.com/maeda-kazuya/chromemacs/issues

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12