Skip to content

Commit

Permalink
Adding colemak keyboard layout option to keyboard-layout
Browse files Browse the repository at this point in the history
- Base Remapping Keys

`#{n, e, i, o}` <=> `#{h, j, k, l}`

- setting `avy` keys to the `colemak` home row keys

`#{a, r, s, t, n, e, i, o}`

- adjusting leader key to `tn`

- overriding evil org mode bindings especially for 'o'

- one character key guess rebindings can give back empty string
when looking for the prefix and it isn't empty, then guess the rebindings --
this fix lets the check not pass and return `'(nil nil)`, allowing the
`(remove-if #'null)` to actually work.

- correcting magit staging when using visual line
  • Loading branch information
scubacabra authored and syl20bnr committed Apr 17, 2017
1 parent 7554aff commit 4461721
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
12 changes: 12 additions & 0 deletions layers/+intl/keyboard-layout/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- [[#keyboard-layouts][Keyboard layouts]]
- [[#bepo][bepo]]
- [[#dvorak][dvorak]]
- [[#colemak][colemak]]
- [[#remapped-keys][Remapped Keys]]
- [[#package-configurations][Package Configurations]]
- [[#keybindings][Keybindings]]
- [[#sources][Sources]]
Expand Down Expand Up @@ -148,6 +150,16 @@ will remap keybindings for the =dvorak-programmer= variant.

[[file:img/dvorak-keymap.png]]

** colemak
=colemak= is a keyboard layout designed for touch typing in English.

[[file:img/colemak-layout.png]]

*** Remapped Keys

- ~avy~ and ~ace-window~ keys are remapped to the ~colemak~ home row
- ~evil-leader~ is also remapped to ~tn~

* Package Configurations
The available configurations are:

Expand Down
11 changes: 10 additions & 1 deletion layers/+intl/keyboard-layout/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
;;------------------------------------------------------------------------------

(defvar kl-layout 'dvorak
"The keyboard-layout to use. Possible values are `dvorak' and `bepo'.")
"The keyboard-layout to use. Possible values are `colemak', `dvorak' and `bepo'.")

(defvar kl-enabled-configurations nil
"If non nil, `keyboard-layout' will enable configurations only
Expand All @@ -41,6 +41,15 @@ any case.")
("j" . "t")
("k" . "s")
("l" . "c")))
(colemak . (("n" . "h")
("e" . "j")
("i" . "k")
("o" . "l")
;;
("h" . "n")
("j" . "e")
("k" . "i")
("l" . "o")))
(dvorak . (("h" . "h")
("t" . "j")
("n" . "k")
Expand Down
5 changes: 3 additions & 2 deletions layers/+intl/keyboard-layout/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
(mapcar
(lambda (modifier)
(cons (concat modifier key1) (concat modifier key2)))
'("" "C-" "M-" "C-S-")))))
'("C-" "M-" "C-S-")))))
basemap))

(defun kl//define-key (maps key def bindings)
Expand Down Expand Up @@ -81,7 +81,8 @@ key."
(let* ((key2 (cdr (assoc key1 rebinding-map)))
(bind1 (assoc key1 rebinding-map))
(bind2 (assoc key2 rebinding-map)))
(when prefix
(when (and prefix
(not (string-empty-p prefix)))
(defun kl//guess-prefixit (bind)
`(,(concat prefix (car bind)) . ,(concat prefix (cdr bind))))
(setq bind1 (kl//guess-prefixit bind1))
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 27 additions & 7 deletions layers/+intl/keyboard-layout/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
(spacemacs|use-package-add-hook ace-window :post-init BODY)
:bepo
(setq aw-keys '(?a ?u ?i ?e ?t ?s ?r ?n))
:colemak
(setq aw-keys '(?a ?r ?s ?t ?n ?e ?i ?o))
:dvorak
(setq aw-keys '(?a ?o ?e ?u ?h ?t ?n ?s))))

Expand All @@ -53,6 +55,8 @@
(spacemacs|use-package-add-hook avy :post-init BODY)
:bepo
(setq-default avy-keys '(?a ?u ?i ?e ?t ?s ?r ?n))
:colemak
(setq-default avy-keys '(?a ?r ?s ?t ?n ?e ?i ?o))
:dvorak
(setq-default avy-keys '(?a ?o ?e ?u ?h ?t ?n ?s))))

Expand Down Expand Up @@ -171,7 +175,9 @@
:loader
(spacemacs|use-package-add-hook evil-escape :post-init BODY)
:bepo
(setq-default evil-escape-key-sequence "gq")))
(setq-default evil-escape-key-sequence "gq")
:colemak
(setq-default evil-escape-key-sequence "tn")))

(defun keyboard-layout/pre-init-evil-evilified-state ()
(kl|config evil-evilified-state
Expand Down Expand Up @@ -308,11 +314,14 @@
(spacemacs|use-package-add-hook magit :post-config BODY)
:common
(progn
(kl/evil-correct-keys evil-magit-state magit-mode-map
"j"
"k"
"C-j"
"C-k")
(dolist (state (if evil-magit-use-y-for-yank
(list evil-magit-state 'visual)
(list evil-magit-state)))
(kl/evil-correct-keys state magit-mode-map
"j"
"k"
"C-j"
"C-k"))
(kl/evil-correct-keys 'normal evil-magit-toggle-text-minor-mode-map
"C-j")
(dolist (map (list magit-branch-section-map
Expand Down Expand Up @@ -436,7 +445,18 @@
"gk" nil
;; additional
(kbd "«") 'org-metaleft
(kbd "»") 'org-metaright))))
(kbd "»") 'org-metaright))
:colemak
(progn
(spacemacs|use-package-add-hook evil-org
:post-config
(progn
(evil-define-key 'normal evil-org-mode-map
"O" 'org-forward-heading-same-level
"o" 'evil-forward-char
"E" 'org-forward-element
"I" 'org-backward-element
"N" 'org-backward-heading-same-level))))))

(defun keyboard-layout/pre-init-org-agenda ()
(kl|config org-agenda
Expand Down

0 comments on commit 4461721

Please sign in to comment.