-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-common.el
111 lines (97 loc) · 4.79 KB
/
init-common.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
;;; init-common.el -- Emacs 基本配置
;;;
;;; Commentary:
;;;
;;; 基本配置
;;; Code:
;;;
;; 中文显示
(set-language-environment "utf-8")
(set-buffer-file-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-clipboard-coding-system 'utf-8)
(modify-coding-system-alist 'process "*" 'utf-8)
(prefer-coding-system 'utf-8)
(setq-default pathname-coding-system 'utf-8)
(setq
default-process-coding-system '(utf-8 . utf-8)
locale-coding-system 'utf-8
file-name-coding-system 'utf-8
default-buffer-file-coding-system 'utf-8
slime-net-coding-system 'utf-8-unix)
(setenv "LC_CTYPE" "UTF-8")
(setenv "LC_ALL" "en_US.UTF-8")
(setenv "LANG" "en_US.UTF-8") ; Iterate through CamelCase words
;; 基本设置
(setq-default
indicate-buffer-boundaries 'left ;; 在窗口边缘上显示一个小箭头指示当前 buffer 的边界
kill-whole-line t) ;; C-k时,同时删除该行
(setq
fringes-outside-margins t ;; fringe 放在外面
echo-keystrokes 0.1 ;; 尽快显示按键序列
system-time-locale "en_US" ;; 设置系统时间显示格式
tab-always-indent 'complete ;; Tab 键优先格式化再补全
font-lock-global-modes '(not shell-mode text-mode) ;; 设置语法高亮.除shell-mode和text-mode之外的模式
mouse-yank-at-point t ;; 不在鼠标点击的地方插入剪贴板内容
kill-ring-max 200 ;; 设置 kill ring 个数
default-fill-column 60 ;; 把fill-column设为60.让文字更好读
enable-recursive-minibuffers t ;; 递归的使用minibuffer
scroll-margin 3 ;; 在靠近屏幕边沿 3 行时就开始滚动,可很好看到上下文
scroll-conservatively 10000 ;; 防止页面滚动时跳动
select-enable-clipboard t ;; 允许emacs和外部程序进行粘贴
track-eol t ;; 当光标在行尾上下移动的时候,始终保持在行尾
next-line-add-newlines nil ;; 按C-n或down时不添加新行
;; emacs启动时显示的内容可以通过变量initial-scratch-message来设置
initial-scratch-message nil
dired-listing-switches "-vha" ;; dired 列出文件的参数(man ls)
show-paren-style 'parenthesis ;; 括号匹配时高亮显示另一边的括号,而不是跳到另一个括号处
vc-follow-symlinks t ;; 跟随版本控制中的符号链接
x-underline-at-descent-line t ;; Underline line at descent position, not baseline position
)
;; 设置4个空格缩进
(setq-default indent-tabs-mode nil)
(setq tab-width 4) ; or any other preferred value
;;; Tidy workdir
(make-directory "~/.emacs.d/data/backup/" t)
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/data/backup/" t)) ; Write auto-save files to a separate directory
backup-directory-alist '(("." . "~/.emacs.d/data/backup/")) ; Write backup files to a separate directory
create-lockfiles nil ; Disable lockfiles as I use only one Emacs instance
)
;; Making Buffer Names Unique
;; 当寻找一个同名的文件,改变两个buffer的名字,前面加上目录名
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
(defvar usr-bin-path "/usr/bin/"
"The /usr/bin path to custom in each OS.")
;; Copied from https://tecosaur.github.io/emacs-config/
(setq-default
delete-by-moving-to-trash t ; Delete files to trash
window-combination-resize t ; take new window space from all other windows (not just current)
x-stretch-cursor t) ; Stretch cursor to the glyph width
(setq undo-limit 80000000 ; Raise undo-limit to 80Mb
truncate-string-ellipsis "…" ; Unicode ellispis are nicer than "...", and also save /precious/ space
password-cache-expiry nil ; I can trust my computers ... can't I?
scroll-margin 2) ; It's nice to maintain a little margin
;; 在标题栏显示buffer的名字和项目
(setq frame-title-format
'(""
(:eval
(if (and
(boundp 'org-roam-directory)
(s-contains-p org-roam-directory (or buffer-file-name "")))
(replace-regexp-in-string
".*/[0-9]*-?" "☰ "
(subst-char-in-string ?_ ? buffer-file-name))
"%b"))
(:eval
(if (boundp 'projectile-project-name)
(let ((project-name (projectile-project-name)))
(unless (string= "-" project-name)
(format (if (buffer-modified-p) " ◉ %s" " ● %s") project-name)))))))
(when window-system
(set-frame-position (selected-frame) 0 0)
(set-frame-size (selected-frame) lo-frame-width lo-frame-height))
(provide 'init-common)
;;; init-common.el ends here