Skip to content

Commit 54e4706

Browse files
committed
Update README with keymap- forms and use-package
1 parent e6eef24 commit 54e4706

1 file changed

Lines changed: 56 additions & 19 deletions

File tree

.github/README.md

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![melpa-stable-badge][melpa-stable-badge]][melpa-stable-link]
55
[![gh-actions-badge][gh-actions-badge]][gh-actions-link]
66

7-
_NOTE_: This package requires Emacs 26.3 to work well.
7+
_NOTE_: This package requires Emacs 29 to work well.
88

99
This is a global minor mode for entering Emacs commands without
1010
modifier keys. It's similar to Vim's separation of command mode and
@@ -47,22 +47,22 @@ God mode can be toggled through `god-local-mode` using the escape key
4747
(<kbd>ESC</kbd>) as follows:
4848

4949
```emacs-lisp
50-
(global-set-key (kbd "<escape>") #'god-local-mode)
50+
(keymap-global-set "<escape>" #'god-local-mode)
5151
```
5252

5353
If you want to toggle God mode on _all active and future buffers_, use
5454
`god-mode-all` as follows:
5555

5656
```emacs-lisp
57-
(global-set-key (kbd "<escape>") #'god-mode-all)
57+
(keymap-global-set "<escape>" #'god-mode-all)
5858
```
5959

6060
If God mode is activated through `god-mode` or `god-mode-all`, you might want to
6161
ensure that no buffers are skipped, as follows:
6262

6363
```emacs-lisp
64-
(setq god-exempt-major-modes nil)
65-
(setq god-exempt-predicates nil)
64+
(setopt god-exempt-major-modes nil)
65+
(setopt god-exempt-predicates nil)
6666
```
6767

6868
This means that `magit-mode` or `dired-mode`, for example, will also enter God
@@ -76,7 +76,7 @@ translated to <kbd>C-&lt;f5></kbd>. To disable this translation, you can set the
7676
mode, as follows:
7777

7878
``` emacs-lisp
79-
(setq god-mode-enable-function-key-translation nil)
79+
(setopt god-mode-enable-function-key-translation nil)
8080
(require 'god-mode)
8181
```
8282

@@ -240,8 +240,8 @@ You can load and activate this feature as follows:
240240

241241
```emacs-lisp
242242
(require 'god-mode-isearch)
243-
(define-key isearch-mode-map (kbd "<escape>") #'god-mode-isearch-activate)
244-
(define-key god-mode-isearch-map (kbd "<escape>") #'god-mode-isearch-disable)
243+
(keymap-set isearch-mode-map "escape>" #'god-mode-isearch-activate)
244+
(keymap-set god-mode-isearch-map "<escape>" #'god-mode-isearch-disable)
245245
```
246246

247247
You can also configure `god-mode-isearch-map` for additional keybindings.
@@ -259,7 +259,7 @@ mapping that calls `org-self-insert-command` in `org-mode`:
259259
(call-interactively 'org-self-insert-command)
260260
(call-interactively 'god-mode-self-insert)))
261261
262-
(define-key god-local-mode-map [remap self-insert-command] #'my-god-mode-self-insert)
262+
(keymap-set god-local-mode-map "<remap> <self-insert-command>" #'god-mode-self-insert)
263263
```
264264

265265
## Useful key bindings
@@ -268,37 +268,74 @@ For vim refugees, consider using `i` and `<escape>` to toggle god-mode off and
268268
on:
269269

270270
```emacs-lisp
271-
(define-key god-local-mode-map (kbd "i") #'god-local-mode)
272-
(global-set-key (kbd "<escape>") #'(lambda () (interactive) (god-local-mode 1)))
271+
(keymap-set god-local-mode-map "i" #'god-local-mode)
272+
(keymap-global-set "<escape>" #'(lambda () (interactive) (god-local-mode 1)))
273273
```
274274

275275
The following key binding is also popular:
276276

277277
```emacs-lisp
278-
(define-key god-local-mode-map (kbd "z") #'repeat)
278+
(keymap-set god-local-mode-map "z" #'repeat)
279279
```
280280

281281
Although I personally prefer:
282282

283283
```emacs-lisp
284-
(define-key god-local-mode-map (kbd ".") #'repeat)
284+
(keymap-set god-local-mode-map "." #'repeat)
285285
```
286286

287287
These are also handy:
288288

289289
```emacs-lisp
290-
(global-set-key (kbd "C-x C-1") #'delete-other-windows)
291-
(global-set-key (kbd "C-x C-2") #'split-window-below)
292-
(global-set-key (kbd "C-x C-3") #'split-window-right)
293-
(global-set-key (kbd "C-x C-0") #'delete-window)
290+
(keymap-global-set "C-x C-1" #'delete-other-windows)
291+
(keymap-global-set "C-x C-2" #'split-window-below)
292+
(keymap-global-set "C-x C-3" #'split-window-right)
293+
(keymap-global-set "C-x C-0" #'delete-window)
294294
295-
(define-key god-local-mode-map (kbd "[") #'backward-paragraph)
296-
(define-key god-local-mode-map (kbd "]") #'forward-paragraph)
295+
(keymap-set god-local-mode-map "[" #'backward-paragraph)
296+
(keymap-set god-local-mode-map "]" #'forward-paragraph)
297297
```
298298

299299
So that you can run <kbd>x</kbd> <kbd>1</kbd>, <kbd>x</kbd>
300300
<kbd>2</kbd>, <kbd>x</kbd> <kbd>3</kbd>, and <kbd>x</kbd> <kbd>0</kbd> in God mode.
301301

302+
## Setup with use-package
303+
You can also set all above customizations with following use-package:
304+
305+
```emacs-lisp
306+
(use-package god-mode ; uncomment anything you want to use
307+
:ensure t
308+
:config
309+
(require 'god-mode-isearch)
310+
;; :custom
311+
;; (god-exempt-major-modes nil)
312+
;; (god-exempt-predicates nil)
313+
;; (god-mode-enable-function-key-translation nil)
314+
;; :custom-face
315+
;; (god-mode-lighter ((t (:inherit error))))
316+
:bind (:map
317+
global-map
318+
("<escape>" . god-local-mode)
319+
;; ("<escape>" . god-mode-all)
320+
;; ("<escape>" . (lambda () (interactive) (god-local-mode 1)))
321+
;; ("i" . god-local-mode)
322+
;; ("." . repeat)
323+
;; ("C-x C-1" . delete-other-windows)
324+
;; ("C-x C-2" . split-window-below)
325+
;; ("C-x C-3" . split-window-right)
326+
;; ("C-x C-0" . delete-window)
327+
;; :map god-local-mode-map
328+
;; ("[" . backward-paragraph)
329+
;; ("]" . forward-paragraph)
330+
;; :map
331+
;; isearch-mode-map
332+
;; ("<escape>" . god-mode-isearch-activate)
333+
;; :map
334+
;; god-mode-isearch-map
335+
;; ("<escape>" . god-mode-isearch-disable)
336+
))
337+
```
338+
302339
## Exempt major modes
303340

304341
_NOTE_: This is less necessary in recent versions of God mode, as

0 commit comments

Comments
 (0)