]> code.delx.au - dotemacs/blob - init.el
SSH_AUTH_SOCK
[dotemacs] / init.el
1 ;;; -*- lexical-binding: t -*-
2
3 ;;;;;;;;;;;;;;;;
4 ;; Early init ;;
5 ;;;;;;;;;;;;;;;;
6
7 (let ((dir "~/.cache/emacs/eln-cache/"))
8 (unless (file-accessible-directory-p dir)
9 (make-directory dir))
10 (startup-redirect-eln-cache dir))
11
12 (let ((dir "~/.cache/emacs/saves/"))
13 (unless (file-accessible-directory-p dir)
14 (make-directory dir))
15 (setq auto-save-list-file-prefix dir))
16
17 (let ((dir "~/.cache/emacs/backups/"))
18 (unless (file-accessible-directory-p dir)
19 (make-directory dir))
20 (setq backup-directory-alist `(("." . ,dir))))
21
22 (setq save-place-file "~/.cache/emacs/places")
23
24 (setq project-list-file "~/.cache/emacs/projects")
25
26 (setq tramp-persistency-file-name "~/.cache/emacs/tramp")
27
28 ;;;;;;;;;;;;;;;;;;;;
29 ;; Visual options ;;
30 ;;;;;;;;;;;;;;;;;;;;
31
32 (load-file "~/.emacs.d/pastels-on-dark-theme.el")
33 (enable-theme 'pastels-on-dark)
34
35 (setq default-frame-alist '((vertical-scroll-bars . nil)
36 (menu-bar-lines . 0)
37 (tool-bar-lines . 0)
38 (background-mode . dark)
39 (alpha . 95)
40 (font . "monospace 12")))
41
42 (column-number-mode t)
43
44 (line-number-mode t)
45
46 (show-paren-mode t)
47
48 (setq-default show-trailing-whitespace t)
49
50 ;; 256-color mode in screen terminals
51 (add-to-list 'term-file-aliases
52 '("screen.xterm-256color" . "screen-256color"))
53
54 ;;;;;;;;;;;;;;;;;;;;;
55 ;; General options ;;
56 ;;;;;;;;;;;;;;;;;;;;;
57
58 (add-hook 'text-mode-hook #'goto-address-mode)
59 (add-hook 'prog-mode-hook #'goto-address-prog-mode)
60
61 (global-auto-revert-mode 1)
62 (setq global-auto-revert-non-file-buffers t)
63 (setq auto-revert-verbose nil)
64
65 (setq auto-save-interval 0)
66 (setq auto-save-timeout 30)
67
68 ;; backup files - keep 10 numbered backups
69 (setq backup-by-copying t)
70 (setq delete-old-versions t)
71 (setq kept-new-versions 10)
72 (setq kept-old-versions 0)
73 (setq vc-make-backup-files t)
74 (setq version-control t)
75
76 (setq create-lockfiles nil)
77
78 (delete-selection-mode t)
79
80 (setq disabled-command-function nil)
81
82 (setq ediff-window-setup-function 'ediff-setup-windows-plain
83 ediff-split-window-function 'split-window-horizontally)
84
85 (setq find-file-visit-truename t)
86
87 (setq help-window-select t)
88
89 (global-hl-line-mode 1)
90
91 (setq-default indent-tabs-mode nil)
92
93 (setq mouse-1-click-follows-link nil)
94
95 (setq mouse-wheel-scroll-amount '(3))
96 (setq mouse-wheel-progressive-speed nil)
97
98 (repeat-mode 1)
99
100 (setq-default require-final-newline t)
101
102 (setq save-interprogram-paste-before-kill t)
103
104 (save-place-mode 1)
105
106 (setq scroll-conservatively 1)
107 (setq scroll-margin 1)
108
109 (setq shift-select-mode nil)
110
111 (setq sentence-end-double-space nil)
112
113 (setq undo-limit 10000000)
114 (setq undo-strong-limit undo-limit)
115
116 ;; unique buffer names
117 (setq uniquify-strip-common-suffix t)
118 (setq uniquify-buffer-name-style 'post-forward)
119
120 (setq vc-follow-symlinks t)
121
122 (xterm-mouse-mode 1)
123
124 (defalias 'yes-or-no-p 'y-or-n-p)
125
126 ;;;;;;;;;;;;;;;;;
127 ;; Keybindings ;;
128 ;;;;;;;;;;;;;;;;;
129
130 (global-set-key (kbd "C-x f") 'project-find-file)
131
132 ;; Text formatting
133 (global-set-key (kbd "M-;") 'comment-line)
134 (global-set-key (kbd "C-c d") 'duplicate-dwim)
135 (global-set-key (kbd "M-z") 'zap-up-to-char)
136 (global-set-key (kbd "C-c k") 'kill-whole-line)
137
138 ;; Windows/frames
139 (global-set-key (kbd "<C-up>") 'windmove-up)
140 (global-set-key (kbd "<C-down>") 'windmove-down)
141 (global-set-key (kbd "<C-left>") 'windmove-left)
142 (global-set-key (kbd "<C-right>") 'windmove-right)
143
144 ;; Mode switching
145 (global-set-key (kbd "<f7>") 'flymake-mode)
146 (global-set-key (kbd "<f8>") 'flyspell-mode)
147 (global-set-key (kbd "<f9>") 'whitespace-mode)
148 (global-set-key (kbd "<f10>") 'toggle-truncate-lines)
149
150 ;; Disable some default bindings from the builtin mouse.el
151 (global-set-key [C-down-mouse-1] nil)
152 (global-set-key [C-down-mouse-2] nil)
153 (global-set-key [C-down-mouse-3] nil)
154 (global-set-key [S-down-mouse-1] nil)
155 (global-set-key [S-down-mouse-2] nil)
156 (global-set-key [S-down-mouse-3] nil)
157
158 ;; Disable suspend-frame, it's annoying
159 (global-set-key (kbd "C-z") nil)
160 (global-set-key (kbd "C-x C-z") nil)
161
162 ;;;;;;;;;;;;;;;;;;;;;;;;
163 ;; Find SSH_AUTH_SOCK ;;
164 ;;;;;;;;;;;;;;;;;;;;;;;;
165
166 (dolist (p '("keyring/ssh" "gcr/ssh" "openssh_agent"))
167 (let ((SSH_AUTH_SOCK (substitute-env-vars (concat "$XDG_RUNTIME_DIR/" p))))
168 (when (file-exists-p SSH_AUTH_SOCK)
169 (message "Found SSH_AUTH_SOCK %s" SSH_AUTH_SOCK)
170 (setenv "SSH_AUTH_SOCK" SSH_AUTH_SOCK))))
171
172 ;;;;;;;;;;;;;;;;;;;
173 ;; Load packages ;;
174 ;;;;;;;;;;;;;;;;;;;
175
176 (defvar my/original-load-path load-path)
177
178 (defun my/reset-load-path ()
179 (setq load-path my/original-load-path))
180
181 (message "Loading packages...")
182 (load-file "~/.emacs.d/utils/init.el")
183 (load-file "~/.emacs.d/completion/init.el")
184 (load-file "~/.emacs.d/text-edit/init.el")
185 (load-file "~/.emacs.d/file-modes/init.el")
186 (load-file "~/.emacs.d/vc/init.el")
187 (message "Finished loading init.el")