branch: elpa/devil commit 21eeb196f74a18509be48509af3822c49406cbe2 Author: Susam Pal <su...@susam.net> Commit: Susam Pal <su...@susam.net>
Explain how to configure multiple Devil keys --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index d1840bc17d..edc7cfccec 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Contents * [Local Mode](#local-mode) * [Custom Appearance](#custom-appearance) * [Custom Devil Key](#custom-devil-key) +* [Multiple Devil Keys](#multiple-devil-keys) * [Why?](#why) * [Support](#support) * [Channels](#channels) @@ -385,6 +386,38 @@ see the variables `devil-special-keys`, `devil-translations`, and `devil-repeatable-keys`, respectively. +Multiple Devil Keys +------------------- + +While this package provides the comma as the default and the only +Devil key, nothing stops you from extending the mode map to support +multiple Devil keys. Say, you decide that in addition to activating +Devil with `,` which also plays the role of `C-`, you also want to +activate Devil with `.` which must now play the role of `M-`. To +achieve such a result, you could tuse this initialization code as a +starting point and then customise it further based on your +requirements: + +```elisp +(defvar devil-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd ",") #'devil) + (define-key map (kbd ".") #'devil) + map)) +(require 'devil) +(global-devil-mode) +(setq devil-special-keys '((", ," . (lambda () (insert ","))) + (". ." . (lambda () (insert "."))))) +(setq devil-translations '(("," . "C-") + ("." . "M-"))) +``` + +With this configuration, we can type `, x , f` for `C-x C-f` like +before. But now we can also type `. x` for `M-x`. Similarly, we can +type `, . s` for `C-M-s` and so on. Further, `, ,` inserts a literal +comma and `. .` inserts a literal dot. + + Why? ----