Files
doomemacs/modules/editor/evil
Henrik Lissner 51d3b1b424 💥 revise advice naming convention (1/2)
This is first of three big naming convention updates that have been a
long time coming. With 2.1 on the horizon, all the breaking updates will
batched together in preparation for the long haul.

In this commit, we do away with the asterix to communicate that a
function is an advice function, and we replace it with the '-a' suffix.
e.g.

  doom*shut-up -> doom-shut-up-a
  doom*recenter -> doom-recenter-a
  +evil*static-reindent -> +evil--static-reindent-a

The rationale behind this change is:

1. Elisp's own formatting/indenting tools would occasionally struggle
   with | and * (particularly pp and cl-prettyprint). They have no
   problem with / and :, fortunately.
2. External syntax highlighters (like pygmentize, discord markdown or
   github markdown) struggle with it, sometimes refusing to highlight
   code beyond these symbols.
3. * and | are less expressive than - and -- in communicating the
   intended visibility, versatility and stability of a function.
4. It complicated the regexps we must use to search for them.
5. They were arbitrary and over-complicated to begin with, decided
   on haphazardly way back when Doom was simply "my private config".

Anyhow, like how predicate functions have the -p suffix, we'll adopt the
-a suffix for advice functions, -h for hook functions and -fn for
variable functions.

Other noteable changes:
- Replaces advice-{add,remove}! macro with new def-advice!
  macro. The old pair weren't as useful. The new def-advice! saves on a
  lot of space.
- Removed "stage" assertions to make sure you were using the right
  macros in the right place. Turned out to not be necessary, we'll
  employ better checks later.
2019-07-22 02:27:45 +02:00
..
2019-07-22 02:27:45 +02:00
2019-07-22 02:27:45 +02:00
2019-07-22 02:27:45 +02:00
2019-07-22 02:27:45 +02:00
2019-06-10 09:38:57 +02:00

feature/evil

Description

This holy module brings the vim experience to Emacs.

Module Flags

  • +everywhere Enables evilified keybinds everywhere possible. Uses the evil-collection plugin as a foundation.

Hacks

  • When a window is split, the new window will be focused.
  • The o/O keys will respect and continue commented lines (can be disabled by setting +evil-want-o/O-to-continue-comments to nil).
  • In visual mode, * and # will search for the current selection instead of the word-at-point.
  • The :g[lobal] ex command has been modified to highlight matches.
  • More of vim's filename modifiers are supported in ex commands (like :p, :p:h or :t) than vanilla evil-mode offers.
  • A custom filename modifier is available in Doom: :P, which expands to the project root (throws an error if not in a project).

Prerequisites

This module has no external prerequisites.

Features

Ported vim plugins

The following vim plugins have been ported to evil:

Vim Plugin Emacs Plugin Keybind(s)
vim-commentary evil-commentary omap gc
vim-easymotion evil-easymotion omap gs
vim-seek or vim-sneak evil-snipe mmap s=/=S, omap z=/=Z & x=/=x
vim-surround evil-embrace and evil-surround vmap S, omap ys

In other modules:

  • The tools/neotree & tools/treemacs modules provide a NERDTree equivalent.
  • The editor/multiple-cursors module contains functionality equal to the following vim plugins:

    • evil-multiedit => vim-multiedit
    • evil-mc => vim-multiple-cursors

Custom Text Objects

This module provides a couple extra text objects, along with the built-in ones. For posterity, here are the built-in ones:

  • w W words
  • s sentences
  • p paragraphs
  • b parenthesized blocks
  • ) { } [ ] < >= braces, parentheses and brackets
  • ' " ` quotes
  • t tags
  • o symbols

And these are text objects added by this module:

  • a C-style fucntion arguments (provided by evil-args)
  • B any block delimited by braces, parentheses or backets (provided by evil-textobj-anyblock)
  • i j k By indentation (k includes on line above and j includes one line below) (provided by evil-indent-plus)
  • x XML attributes (provided by exato)

Custom Ex Commands

Ex Command Description
:@ Apply macro on selected lines
:ag[!] REGEXP Perform a project search with ag
:agcwd[!] REGEXP Perform a project search with ag from the current directory
:al[ign][!] REGEXP Align text to the first match of REGEXP. If BANG, align all matches on each line
:cp[!] NEWPATH Copy the current file to NEWPATH
:dash QUERY Look up QUERY (or the symbol at point) in dash docsets
:dehtml [INPUT] HTML decode selected text / inserts result if INPUT is given
:enhtml [INPUT] HTML encode selected text / inserts result if INPUT is given
:grep[!] Perform a project search with git-grep
:grepcwd[!] Perform a project search with git-grep from the current directory
:iedit REGEXP Invoke iedit on all matches for REGEXP
:k[ill]all[!] Kill all buffers (if BANG, affect buffer across workspaces)
:k[ill]b Kill all buried buffers
:k[ill]m[!] REGEXP Kill buffers whose name matches REGEXP (if BANG, affect buffers across workspaces)
:k[ill]o Kill all other buffers besides the selected one
:k[ill] Kill the current buffer
:lo[okup] QUERY Look up QUERY on an online search engine
:mc REGEXP Invoke multiple cursors on all matches for REGEXP
:mv[!] NEWPATH Move the current file to NEWPATH
:na[rrow] Narrow the buffer to the selection
:pad Open a scratch pad for running code quickly
:pt[!] Perform a project search with pt
:ptcwd[!] Perform a project search with pt from the current directory
:ral[ign][!] REGEXP Right-Align text that matches REGEXP. If BANG, align all matches on each line
:repl Open a REPL and/or copy the current selection to it
:retab Convert indentation to the default within the selection
:rev[erse] Reverse the selected lines
:rg[!] Perform a project search with ripgrep
:rgcwd[!] Perform a project search with rigprep from the current directory
:rm[!] [PATH] Delete the current buffer's file and buffer
:tcd[!] Send cd X to tmux. X = the project root if BANG, X = default-directory otherwise

Configuration

Removing evil-mode

You must do two things to remove Evil:

  1. Remove :editor evil from ~/.doom.d/init.el,
  2. Run doom refresh to clean up lingering dependencies and refresh your autoloads files.
  3. [OPTIONAL] You may want to assign new values to doom-leader-alt-key and doom-localleader-alt-key. These are bound to C-c and C-c l by default.

Ignore doom-leader-key and doom-localleader-key, they don't apply to non-evil sessions.

Evil-specific configuration and keybindings (defined with map!) will be ignored without :editor evil present (and omitted when byte-compiling).

Keep in mind that, at the time of this writing, Doom was designed by a vimmer, for vimmers. Little consideration has been put into designing a keybind scheme for vanilla Emacs users (though it's being worked on!).

That means that much of Doom's functionality will be orphaned in an evil-less setup. You'll have to set your own keybinds.

I suggest studying config/default/+emacs-bindings.el to see what keybinds are available for non-evil users. Otherwise, you may find inspiration on the example Doom configurations page.

Restoring old substitution behavior on s/S

Doom replaces the s and S keys with the evil-snipe package (a port of vim-seek/vim-sneak for 2-character versions of f/F/t/T).

To disable evil-snipe on s/S, you can either:

  1. Disable evil-snipe-mode by adding (after! evil-snipe (evil-snipe-mode -1)) to $DOOMDIR/config.el,
  2. Or disable evil-snipe completely with (package! evil-snipe :disable t) added to $DOOMDIR/packages.el, but this will also disable incremental highlighting for the f/F/t/T motions keys.
  3. Or use cl and cc, respectively; they do the same thing.