-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.emacs
More file actions
executable file
·261 lines (227 loc) · 8.65 KB
/
.emacs
File metadata and controls
executable file
·261 lines (227 loc) · 8.65 KB
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
;(setq exec-path (cons "/usr/local/bin" exec-path))
(setenv "PATH" (concat "/usr/local/bin" ":" (getenv "PATH")))
(require 'package)
(add-to-list 'package-archives
'("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(setq inhibit-startup-screen t)
(setq use-package-always-ensure nil)
(unless (require 'use-package nil t)
(if (not (yes-or-no-p (concat "Refresh packages, install use-package and"
" other packages used by init file? ")))
(error "you need to install use-package first")
(package-refresh-contents)
(package-install 'use-package)
(require 'use-package)
(setq use-package-always-ensure t)))
(use-package which-key
:config
(which-key-mode))
(global-set-key (kbd "C-c h b") 'describe-personal-keybindings)
(setq recentf-max-saved-items 100)
(global-set-key "\C-cq" #'bury-buffer)
(use-package helm
:demand
:init
(setq helm-split-window-default-side 'other
helm-split-window-inside-p t
helm-swoop-split-with-multiple-windows t
helm-command-prefix-key "s-c")
:config
;(require 'helm-config) ; required to setup "s-c" keymap
(helm-mode 1)
(helm-autoresize-mode 1)
;; Only rebind M-x and C-x C-f on successful load of helm to remain
;; this basic operations if helm is not installed.
(bind-key "M-x" #'helm-M-x)
(bind-key "C-x C-f" #'helm-find-files)
:bind
(("M-y" . helm-show-kill-ring)
("C-c o" . helm-occur)
("C-x b" . helm-mini)
("C-x r b" . helm-bookmarks)
("C-h a" . helm-apropos)
("C-h d" . helm-info-at-point)
("C-c a" . helm-all-mark-rings)
("C-c h e" . helm-info-emacs)
("C-c h g" . helm-info-gnus)
("C-c R" . helm-register)
("s-P" . helm-run-external-command)
;; More key bindings in "s-c" keymap
:map helm-find-files-map
("<backtab>" . helm-select-action)
("C-i" . helm-execute-persistent-action)))
(use-package ace-window
:init
(setq aw-scope 'frame ; limit to single frame (useful when using exwm)
aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
:bind
("C-x o" . ace-window))
(use-package helm-swoop
:bind
(("C-s" . helm-swoop-without-pre-input)
("C-S-s" . helm-swoop)))
(use-package magit
:bind (("C-x g" . magit-status)
("C-x M-g" . magit-dispatch)))
(use-package git-commit
:hook (git-commit-mode . my-american-dict))
(use-package git-messenger
:bind ("C-x G" . git-messenger:popup-message)
:config
(setq git-messenger:show-detail t
git-messenger:use-magit-popup t))
(use-package helm-git-grep
:bind
(("C-c j" . helm-git-grep)
("C-c J" . helm-git-grep-at-point)))
(use-package helm-ls-git
:bind
(("C-c g" . helm-ls-git-ls)))
(defun export-to-jekyll-html ()
(interactive)
(let* ((fname (buffer-file-name))
(dname (file-name-directory fname))
(base-name (file-name-base fname)))
(if (not (string= (file-name-extension fname) "org"))
(message "not a org-mode file, skip ...")
(progn
(org-html-export-as-html)
(switch-to-buffer "*Org HTML Export*")
(goto-char (point-min))
(search-forward "<div id=\"content\" class=\"content\">")
(kill-region (point-min) (+ 1 (point)))
(goto-char (point-max))
(search-backward "</div>")
(kill-region (point) (point-max))
(write-file (format "%s../_posts/%s.html" dname base-name))
(kill-buffer (format "%s.html" base-name))
(delete-window)))))
(defun convert-org-to-markdown (fname)
(let* ((dname (file-name-directory fname))
(base-name (file-name-base fname)))
(if (not (string= (file-name-extension fname) "org"))
(message "not a org-mode file, skip ...")
(progn
(org-md-export-as-markdown)
(switch-to-buffer "*Org MD Export*")
;(goto-char (point-min))
;(search-forward "<div id=\"content\" class=\"content\">")
;(kill-region (point-min) (+ 1 (point)))
;(goto-char (point-max))
;(search-backward "</div>")
;(kill-region (point) (point-max))
(write-file (format "%s../_posts/%s.md" dname base-name))
(kill-buffer (format "%s.md" base-name))
(delete-window)))))
(defun export-to-jekyll-markdown ()
(interactive)
(convert-org-to-markdown (buffer-file-name)))
(defun export-all-to-jekyll-markdown ()
(interactive)
(let* ((fname (buffer-file-name))
(dname (file-name-directory fname))
(flist (directory-files dname t)))
(progn
(mapc #'(lambda (x)
(when (and (string= (file-name-extension x) "org")
(not (backup-file-name-p x)))
(progn
(message (format "processing %s" x))
(switch-to-buffer (find-file-noselect x))
(convert-org-to-markdown x))))
flist))))
(show-paren-mode 1)
(setq-default abbrev-mode 1)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(use-package yasnippet
:hook (after-init . yas-global-mode)
:bind
(:map yas-minor-mode-map
("C-c & t" . yas-describe-tables)
("C-c & &" . org-mark-ring-goto)))
(use-package yasnippet-snippets
:defer)
(use-package helm-c-yasnippet
:bind
(("C-c y" . helm-yas-complete)))
(add-hook 'after-init-hook 'global-company-mode)
(use-package org
:init
(setq org-export-with-toc nil)
(setq org-publish-project-alist
'(("org-paul356"
;; Path to your org files.
:base-directory "~/code/paul356.github.io/org/"
:base-extension "org"
;; Path to your Jekyll project.
:publishing-directory "~/code/paul356.github.io/_posts/"
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4
:html-extension "html"
:body-only t ;; Only export section between <body> </body>
)
("org-paul356-static"
:base-directory "~/code/paul356.github.io/org/"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|php"
:publishing-directory "~/code/paul356.github.io/images/"
:recursive t
:publishing-function org-publish-attachment)
("blog" :components ("org-paul356" "org-paul356-static")))))
(defconst my-cc-style
'("k&r"
(c-offsets-alist . ((innamespace . [0])))))
(c-add-style "my-cc-mode" my-cc-style)
(setq-default c-basic-offset 4)
(setq c-default-style '((java-mode . "java")
(awk-mode . "awk")
(c++-mode . "my-cc-mode")
(other . "k&r")))
(add-to-list 'auto-mode-alist '("\\.ino\\'" . c++-mode))
(add-hook 'c-mode-common-hook 'cscope-setup)
(define-key org-mode-map "\M-q" 'toggle-truncate-lines)
;; (use-package cmake-ide
;; :after cc-mode
;; :config
;; (cmake-ide-setup))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(company-idle-delay 0.5)
'(cscope-option-do-not-update-database t)
'(cscope-program "/usr/bin/cscope")
'(custom-enabled-themes '(tango-dark))
'(lpr-command "lpr")
'(lpr-switches nil)
'(org-export-backends '(html latex md))
'(org-html-postamble nil)
'(org-latex-compiler "xelatex")
'(org-mode-hook
'(#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-show-all append local]
5]
#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-babel-show-result-all append local]
5]
org-babel-result-hide-spec org-babel-hide-all-hashes valign-mode))
'(package-selected-packages
'(protobuf-mode markdown-mode java-imports gradle-mode scala-mode org s xcscope git-messenger helm-git-grep helm-ls-git magit helm-c-yasnippet ace-window helm helm-swoop yasnippet-snippets which-key cmake-ide zygospore ws-butler volatile-highlights use-package undo-tree rtags-xref projectile iedit flycheck dtrt-indent company comment-dwim-2 clojure-snippets clean-aindent-mode anzu valign))
'(tags-case-fold-search nil)
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(put 'downcase-region 'disabled nil)