forked from seagle0128/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-mini.el
173 lines (145 loc) · 5.6 KB
/
init-mini.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
;;; init-mini.el --- Centaur Emacs minimal configurations. -*- lexical-binding: t no-byte-compile: t -*-
;; Copyright (C) 2018-2020 Vincent Zhang
;; Author: Vincent Zhang <[email protected]>
;; URL: https://github.com/seagle0128/.emacs.d
;; Version: 1.1.0
;; Keywords: .emacs.d centaur
;; This file is not part of GNU Emacs.
;;
;; This program 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 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;; Commentary:
;;
;; Minimal configurations for debugging purpose.
;;
;;; Code:
;; Load path
(push (expand-file-name "site-lisp" user-emacs-directory) load-path)
(push (expand-file-name "lisp" user-emacs-directory) load-path)
;; Packages
;; Without this comment Emacs25 adds (package-initialize) here
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")))
;; Explicitly set the prefered coding systems to avoid annoying prompt
;; from emacs (especially on Microsoft Windows)
(prefer-coding-system 'utf-8)
;; Miscs
;; (setq initial-scratch-message nil)
(setq inhibit-splash-screen t)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets) ; Show path if names are same
(setq adaptive-fill-regexp "[ t]+|[ t]*([0-9]+.|*+)[ t]*")
(setq adaptive-fill-first-line-regexp "^* *$")
(setq delete-by-moving-to-trash t) ; Deleting files go to OS's trash folder
(setq make-backup-files nil) ; Forbide to make backup files
(setq auto-save-default nil) ; Disable auto save
(setq set-mark-command-repeat-pop t) ; Repeating C-SPC after popping mark pops it again
;; (setq kill-whole-line t) ; Kill line including '\n'
(setq-default major-mode 'text-mode)
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
;; Tab and Space
;; Permanently indent with spaces, never with TABs
(setq-default c-basic-offset 4
tab-width 4
indent-tabs-mode nil)
;; UI
(load-theme 'wombat t)
(unless (eq window-system 'ns)
(menu-bar-mode -1))
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
(when (fboundp 'horizontal-scroll-bar-mode)
(horizontal-scroll-bar-mode -1))
;; (global-hl-line-mode 1)
;; (if (fboundp 'display-line-numbers-mode)
;; (global-display-line-numbers-mode 1)
;; (global-linum-mode 1))
;; Basic modes
(recentf-mode 1)
(ignore-errors (savehist-mode 1))
(save-place-mode 1)
(show-paren-mode 1)
(delete-selection-mode 1)
(global-auto-revert-mode 1)
(setq electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit)
(electric-pair-mode 1)
(add-hook 'prog-mode-hook #'subword-mode)
(add-hook 'minibuffer-setup-hook #'subword-mode)
;; IDO
(if (fboundp 'fido-mode)
(progn
(fido-mode 1)
(defun fido-recentf-open ()
"Use `completing-read' to find a recent file."
(interactive)
(if (find-file (completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
(global-set-key (kbd "C-x C-r") 'fido-recentf-open))
(progn
(ido-mode 1)
(ido-everywhere 1)
(setq ido-use-virtual-buffers t)
(setq ido-use-filename-at-point 'guess)
(setq ido-create-new-buffer 'always)
(setq ido-enable-flex-matching t)
(defun ido-recentf-open ()
"Use `ido-completing-read' to find a recent file."
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)))
;; Key Modifiers
(cond
((eq system-type 'windows-nt)
;; make PC keyboard's Win key or other to type Super or Hyper
;; (setq w32-pass-lwindow-to-system nil)
(setq w32-lwindow-modifier 'super ; Left Windows key
w32-apps-modifier 'hyper) ; Menu/App key
(w32-register-hot-key [s-t]))
((eq window-system 'mac)
;; Compatible with Emacs Mac port
(setq mac-option-modifier 'meta
mac-command-modifier 'super)
(global-set-key [(super a)] #'mark-whole-buffer)
(global-set-key [(super v)] #'yank)
(global-set-key [(super c)] #'kill-ring-save)
(global-set-key [(super s)] #'save-buffer)
(global-set-key [(super l)] #'goto-line)
(global-set-key [(super w)] #'delete-frame)
(global-set-key [(super z)] #'undo)))
;; Keybindings
(global-set-key (kbd "C-.") #'imenu)
(global-set-key (kbd "<C-return>") #'rectangle-mark-mode)
(defun revert-current-buffer ()
"Revert the current buffer."
(interactive)
(message "Revert this buffer")
(text-scale-set 0)
(widen)
(revert-buffer t t))
(global-set-key (kbd "<f5>") #'revert-current-buffer)
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(local-set-key (kbd "C-c C-x") #'ielm)
(local-set-key (kbd "C-c C-c") #'eval-defun)
(local-set-key (kbd "C-c C-b") #'eval-buffer)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Init-mini.el ends here