-
Notifications
You must be signed in to change notification settings - Fork 0
/
handy-mode.el
80 lines (66 loc) · 2.69 KB
/
handy-mode.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
;;; handy-mode.el --- handy-mode
;; Copyright (C) 2015-2019 David Capello
;;
;; Author: David Capello <davidcapello@gmail.com>
;; Maintainer: David Capello
(defgroup handy-mode nil
"Customization group for handy-mode."
:package-version '(handy-mode . "0.1")
:group 'local
:prefix 'handy-)
(load (concat (file-name-directory load-file-name) "handy-vars.el"))
(load (concat (file-name-directory load-file-name) "handy-funs.el"))
(load (concat (file-name-directory load-file-name) "handy-mode-jlik.el"))
(load (concat (file-name-directory load-file-name) "handy-mode-nm.el"))
(load (concat (file-name-directory load-file-name) "handy-mode-uo.el"))
(load (concat (file-name-directory load-file-name) "handy-mode-zb.el"))
(load (concat (file-name-directory load-file-name) "handy-mode-yh.el"))
(load (concat (file-name-directory load-file-name) "handy-mode-werd.el"))
(load (concat (file-name-directory load-file-name) "handy-mode-modal.el"))
(defvar handy-level--installed -1
"Internal variable used to store the current `handy-level' when
`handy-mode' is enabled.")
(defvar handy-mode-all-modes
[handy-mode-jlik ; Level 1
handy-mode-nm ; Level 2
handy-mode-uo ; Level 3
handy-mode-zb ; Level 4
handy-mode-yh ; Level 5
handy-mode-werd ; Level 6
handy-mode-modal] ; Level 7
"List of modes ordered by `handy-level' used by
`handy-mode' to know in which order and what modes
it should enable/disable for each level.")
(define-minor-mode handy-mode
"Handy keyboard bindings.
You can change your current `handy-level' using `handy-switch-level'
command so you can start using handy-mode progressively. E.g. To start
in the first level:
M-x handy-switch-level
And then choose level interactively pressing key 1, or you can
just execute the following expression:
(handy-switch-level 1)
"
:global t
:version "0.1"
:lighter " handy"
:group 'handy-mode
(let (i level)
(if handy-mode
(progn
;; installing handy-mode
(message "handy-mode level %d enabled" handy-level)
(setq i 1)
(while (<= i handy-level)
(funcall (aref handy-mode-all-modes (- i 1)) 1)
(setq i (+ i 1)))
(setq handy-level--installed handy-level))
;; removing handy-mode
(message (format "handy-mode level %d disabled" handy-level--installed))
(setq i handy-level--installed)
(while (> i 0)
(funcall (aref handy-mode-all-modes (- i 1)) 0)
(setq i (- i 1)))
(setq level handy-level--installed)
(setq handy-level--installed -1))))
(provide 'handy-mode)