-
Notifications
You must be signed in to change notification settings - Fork 1
/
my-display.el
270 lines (219 loc) · 7.38 KB
/
my-display.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
;;; my-display --- Changes to how Emacs looks
;;
;; Copyright (C) 2014 Alex Bennée
;;
;; Author: Alex Bennée <[email protected]>
;;
;; 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.
;;
;;; Commentary:
;;
;; Mostly we are disabling elements but there is some eye-candy here
;;
;;; Code:
;; Require prerequisites
(require 'use-package)
(require 'my-vars)
(require 'my-libs)
;;; Display hacks
;
; With --daemon mode using start-up evaluation is no longer useful as
; the .emacs will almost certainly run without window-system meaning
; anything. Instead we should do things on the fly as new frames are
; created.
;; Disable the menu and tool bars, they just take up space.
(use-package menu-bar
:commands menu-bar-mode
:init (menu-bar-mode -1))
(use-package tool-bar
:commands tool-bar-mode
:init (tool-bar-mode -1))
(use-package scroll-bar
:commands scroll-bar-mode
:init (scroll-bar-mode -1))
;; Use imagemagick if we have it to view images
(use-package image
:if (getenv "DISPLAY")
:commands imagemagick-register-types
:init (imagemagick-register-types))
(use-package image-file
:if (getenv "DISPLAY")
:init (auto-image-file-mode 1))
;; Tweaks for terminals
(use-package faces
:config (add-to-list 'term-file-aliases '("foot" . "xterm")))
;;
;; The easiest solution is to locally install one of the Nerd Fonts
;; from https://www.nerdfonts.com/ where you can get fonts that have
;; been pimped out with the rest of the unicode space. Otherwise we
;; let unicode-fonts try and do its thing.
;;
(if (--filter (s-prefix-p "DejaVuSansM Nerd Font" it)
(font-family-list))
(set-face-attribute 'default nil
:family "DejaVuSansM Nerd Font"
:height 150
:weight 'normal
:width 'normal)
(use-package unicode-fonts
:ensure t
:if (and (getenv "DISPLAY") (locate-library "unicode-fonts"))
:config (unicode-fonts-setup))
(set-face-attribute 'default nil
:family "DejaVu Sans Mono"
:height 145
:weight 'normal
:width 'normal))
(use-package frame
:config (setq default-frame-alist '((fullscreen . 'fullboth)
(vertical-scroll-bars))
frame-background-mode 'dark))
(use-package nerd-icons
:config (setq nerd-icons-font-family "DejaVuSansM Nerd Font"))
;; Prettier unique buffer names.
(use-package uniquify
:config
(setq uniquify-buffer-name-style 'post-forward-angle-brackets))
;; Mouse set-up
;
; I don't use the mouse for a lot of things and on my netbook it
; positively gets in the way. Really it is only used for links and the
; occasional scroll of the buffer.
;; Stop the mouse cursor getting in the way. This is great.
(use-package avoid
:if window-system
:defer 60
:config
(mouse-avoidance-mode 'exile))
;; enable the mouse wheel
(use-package mwheel
:if window-system
:commands mwheel-install
:init (mwheel-install))
; X11 paste to point
(when (boundp 'mouse-yank-at-point)
(setq mouse-yank-at-point t))
;; Change the cursor colour in Ovwrt mode
(defun ins-cursor-set ()
"Set cursor colour according to insert mode."
(set-cursor-color
(if overwrite-mode
"red"
"grey")))
(use-package simple
:config
(add-hook 'overwrite-mode-hook 'ins-cursor-set))
(if I-am-emacs-21+
(blink-cursor-mode -1))
(setq frame-title-format "%b")
(setq icon-title-format "%b")
(defun my-flash-modeline ()
"Flash the modeline."
(let ((orig-fg (face-foreground 'mode-line)))
(set-face-foreground 'mode-line "#F2804F")
(run-with-idle-timer
0.1 nil
(lambda (fg)
(set-face-foreground 'mode-line fg))
orig-fg)))
(setq cursor-type 'box
visible-bell t
ring-bell-function 'my-flash-modeline)
;; Make fill do the Right Thing with full-stops.
(setq sentence-end-double-space nil)
;; Highlights region _all_ the time. Slightly buggy...
(transient-mark-mode t)
(delete-selection-mode 1)
;; Tweaks to scrolling behaviour. Still a bit odd.
(setq scroll-preserve-screen-position t
scroll-conservatively 5
scroll-step 1
next-line-add-newlines nil)
;; Make pound signs work
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-language-environment 'utf-8)
;(setq unibyte-display-via-language-environment t)
;; Allow narrowing.
(put 'narrow-to-region 'disabled nil)
(global-set-key (kbd "C-x n r") 'narrow-to-region)
(defun my-persist-theme (&optional frame)
"Persist the current theme"
(when custom-enabled-themes
(load-theme (car custom-enabled-themes) t)))
(add-hook 'after-make-frame-functions 'my-persist-theme)
(message "Done Display Hacks")
;; I hate tabs - they are set in cc-mode but not everything respects that
(setq-default indent-tabs-mode nil)
(setq tab-always-indent 'complete)
;; Whitespace mode
(use-package whitespace
:commands whitespace-mode
:config
(setq whitespace-style '(face
tabs trailing lines-tail empty
space-after-tab tab-mark)))
;; WIP: what I want is to be able to re-size without being locked to
;; the golden ratio
(defun my-shrink-window-horizontally (delta)
"Temporarily disable golden-ratio before shrinking window."
(interactive "p")
(if (not golden-ratio-mode)
(shrink-window-horizontally delta)
(golden-ratio-mode -1)
(shrink-window-horizontally delta)))
;; (defadvice shrink-window
;; (before disable-golden-ratio)
;; "Disable golden ratio before changing window size."
;; (golden-ratio -1))
;; (defadvice enlarge-window
;; (before disable-golden-ratio)
;; "Disable golden ratio before changing window size."
;; (golden-ratio -1))
(defun my-ediff-comparison-buffer-p ()
"Safely check if in an ediff session"
(and (boundp 'ediff-this-buffer-ediff-sessions)
ediff-this-buffer-ediff-sessions))
;; Nice window sizing
(use-package golden-ratio
:ensure t
:commands (golden-ratio-mode)
:defer 30
:config (setq golden-ratio-exclude-modes '("mu4e-headers-mode"
"mu4e-view-mode"
"gnus-summary-mode"
"ediff-mode"
reb-lisp-mode)
golden-ratio-inhibit-functions
#'my-ediff-comparison-buffer-p)
(add-to-list 'golden-ratio-extra-commands 'ace-window)
:init (golden-ratio-mode))
;; Manual colour themes
(setq custom-safe-themes
'("84d2f9eeb3f82d619ca4bfffe5f157282f4779732f48a5ac1484d94d5ff5b279"
"c74e83f8aa4c78a121b52146eadb792c9facc5b1f02c917e3dbb454fca931223"
"3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" default))
(use-package facemenu
:commands list-colors-display)
(use-package moe-theme
:ensure t
:commands moe-dark
:init (when window-system
(moe-dark)))
(use-package gruvbox-theme
:ensure t
:init (when (not window-system)
(load-theme 'gruvbox t)))
(use-package zenburn-theme
:ensure t)
(use-package solarized-theme
:ensure t)
(provide 'my-display)
;;; my-display.el ends here