-
Notifications
You must be signed in to change notification settings - Fork 4
/
fingers-neo.el
107 lines (94 loc) · 3.3 KB
/
fingers-neo.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
;;; fingers-neo.el --- Neo mapping for fingers.el
;; Copyright (c) 2014 Felix Geller
;; Author: Felix Geller <fgeller@gmail.com>
;; Keywords: fingers modal editing workman
;; URL: http://github.com/fgeller/fingers.el
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Sample mapping from Workman to Neo.
;;
;; Example for your configuration:
;;
;; (require 'fingers)
;; (require 'fingers-neo)
;; (setq fingers-keyboard-layout-mapper 'fingers-workman-to-neo)
;; (setq fingers-region-specifiers fingers-neo-region-specifiers)
;; (fingers-reset-bindings)
;; This currently maps bindings for the main `fingers-mode-map', not for
;; `fingers-mode-x-map' or `fingers-mode-c-map' which are mostly using default
;; Emacs bindings.
;;
(defvar fingers-neo-region-specifiers
'((char . ?z)
(char-and-whitespace . ?Z)
(line . ?O)
(line-rest . ?o)
(word . ?a)
(word-and-whitespace . ?A)
(symbol . ?e)
(symbol-and-whitespace . ?E)
(between-whitespace . ?p)
(with-surrounding-whitespace . ?P)
(inside-pair . ?i)
(with-pair . ?u)
(with-pair-and-whitespace . ?U))
"Region specifiers tuned for the Neo keyboard layout")
(defun fingers-workman-to-neo (keys)
(let ((workman-to-neo
(lambda (char)
(let* ((should-upcase (and
(or (and (>= char 65) (<= char 90))
(and (>= char 97) (<= char 122)))
(= (upcase char) char)))
(lower-char (downcase char))
(neo-char (cond ((= ?a lower-char) "u")
((= ?b lower-char) "w")
((= ?c lower-char) "p")
((= ?d lower-char) "v")
((= ?e lower-char) "r")
((= ?f lower-char) "h")
((= ?g lower-char) "o")
((= ?h lower-char) "a")
((= ?i lower-char) "d")
((= ?j lower-char) "k")
((= ?k lower-char) "b")
((= ?l lower-char) "m")
((= ?m lower-char) "ä")
((= ?n lower-char) "n")
((= ?o lower-char) "t")
((= ?p lower-char) "f")
((= ?q lower-char) "x")
((= ?r lower-char) "l")
((= ?s lower-char) "i")
((= ?t lower-char) "e")
((= ?u lower-char) "g")
((= ?v lower-char) "z")
((= ?w lower-char) "c")
((= ?x lower-char) "ö")
((= ?y lower-char) "s")
((= ?z lower-char) "ü")
((= ?\; lower-char) "q")
((= ?\/ lower-char) "j")
((= ?\[ lower-char) "ß")
((= ?\' lower-char) "y")
(t (string lower-char)))))
(cond ((and should-upcase (string= ";" neo-char)) ":")
(should-upcase (upcase neo-char))
(t neo-char))))))
(cond ((string= "SPC" keys) keys)
((string= "RET" keys) keys)
(t
(apply 'concat (mapcar workman-to-neo keys))))))
(provide 'fingers-neo)