forked from syl20bnr/spacemacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextensions.el
194 lines (174 loc) · 6.65 KB
/
extensions.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
;;; extensions.el --- Spacemacs Layer extensions File
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;; Extensions are in emacs_paths/extensions
;; Pre extensions are loaded *before* the packages
(setq spacemacs-pre-extensions
'(
evil-evilified-state
holy-mode
))
;; Post extensions are loaded *after* the packages
(setq spacemacs-post-extensions
'(
centered-cursor
helm-spacemacs
solarized-theme
spray
zoom-frm
;; hack to be able to wrap built-in emacs modes in an init function
emacs-builtin-process-menu
))
;; use the last 24.3 compatible version of paradox as
;; an extension.
;; There is no corresponding init-paradox function here
;; the init-paradox from packages.el will be called
;; automatically.
(when (version< emacs-version "24.4")
(push 'paradox spacemacs-post-extensions))
;; Initialize the extensions
(defun spacemacs/init-evil-evilified-state ()
(require 'evil-evilified-state))
(defun spacemacs/init-centered-cursor ()
(use-package centered-cursor-mode
:commands (centered-cursor-mode
global-centered-cursor-mode)
:init
(progn
(spacemacs|add-toggle centered-point
:status centered-cursor-mode
:on (centered-cursor-mode)
:off (centered-cursor-mode -1)
:documentation
"Keep point always at the center of the window."
:evil-leader "t-")
(spacemacs|add-toggle centered-point-globally
:status centered-cursor-mode
:on (global-centered-cursor-mode)
:off (global-centered-cursor-mode -1)
:documentation
"Globally keep point always at the center of the window."
:evil-leader "t C--"))
:config
(progn
(custom-set-variables
'(ccm-recenter-at-end-of-file t)
'(ccm-ignored-commands (quote (mouse-drag-region
mouse-set-point
widget-button-click
scroll-bar-toolkit-scroll
evil-mouse-drag-region))))
(spacemacs|diminish centered-cursor-mode " ⊝" " -"))))
(defun spacemacs/init-holy-mode ()
(use-package holy-mode
:commands holy-mode
:init
(progn
(when (eq 'emacs dotspacemacs-editing-style)
(holy-mode))
(spacemacs|add-toggle holy-mode
:status holy-mode
:on (holy-mode)
:off (holy-mode -1)
:documentation "Globally toggle the holy mode."
:evil-leader "P <tab>" "P C-i"))))
(defun spacemacs/init-helm-spacemacs ()
(use-package helm-spacemacs
:commands helm-spacemacs
:init
(evil-leader/set-key "feh" 'helm-spacemacs)))
(defun spacemacs/init-revive ()
(use-package revive
:disabled t
:init
(require 'revive-mode-config)
:config
(progn
;; save and restore layout
(add-hook 'kill-emacs-hook 'emacs-save-layout)
(add-hook 'after-init-hook 'emacs-load-layout t))))
(defun spacemacs/init-spray ()
(use-package spray
:commands spray-mode
:init
(progn
(defun spacemacs/start-spray ()
"Start spray speed reading on current buffer at current point."
(interactive)
(evil-insert-state)
(spray-mode t)
(evil-insert-state-cursor-hide))
(evil-leader/set-key "asr" 'spacemacs/start-spray)
(defadvice spray-quit (after spacemacs//quit-spray activate)
"Correctly quit spray."
(set-default-evil-insert-state-cursor)
(evil-normal-state)))
:config
(progn
(define-key spray-mode-map (kbd "h") 'spray-backward-word)
(define-key spray-mode-map (kbd "l") 'spray-forward-word)
(define-key spray-mode-map (kbd "q") 'spray-quit))))
(defun spacemacs/init-solarized-theme ()
(use-package solarized
:init
(progn
(deftheme solarized-dark "The dark variant of the Solarized colour theme")
(deftheme solarized-light "The light variant of the Solarized colour theme"))))
(defun spacemacs/init-zoom-frm ()
(use-package zoom-frm
:commands (zoom-frm-unzoom
zoom-frm-out
zoom-frm-in)
:init
(progn
(spacemacs|define-micro-state zoom-frm
:doc "[+] zoom frame in [-] zoom frame out [=] reset zoom"
:evil-leader "zf"
:use-minibuffer t
:bindings
("+" spacemacs/zoom-frm-in :post (spacemacs//zoom-frm-powerline-reset))
("-" spacemacs/zoom-frm-out :post (spacemacs//zoom-frm-powerline-reset))
("=" spacemacs/zoom-frm-unzoom :post (spacemacs//zoom-frm-powerline-reset)))
(defun spacemacs//zoom-frm-powerline-reset ()
(when (fboundp 'powerline-reset)
(setq-default powerline-height (spacemacs/compute-powerline-height))
(powerline-reset)))
(defun spacemacs//zoom-frm-do (arg)
"Perform a zoom action depending on ARG value."
(let ((zoom-action (cond ((eq arg 0) 'zoom-frm-unzoom)
((< arg 0) 'zoom-frm-out)
((> arg 0) 'zoom-frm-in)))
(fm (cdr (assoc 'fullscreen (frame-parameters))))
(fwp (* (frame-char-width) (frame-width)))
(fhp (* (frame-char-height) (frame-height))))
(when (equal fm 'maximized)
(toggle-frame-maximized))
(funcall zoom-action)
(set-frame-size nil fwp fhp t)
(when (equal fm 'maximized)
(toggle-frame-maximized))))
(defun spacemacs/zoom-frm-in ()
"zoom in frame, but keep the same pixel size"
(interactive)
(spacemacs//zoom-frm-do 1))
(defun spacemacs/zoom-frm-out ()
"zoom out frame, but keep the same pixel size"
(interactive)
(spacemacs//zoom-frm-do -1))
(defun spacemacs/zoom-frm-unzoom ()
"Unzoom current frame, keeping the same pixel size"
(interactive)
(spacemacs//zoom-frm-do 0))
;; Font size, either with ctrl + mouse wheel
(global-set-key (kbd "<C-wheel-up>") 'spacemacs/zoom-frm-in)
(global-set-key (kbd "<C-wheel-down>") 'spacemacs/zoom-frm-out))))
(defun spacemacs/init-emacs-builtin-process-menu ()
(evilify process-menu-mode process-menu-mode-map))