-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmini4.el
415 lines (354 loc) · 14.2 KB
/
mini4.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
;; Minimal Emacs v4.0
;; ===========================================================================
;; ===========================================================================
;; Unclutter startup
;; ===========================================================================
(setq inhibit-startup-message t)
(setq cursor-type 'bar)
(menu-bar-mode -1)
(if (display-graphic-p)
(progn
(tool-bar-mode -1)
(scroll-bar-mode -1))
nil
)
;; ===========================================================================
;; Open full frame
;; https://emacs.stackexchange.com/questions/2350/how-to-toggle-fullscreen-in-emacs-gui-mode-full-screen-option-is-greyed-out-i
;; <f11> toggle-frame-fullscreen
;; M-<f10> toggle-frame-maximized
;; ===========================================================================
(toggle-frame-fullscreen)
;; ===========================================================================
;; Set base font
;; https://stackoverflow.com/questions/6026713/how-do-i-change-emacs-default-font-size-and-font-type
;; ===========================================================================
(set-face-attribute 'default nil :font "Iosevka" :height 160)
;; ===========================================================================
;; Set centralized back up
;; ===========================================================================
(if (file-directory-p "~/.emacs.d/backup")
(setq backup-directory-alist '(("." . "~/.emacs.d/backup")))
(message "Directory does not exist: ~/.emacs.d/backup"))
(defvar user-temporary-file-directory
(concat temporary-file-directory user-login-name "/"))
(make-directory user-temporary-file-directory t)
(setq backup-by-copying t)
(setq backup-directory-alist
`(("." . ,user-temporary-file-directory)
(,tramp-file-name-regexp nil)))
(setq auto-save-list-file-prefix
(concat user-temporary-file-directory ".auto-saves-"))
(setq auto-save-file-name-transforms
`((".*" ,user-temporary-file-directory t)))
;; ===========================================================================
;; Use the Trash instead of rm
;; https://ashok-khanna.medium.com/introduction-to-dired-mode-91cecd3a06ff
;; ===========================================================================
(if (eq system-type 'darwin)
(setq trash-directory "~/.Trash"))
;; ===========================================================================
;; Set line numbers
;; ===========================================================================
(setq display-line-numbers-width-start '5)
(setq display-line-numbers-type 'visual)
(setq display-line-numbers 'relative)
;; Always display line numbers
(global-display-line-numbers-mode)
;; Make the current line number more apparent
(set-face-attribute 'line-number-current-line nil :foreground "#ECEFF4")
;; ===========================================================================
;; Misc Properties
;; ===========================================================================
;; Automatically follow sumbolic links
;; My config files are all symlinks. This faciliates opening those files
;; ...................................
(setq vc-follow-symlinks t)
;; recentf mode
;; List of rencently opened files
;; Use: consult-recent-file
;; ...................................
(recentf-mode 1)
;; Clean up when saving
;; ...................................
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; ===========================================================================
;; parenthesis
;; ===========================================================================
(electric-pair-mode t)
;; ===========================================================================
;; mark
;; ===========================================================================
(delete-selection-mode 1)
;; ===========================================================================
;; save a recent files list
;; ===========================================================================
(recentf-mode t)
;; Highlight current line
;; Set colors using Nord https://www.nordtheme.com
;; ..............................................
(global-hl-line-mode 1)
;; Show fill line
;; This is set in conjunction with visual-fill-column mode
(setq-default fill-column 80)
(global-display-fill-column-indicator-mode 1)
(auto-fill-mode 1)
;; set pdf resolution
;; ..............................................
(setq doc-view-resolution 220)
;; Enable transparent encryption
;; https://orgmode.org/worg/org-tutorials/encrypting-files.html
;; ..............................................
;;(require 'epa-file)
(epa-file-enable)
;; https://colinxy.github.io/software-installation/2016/09/24/emacs25-easypg-issue.html
;; If this line is not there, you get error: "inappropriate ioctl for device"
(setq epa-pinentry-mode 'loopback)
;; ===========================================================================
;; Set mode-line
;; ===========================================================================
;; Date Time in mode-line
(setq display-time-format "[%Y-%m-%d %a %H:%M]")
(setq display-time-default-load-average nil)
(display-time-mode 1)
;; Clean out misc info
;;https://emacs.stackexchange.com/questions/13855/how-to-append-string-that-gets-updated-to-mode-line
(setq-default mode-line-misc-info "")
;; Left and right justified mode-line
;; https://emacs.stackexchange.com/questions/5529/how-to-right-align-some-items-in-the-modeline
(defun simple-mode-line-render (left right)
"Return a string of `window-width' length.
Containing LEFT, and RIGHT aligned respectively."
(let ((available-width
(- (window-total-width)
(+ (length (format-mode-line left))
(length (format-mode-line right))))))
(append left
(list (format (format "%%%ds" available-width) ""))
right)))
(setq-default
mode-line-format
'((:eval
(simple-mode-line-render
;; Left.
(quote (" "
mode-line-modified
;; full path name: buffer-file-name
;; just the filename: " %b "
buffer-file-name
;; major mode
" ["
mode-name
mode-line-process
"%n"
"] "
))
;; Right.
(quote (" "
display-time-string
))))))
;; ===========================================================================
;; Package manager: straight.el
;; https://jeffkreeftmeijer.com/emacs-straight-use-package/
;; ===========================================================================
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; --------------------------------------------------------------------------
(setq package-enable-at-startup nil)
(setq find-file-visit-truename nil)
;; ===========================================================================
;; Install use-package
;; ===========================================================================
(straight-use-package 'use-package)
;; Configure use-package to use straight.el by default
(use-package straight
:custom
(straight-use-package-by-default t))
;; ===========================================================================
;; org-mode
;; ===========================================================================
;; Use updated org-mode package
;; - required by org-roam
;; - This must be invoked BEFORE any org-babel-load-files occur
;; or emacs will report a version conflict
;; ---------------------------------------------------------------------------
(straight-use-package 'org)
(use-package org
:init
(setq
org-log-into-drawer t
org-use-speed-commands t
)
:config
(add-hook 'org-mode-hook 'org-indent-mode)
)
;; org-roam
;; ---------------------------------------------------------------------------
(straight-use-package 'org-roam)
(use-package org-roam
:init
(setq org-roam-directory (file-truename "~/Notebook/org-roam"))
:config
)
;; org-noter
;; ---------------------------------------------------------------------------
(straight-use-package 'org-noter)
;; org-mode custom code
;; ---------------------------------------------------------------------------
(org-babel-load-file (expand-file-name "~/Config/dotEmacsV4/babel/orgMode.org"))
(org-babel-load-file (expand-file-name "~/Config/dotEmacsV4/babel/org-jrnl.org"))
;; ===========================================================================
;; Themes
;; ===========================================================================
;; https://protesilaos.com/emacs/ef-themes
;; ---------------------------------------------------------------------------
(straight-use-package 'ef-themes)
;;(use-package ef-themes
;; :init
;; (setq ef-themes-to-toggle '(ef-duo-dark ef-duo-light))
;; :config
;; (load-theme 'ef-duo-dark :no-confirm))
;; https://protesilaos.com/emacs/modus-themes
;; modus is built into emacs as of 28.1
;; ---------------------------------------------------------------------------
;;; For the built-in themes which cannot use `require'.
(require-theme 'modus-themes)
;; Add all your customizations prior to loading the themes.
(setq modus-themes-italic-constructs t
modus-themes-bold-constructs nil)
;; Load the theme of your choice.
(load-theme 'modus-vivendi)
;; Optionally define a key to switch between Modus themes. Also check
;; the user option `modus-themes-to-toggle'.
(define-key global-map (kbd "<f5>") #'modus-themes-toggle)
;; ===========================================================================
;; Customize theme components
;; Note: do this after setting the theme
;; ===========================================================================
(setq-default cursor-type 'bar)
(set-cursor-color "#ff0000")
(set-face-attribute 'fringe nil :background nil)
;; ===========================================================================
;; Install global packages
;; ===========================================================================
;; try
;; temporarily install a package for testing
;; ---------------------------------------------------------------------------
(straight-use-package 'try)
;; vertico
;; single column mini-buffer
;; ---------------------------------------------------------------------------
(straight-use-package 'vertico)
(use-package vertico
:config
(vertico-mode t))
;; orderless
;; mini-buffer regex search tokens in any order
;; ---------------------------------------------------------------------------
(straight-use-package 'orderless)
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
;; marginalia
;; adds notes to mini-buffer items
;; ---------------------------------------------------------------------------
(straight-use-package 'marginalia)
(use-package marginalia
;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding
;; available in the *Completions* buffer, add it to the
;; `completion-list-mode-map'.
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
;; The :init section is always executed.
:init
;; Marginalia must be activated in the :init section of use-package such that
;; the mode gets enabled right away. Note that this forces loading the
;; package.
(marginalia-mode))
;; consult
;; mini-buffer preview
;; ---------------------------------------------------------------------------
(straight-use-package 'consult)
(use-package consult
:bind
(("M-s" . consult-line)
:map ctl-x-map ("b" . consult-buffer))
)
;; visual-fill-column
;; center text, use to create a minimistic UI
;; ---------------------------------------------------------------------------
(straight-use-package 'visual-fill-column)
(use-package visual-fill-column
:bind
("<f12>" . visual-fill-column-mode)
:init
(setq-default visual-fill-column-center-text t)
;; add padding for display-fill-column-indicator-column
(setq-default visual-fill-column-extra-text-width (cons '3 3))
)
;; dired-preview
;; https://protesilaos.com/emacs/dired-preview
;; ---------------------------------------------------------------------------
(straight-use-package 'dired-preview)
(use-package dired-preview
:init
;; preview dealy of 0.0 causes emacs to flicker
(setq dired-preview-delay 0.25)
(setq dired-preview-max-size (expt 2 20))
(setq dired-preview-ignored-extensions-regexp
(concat "\\."
"\\(mkv\\|webm\\|mp4\\|mp3\\|ogg\\|m4a"
"\\|gz\\|zst\\|tar\\|xz\\|rar\\|zip"
"\\|iso\\|epub\\|pdf\\)"))
:config
;; Enable `dired-preview-mode' in a given Dired buffer or do it
;; globally:
(dired-preview-global-mode 1)
)
;; dired-hacks
;; dependencies: f.el
;; https://github.com/Fuco1/dired-hacks
;; See also https://www.youtube.com/watch?v=vm-FvNdYFcc
;; ---------------------------------------------------------------------------
(straight-use-package 'f)
(straight-use-package 'dired-hacks)
(use-package dired-hacks
:bind (:map dired-mode-map
("<tab>" . dired-subtree-toggle))
)
;; nov - emacs ePub reader
;; dependencies: esxml.el
;; https://tech.toryanderson.com/2022/11/23/viewing-epub-in-emacs/
;; https://depp.brause.cc/nov.el/
;; ---------------------------------------------------------------------------
(straight-use-package 'esxml)
(straight-use-package 'nov)
(use-package nov
:init
(setq nov-text-width 80)
(setq nov-text-width t)
:config
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
(add-hook 'nov-mode-hook 'visual-line-mode)
(add-hook 'nov-mode-hook 'visual-fill-column-mode)
)
;; ===========================================================================
;; Babel configuration code
;; ===========================================================================
(org-babel-load-file (expand-file-name "~/Config/dotEmacsV4/babel/osxKeyBindings.org"))
(org-babel-load-file (expand-file-name "~/Config/dotEmacsV4/babel/diredMode.org"))