-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.emacs
167 lines (142 loc) · 5.08 KB
/
.emacs
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
;;; 1. Presonal Preferences
;; These settings should work in all versions of emacs
;; package.el will insert this, but I call it from init.el
;; (package-initialize)
;; UI
(when (display-graphic-p)
(tool-bar-mode -1)
(scroll-bar-mode -1))
(tooltip-mode -1)
(menu-bar-mode -1)
(if (<= 26 emacs-major-version)
(global-display-line-numbers-mode t)
(when (fboundp 'linum-mode)
(setq linum-format "%d ")
(global-linum-mode 1)))
(set-default 'cursor-type 'bar)
(show-paren-mode 1)
(setq use-dialog-box nil)
;; tab bar settings
(when (< 26 emacs-major-version)
(tab-bar-mode 1)
(setq tab-bar-show 1)
(setq tab-bar-close-button-show nil)
(setq tab-bar-new-tab-choice "*dashboard*")
(setq tab-bar-tab-hints t)
(setq tab-bar-tab-name-function 'tab-bar-tab-name-truncated)
(setq tab-bar-tab-name-truncated-max 10)
(setq tab-bar-select-tab-modifiers "super")
;; TODO: test if this version wrapper is necessary
(when (< 27 emacs-major-version)
(setq tab-bar-format '(tab-bar-format-tabs tab-bar-separator))))
;; Fancy titlebar for MacOS
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))
(setq ns-use-proxy-icon nil)
(setq frame-title-format nil)
;; pulse
(defun pulse-line (&rest _)
"Pulse the current line."
(pulse-momentary-highlight-one-line (point)))
(when (< 24 emacs-major-version)
;; advice-add function added in 24.4
;; TODO figure out how to do minor version comparison, too convoluted now
(dolist (command '(scroll-up-command scroll-down-command
recenter-top-bottom other-window))
(advice-add command :after #'pulse-line)))
(setq pulse-flag nil)
;;;; Behavior
;; startup
(setq make-backup-files nil)
(defalias 'yes-or-no-p 'y-or-n-p)
(delete-selection-mode 1)
(setq delete-by-moving-to-trash 1)
(setq inhibit-splash-screen t)
(when (display-graphic-p)
(setq default-directory (concat (getenv "HOME") "/")))
;; files settings
(global-auto-revert-mode t)
(setq global-auto-revert-non-file-buffers t)
(setq-default indent-tabs-mode nil)
(setq-default c-basic-offset 4)
(setq gdb-gud-control-all-threads t)
(setq require-final-newline t)
(setq-default truncate-lines t)
(setq large-file-warning-threshold 100000000)
(setq history-length 25)
(savehist-mode 1)
(when (< 24 emacs-major-version)
(save-place-mode 1))
(recentf-mode 1)
;; hooks
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(add-hook 'org-mode-hook 'turn-on-visual-line-mode)
;; scrolling
(setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 5)))
;; ;; keep currently line vertically centered
;; (setq scroll-preserve-screen-position t
;; scroll-conservatively 0
;; maximum-scroll-margin 0.5
;; scroll-margin 99999)
;; never kill my frame (GUI window). CMD-w (s-w) on mac
(when (display-graphic-p)
(put 'delete-frame 'disabled t)
(put 'save-buffers-kill-terminal 'disabled t))
;; spell check all the time
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(change-log-mode-hook log-edit-mode-hook))
(add-hook hook (lambda () (flyspell-mode -1))))
;; ibuffer
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(setq ibuffer-default-sorting-mode 'major-mode)
;; line mode
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
(when (< 23 emacs-major-version)
(add-hook 'prog-mode-hook #'hs-minor-mode))
;; Scratch
;; from https://www.emacswiki.org/emacs/RecreateScratchBuffer
(defun unkillable-scratch-buffer ()
(if (equal (buffer-name (current-buffer)) "*scratch*")
(progn
(delete-region (point-min) (point-max))
(insert initial-scratch-message)
nil)
t))
(add-hook 'kill-buffer-query-functions 'unkillable-scratch-buffer)
(defun switch-to-scratch-and-back ()
"Toggle between *scratch* buffer and the current buffer.
If the *scratch* buffer does not exist, create it."
(interactive)
(let ((scratch-buffer-name (get-buffer-create "*scratch*")))
(if (equal (current-buffer) scratch-buffer-name)
(switch-to-buffer (other-buffer))
(switch-to-buffer scratch-buffer-name (lisp-interaction-mode)))))
(global-set-key (kbd "C-c s") 'switch-to-scratch-and-back)
(set-variable 'initial-scratch-message
";; This buffer is for text that is not saved, and for Lisp evaluation.
;; Run lisp code by going to end-of-line and typing C-j
")
;;; 4. Alternate Load Files
;; KEYBINDINGS
(load "~/.config/emacs/my-keybindings.el")
;; MY FUNCTIONS & Packages
(add-to-list 'load-path "~/.config/emacs/elisp")
;; Load Packages if on a Mac
(when (eq system-type 'darwin)
;; ensure running latest emacs
(when (< 24 emacs-major-version)
(load "~/.config/emacs/init.el")))
;; Load colors & theme
;; must come after init.el to ensure packages for guis
(load "~/.config/emacs/theme.el")
(load "~/.config/emacs/eshell.el")
;;; 5. Machine-specific configs
(if (eq system-type 'darwin)
(setq cursys (car (split-string (system-name) "\\." t)))
(setq cursys (getenv "LCSCHEDCLUSTER")))
(setq custom-file (concat "~/.emacs.d/custom-" cursys ".el"))
(load custom-file 'noerror)
(put 'upcase-region 'disabled nil)