#+TITLE: moz-controller: Control Firefox from Emacs It's annoying to switch between your text editor and your web browser constantly when you're hacking and reading web pages at the time. *moz-controller* allows you to control Firefox to scroll, refresh, zoom in, zoom out, close tabs and switch tabs without leaving Emacs. [[http://youtu.be/gP-zpA4WteM][Video Demo]] * Functions and Keybindings | function | name | keybinding | |------------------------+---------------------------------+------------| | get current tab's url | moz-controller-get-current-url | C-c m l | | refresh | moz-controller-page-refresh | C-c m R | | scroll down | moz-controller-page-down | C-c m n | | scroll up | moz-controller-page-up | C-c m p | | zoom in | moz-controller-zoom-in | C-c m + | | zoom out | moz-controller-zoom-out | C-c m - | | zoom reset | moz-controller-zoom-reset | C-c m 0 | | switch to previous tab | moz-controller-tab-previous | C-c m b | | switch to next tab | moz-controller-tab-next | C-c m f | | close current tab | moz-controller-tab-close | C-c m k | | view page source code | moz-controller-view-page-source | C-c m u | * Installation ** Firefox Plugin Install [[https://addons.mozilla.org/en-US/firefox/addon/mozrepl/][MozRepl]] in Firefox. ** Manual Installation First install [[https://github.com/bard/mozrepl/wiki/Emacs-integration][moz.el]] in Emacs (you can install it via Emacs package systems such as el-get). Then install moz-controller: ~git clone git@github.com:RenWenshan/emacs-moz-controller.git~ and add the following code in your .emacs or init.el: #+BEGIN_SRC emacs-lisp (add-to-list 'load-path "/path/to/emacs-moz-controller") (require 'moz-controller) #+END_SRC ** Package Installation moz-controller is available on [[https://github.com/milkypostman/melpa][melpa]]: - Make sure you have melpa in the ~package-archives~ list: #+BEGIN_SRC emacs-lisp (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) (when (< emacs-major-version 24) ;; For important compatibility libraries like cl-lib (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) (package-initialize) #+END_SRC - Press ~M-x package-list-packages~ to get a list of Emacs extensions. - Find ~moz-controller~ and install it from there. * Usage After installation, press ~M-x moz-controller-mode~ to turn on/off moz-controller-mode in the current buffer. Press ~M-x moz-controller-global-mode~ to turn on/off moz-controller-global-mode in all buffers, including future buffers. To turn on moz-controller-mode globally by default, you can add ~(moz-controller-global-mode t)~ to your .emacs or init.el. * Define New Commands I have a macro defined in moz-controller: ~defun-moz-controller-command~ You can use it to define new moz-controller commands, for example: #+BEGIN_SRC emacs-lisp (defun-moz-controller-command moz-controller-zoom-in () "Zoom in." (concat "gBrowser.selectedBrowser.markupDocumentViewer.fullZoom += " (number-to-string moz-controller-zoom-step) ";") ) #+END_SRC Where moz-controller-zoom-in is the function name, "Zoom in." is the docstring, (concat ...) is the command (in string format) you want *MozRepl* to execute. * Thanks - average on #emacs IRC - Chen Bin (https://github.com/redguardtoo) - Steve Purcell (https://github.com/purcell) * License See the LICENSE file. * Copyright (C) 2014 任文山 (Ren Wenshan) All rights reserved. renws1990 at gmail.com * Contributors - Steve Purcell (https://github.com/purcell)