All Projects → justbur → emacs-bind-map

justbur / emacs-bind-map

Licence: GPL-3.0 license
Bind personal keymaps in multiple locations

Programming Languages

emacs lisp
2029 projects
Makefile
30231 projects

Projects that are alternatives of or similar to emacs-bind-map

Mode Icons
Show icons instead of mode names
Stars: ✭ 140 (+154.55%)
Mutual labels:  emacs-packages
Academic Phrases
Bypass that mental block when writing your papers.
Stars: ✭ 244 (+343.64%)
Mutual labels:  emacs-packages
epkg
Browse the Emacsmirror package database
Stars: ✭ 45 (-18.18%)
Mutual labels:  emacs-packages
Org Msg
OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
Stars: ✭ 153 (+178.18%)
Mutual labels:  emacs-packages
Evil Multiedit
Multiple cursors for evil-mode, based on iedit
Stars: ✭ 200 (+263.64%)
Mutual labels:  emacs-packages
dired-rsync
Support for rsync from Emacs dired buffers
Stars: ✭ 93 (+69.09%)
Mutual labels:  emacs-packages
Emacs Gdscript Mode
An Emacs package to get GDScript support and syntax highlighting.
Stars: ✭ 132 (+140%)
Mutual labels:  emacs-packages
gnuplot-mode
An emacs major mode for editing gnuplot scripts.
Stars: ✭ 29 (-47.27%)
Mutual labels:  emacs-packages
Uncledavesemacs
My personal ~/.emacs.d
Stars: ✭ 204 (+270.91%)
Mutual labels:  emacs-packages
jupyterlab-emacskeys
Emacs keybindings inside JupyterLab notebook cells
Stars: ✭ 27 (-50.91%)
Mutual labels:  emacs-keybindings
Emacs Vdiff
Like vimdiff for Emacs
Stars: ✭ 165 (+200%)
Mutual labels:  emacs-packages
Evil Snipe
2-char searching ala vim-sneak & vim-seek, for evil-mode
Stars: ✭ 196 (+256.36%)
Mutual labels:  emacs-packages
emacs-jest
A package to run jest inside emacs
Stars: ✭ 74 (+34.55%)
Mutual labels:  emacs-packages
Borg
Assimilate Emacs packages as Git submodules
Stars: ✭ 145 (+163.64%)
Mutual labels:  emacs-packages
cask-package-toolset.el
🛠 Toolsettize your emacs package! 🛠
Stars: ✭ 30 (-45.45%)
Mutual labels:  emacs-packages
Elpa
Emacs China ELPA 镜像
Stars: ✭ 137 (+149.09%)
Mutual labels:  emacs-packages
load-bash-alias
Convert bash aliases into eshell ones
Stars: ✭ 16 (-70.91%)
Mutual labels:  emacs-packages
modern-sh
🎸 An Emacs minor mode for editing shell script.
Stars: ✭ 27 (-50.91%)
Mutual labels:  emacs-packages
dired-toggle
Show dired as sidebar and will not create new buffers when changing directory
Stars: ✭ 23 (-58.18%)
Mutual labels:  emacs-packages
emacs2nix
Automatically generate Nix expressions for Emacs packages
Stars: ✭ 23 (-58.18%)
Mutual labels:  emacs-packages

https://travis-ci.org/justbur/emacs-bind-map.svg?branch=master http://melpa.org/packages/bind-map-badge.svg

bind-map

bind-map is an Emacs package providing the macro bind-map which can be used to make a keymap available across different “leader keys” including ones tied to evil states. It is essentially a generalization of the idea of a leader key as used in vim or the Emacs evil-leader package, and allows for an arbitrary number of “leader keys”. This is probably best explained with an example.

(bind-map my-base-leader-map
  :keys ("M-m")
  :evil-keys ("SPC")
  :evil-states (normal motion visual))
(bind-map my-elisp-map
  :keys ("M-m m" "M-RET")
  :evil-keys ("SPC m" ",")
  :major-modes (emacs-lisp-mode
                lisp-interaction-mode))

This will make my-base-leader-map (automatically creating the map if it’s not defined yet) available under the prefixes (or leaders) M-m and SPC, where the latter is only bound in evil’s normal, motion or visual states. The second declaration makes my-elisp-map available under the specified keys when one of the specified major modes is active. In the second case, the evil states used are also normal motion and visual because this is the default as specified in bind-map-default-evil-states. It is possible to make the bindings conditional on minor modes being loaded, or a mix of major and minor modes. Since the symbols of the modes are used, it is not necessary to ensure that any of the mode’s packages are loaded prior to this declaration. See the docstring of bind-map for more options.

This package will only make use of evil if one of the evil related keywords is specified. This declaration, for example, makes no use of the evil package.

(bind-map my-elisp-map
  :keys ("M-m m" "M-RET")
  :major-modes (emacs-lisp-mode
                lisp-interaction-mode))

The idea behind this package is that you want to organize your personal bindings in a series of keymaps separate from built-in mode maps. You can simply add keys using the built-in define-key to my-elisp-map for example, and a declaration like the one above will take care of ensuring that these bindings are available in the correct places.

Binding keys in the maps

You may use the built-in define-key which will function as intended. bind-key (part of use-package) is another option. For those who want a different interface, you may either use the :bindings keyword in the bind-map macro or the two provided functions bind-map-set-keys and bind-map-set-key-defaults, which both just use define-key internally, but allow for multiple bindings without much syntax.

(bind-map my-base-leader-map
  :keys ("M-m")
  :evil-keys ("SPC")
  :evil-states (normal motion visual)
  :bindings ("c" 'compile
             "C" 'check))

(bind-map-set-keys my-base-leader-map
  "c" 'compile
  "C" 'check
  ;; ...
  )
  ;; is the same as
  ;; (define-key my-base-leader-map (kbd "c") 'compile)
  ;; (define-key my-base-leader-map (kbd "C") 'check)
  ;; ...

(bind-map-set-key-defaults my-base-leader-map
  "c" 'compile
  ;; ...
  )
  ;; is the same as
  ;; (unless (lookup-key my-base-leader-map (kbd "c"))
  ;;   (define-key my-base-leader-map (kbd "c") 'compile))
  ;; ...

The second function only adds the bindings if there is no existing binding for that key. It is probably only useful for shared configurations, where you want to provide a default binding but don’t want that binding to overwrite one made by the user. Note the keys in both functions are strings that are passed to kbd before binding them.

Avoiding repetition

If you use multiple bind-map declarations you might find yourself repeating properties like :evil-keys and :evil-states. You may use bind-map-for-mode-inherit to automatically pull these properties from a parent map as the following example illustrates. See the docstring for more information.

(bind-map my-leader-map
  :keys ("M-m")
  :evil-keys ("SPC")
  :evil-states (normal motion visual))

(bind-map-for-mode-inherit my-markdown-map my-leader-map
  :major-modes (markdown-mode))
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].