jyp / boon

Ergonomic Command Mode for Emacs
GNU General Public License v3.0
334 stars 35 forks source link

Join the chat at https://gitter.im/boon-mode/Lobby MELPA MELPA-Stable

Boon: An Ergonomic Command Mode for Emacs

Boon is a complete package for modal editing, which is not Evil.

Strong points:

Ergonomic Design

It is largely accepted that modal editing is more ergonomic than using key-chords. Boon attempts to take this advantage to its conclusion, making modal editing as comfortable as possible, by adhering to the following design principles:

In command mode, movement keys are bound to the right hand, while text manipulation is bound to the left hand. This division of tasks is reminiscent of game-console controllers.

Right-hand.

The leftwards (and upwards) movements are bound to the leftmost fingers (index and middle finger), while rightwards (and downwards) movements are bound to the rightmost fingers (ring finger and pinky.) Additional unpaired movements are bound to the middle column, which is reached with an extension of the index finger.

Left-hand.

The most common editing commands (cut, paste, parenthesis manipulation) are bound to the home row. The top row is (mainly) for searching. The bottom row gives access to user-defined (C-x) and mode-specific shortcuts (C-c), insert mode, and registers.

Emacs integration

  1. C-x and C-c shortcuts. Any 'C-x ' command is available via 'x '. (drop the 1st "Control"). Thus 'x s' will save all buffers, etc. C-c C- shortcuts are now typed simply as "c ". This means that no special configuration is required when you start using a new major or minor mode.

  2. 'Special' modes. Emacs already has several modes which have a modal interface. (Dired, Magit, etc.) Instead of re-inventing the wheel, Boon leaves these modes alone (mostly). Only the 'x' key is stolen by Boon (so splitting windows, switching buffers, etc. keep their usual shortcut.)

  3. Command repeats. Boon does not use its own mechanism to repeat commands: it simply uses the Emacs standard way. Commands which contain an insertion (eg. replace current word by something else) are properly recorded in Emacs command history. Emacs command history remains fully usable with Boon.

  4. Parsing commands. Boon does not have a special way to parse commands. Everything is done using Emacs keymaps and interactive arguments.

  5. Customize-friendly. Quick customization is easily done using M-x customize-group boon. (re)-Defining keys in the boon-...-keymaps is also supported.

  6. Multiple-cursors support. System of selectors supports multiple-cursors: (multiple regions will be returned when multiple cursors are active).

Modular design

Boon is designed as set of modules, largely independent of each other. Each module is customizable and provides reusable components, in following the Emacs spirit of hackability. This means that even if you disagree with the design choices explained above, you may still want to use some parts of Boon. The structure of Boon is as follows:

  1. boon-moves.el and boon-search.el provide a set of move and search commands. These work the same way as standard Emacs commands --- they are merely more powerful (or just have different emphasis). Layout-frontends typically bind these commands (in addition to standard ones) in the boon keymaps.
  2. boon-arguments.el provides a set of selectors to define regions. (These selectors are the equivalent of vim 'text objects'). Selectors include plain regions (words, lines, paragraphs, ...), but also region transformers (think: exclude borders, just borders, including spaces, "foreach", etc.). Additionally every move command (in the boon-moves-map keymap) can be used as a selector which means that they are easily customized.
  3. boon-core.el provides an infrastructure for modal editing. The implementation draws much inspiration from evil-core, but is heavily simplified.
  4. boon-main.el provides a set of commands. These are similar to standard Emacs commands, but they use the system of selectors described above. (For good measure, some random extra commands are thrown in.) These commands may be used in combination with a modal system or not. A few commands also switch to insert mode.
  5. boon-keys.el, boon-colemak.el, boon-qwerty.el, etc. are (layout-specific) frontends. Those require all the above and provide a mapping of moves, selectors and commands onto keys.

Installation

REQUIREMENTS

Install Boon (perhaps using MELPA), and add the following to your configuration:

(require 'boon-colemak)
;; (require 'boon-qwerty) ;; for qwerty variant

Then

(boon-mode) ;; to enable boon everywhere

If you just eval'ed the above (or just did not want to enable boon everywhere), Boon may not be active in the current buffer. If it is not activated and you want to try it locally, activate it by

M-x turn-on-boon-mode

Usage

You can jump-start by reading any of the cheat sheets (colemak, qwerty) directly, but reading through the tutorial is highly recommended:

(require 'boon-tutorial)
M-x boon-tutorial

(You'll get the version of the tutorial adapted to the layout-frontend you have activated, qwerty, colemak, etc.)

Configuration

The main variables to configure are:

If you use powerline (or mutatis mutandis spaceline), you may want to:

(require 'boon-powerline)
(boon-powerline-theme) ;; if you want use powerline with Boon

Comparison with other modal layers for Emacs

If possible I would have liked not to develop Boon (or parts of it) and use an existing package. Hence I have looked into other options and have documented my research below. In summary, even though I would like to share code and/or replace parts of Boon with similar package, at the moment no package offers enough that I feel the urge to try and use them. This is partly due to the fact that Boon maintenance burden is fairly low. (And at the time of inception, the only conceivable alternative was Evil.)