Skip to content

Kyuvi/ez-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Ez-map

The main repository is on Codeberg.org, if you are viewing this anywhere else, it is just a mirror, please use the Codeberg.org repository for pull requests and issues, Thank you.

Description

A centralized keybinds system for GNU Emacs, which can integrate with the Which-key package to preview available keybindings, based on Doom Emacs’s keybinds system.

Ez-map provides the map!, cmd!, cmd!!, cmds!, and kbd! macros to make binding keys to functions easier. If evil is never loaded, then evil bindings set with map! are ignored (i.e. omitted entirely for performance reasons).

It also provides an after! macro which wraps with-eval-after-load.

NOTE: while the other macros should follow their doom counterparts exactly, after! is slightly different as the Doom Emacs version is integrated with the Doom Emacs package system.

Ez-map has been tested on GNU Emacs versions 25.1 and 27.1 on Linux.

Motivation

While Doom Emacs is an amazing distribution, it is a bit complex and does have a few dependencies. However Doom Emacs’s map! macro is very simple and intuitive to use, and keybinding in vanilla GNU Emacs (or even with evil-mode) is for me one of its serious downsides, and keybindings are usually the first thing one wants to customize, so I decided to distill out the map! Macro (and the other macros connected to keybinding) into a package that can be used easily, ergo, ‘ez-map’.

Dependencies

Optional packages

Installation

Standard installation, using require

(add-to-list 'load-path "path/to/ez-map.el")
(require 'ez-map)
;; initialize evil and/or update leader key variables if so inclined
(ez-map-init-leader-keys)

or with use-package using the default leader keys…

;; initialize evil
(use-package ez-map
 :init "path/to/ez-map.el"
 :config (ez-map-init-leader-keys)) ;; initialize the leader keys

Initialization and customization

To initialize the leader keys run....

(ez-map-init-leader-keys)

In your init file, after setting the leader keys if so inclined.

The leader keys can be set with the variables ez-map-leader-key (default “SPC”) and ez-map-leader-alt-key (default “M-SPC”).

If evil mode is used ez-map-init-leader-keys should be run after evil-mode itself is initialized.

The localleader variables ez-map-localleader-key (default “SPC m”) and ez-map-localleader-alt-key (default “M-SPC m”) can also be customized.

Key binding examples

(map! :map ielm-map
      :m  "C-r" 'do-something           ; C-r in motion state
      :nv "Q" 'kill-current-buffer   ; Q in normal+visual states
      "C-x C-r" 'a-global-keybind
      :g "C-x C-r" 'another-global-keybind  ; same as above

      (:when (eq system-type 'darwin) ;; OS specific
        :n "M-s" 'some-fn
        :i "M-o" (cmd! (message "Hi"))))

(map! (:when (featurep 'company) ; Conditional loading
        :i "C-@" #'+company/complete
        (:prefix "C-x"                       ; Use a prefix key
         :i "C-l" #'+company/whole-lines)))

(map! (:when (featurep 'tex-mode)    ; local conditional
        (:map LaTeX-mode-map
         :localleader                  ; Use local leader
         :desc "View" "v" #'TeX-view)) ; Add which-key description
      :leader                           ; Use leader key from now on
      :desc "Eval expression" ";" #'eval-expression)

(map! :leader
      :prefix  ("f" . "file")    ;; prefix key with which-key description
      :desc "Find file" :n "f" 'find-file)

Donations

If you would like to support my work, please donate.

Monero

42s4DCgjk2sguR8x1H4Svx7sBuysvrRHGCK3pfQTcEerNBUGhT43gMy6noctiGeVeo61aFzsQfGwVTxNmruy3dqb8PAyYZM

Bitcoin

bc1quymsg5tvyvqkcn35zzujfdrdwgxnakqaptqc5k

LiteCoin

ltc1q8ese8e8rl9c80emqgvek24gylz32u3d76v2e9q

Releases

No releases published

Packages

No packages published