Skip to content

Commit 5994285

Browse files
committed
vanilla emacs
1 parent a2dcfbb commit 5994285

24 files changed

+478
-35
lines changed

.vanilla-emacs.d/custom.el

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
21
(custom-set-variables
32
;; custom-set-variables was added by Custom.
43
;; If you edit it by hand, you could mess it up, so be careful.
54
;; Your init file should contain only one such instance.
65
;; If there is more than one, they won't work right.
76
'(package-selected-packages
8-
'(consult avy expand-region crux undo-tree org-bullets doom-modeline ryo-modal winum smartparens company rg ctrlf selectrum-prescient telega selectrum org-roam which-key)))
7+
'(magit persp-mode org-download grab-mac-link lsp-mode winum which-key telega smartparens selectrum-prescient ryo-modal rg org-roam org-bullets markdown-mode lv expand-region doom-modeline ctrlf crux consult company avy)))
98
(custom-set-faces
109
;; custom-set-faces was added by Custom.
1110
;; If you edit it by hand, you could mess it up, so be careful.

.vanilla-emacs.d/init.el

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,37 @@
44
(setq user-emacs-directory (file-name-directory user-init-file))
55
(add-to-list 'load-path (expand-file-name (concat user-emacs-directory "lisp")))
66

7+
(require 'init-speedup)
78
(require 'init-some-path)
89
(require 'init-imi-func)
910
(require 'init-basic)
1011
(require 'init-platform)
1112
(require 'init-package)
12-
(require 'init-custom)
13+
14+
;; package
1315
(require 'init-roam)
1416
(require 'init-org-mode)
1517
(require 'init-telega)
18+
(require 'init-gtd)
19+
(require 'init-doom)
20+
(require 'init-winum)
21+
(require 'init-org-download)
22+
(require 'init-persp)
23+
24+
;; package
25+
26+
;; completion system
1627
(require 'init-selectrum)
1728
(require 'init-ryo-modal)
29+
(require 'init-consult)
30+
;; completion system
31+
32+
;; language
33+
(require 'init-lsp)
34+
(require 'yasnippet)
35+
(yas-global-mode 1)
36+
;; language
37+
1838
(require 'init-mode-enable)
39+
40+
(require 'init-custom)

.vanilla-emacs.d/lisp/init-basic.el

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
;;(set-face-attribute 'default nil :height 140 :weight 'regular :width 'normal :family "PingFang SC")
44
(set-face-attribute 'default nil :height 150)
5-
(load-theme 'dichromacy t)
5+
6+
;; ;; Open links in the same Window by default.
7+
(setq org-link-frame-setup '((file . find-file)))
68

79
(global-set-key (kbd "<f5>") (lambda() (interactive)(find-file user-init-file)))
810

@@ -18,7 +20,19 @@
1820

1921
(tool-bar-mode 0)
2022
(scroll-bar-mode 0)
21-
(add-to-list 'display-buffer-alist '("*Help*" display-buffer-same-window))
23+
;;(add-to-list 'display-buffer-alist '("*Help*" display-buffer-same-window))
2224
(add-to-list 'default-frame-alist '(fullscreen . maximized))
2325

26+
(setq display-time-24hr-format t)
27+
;;(setq display-time-format "%I:%M")
28+
29+
(add-hook 'emacs-startup-hook
30+
(lambda ()
31+
(message "Emacs ready in %s with %d garbage collections."
32+
(format "%.2f seconds"
33+
(float-time
34+
(time-subtract after-init-time before-init-time)))
35+
gcs-done)))
36+
37+
2438
(provide 'init-basic)

.vanilla-emacs.d/lisp/init-consult.el

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;; -*- lexical-binding: t; -*-
2+
3+
(consult-theme 'modus-vivendi)
4+
5+
(provide 'init-consult)

.vanilla-emacs.d/lisp/init-doom.el

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;; -*- lexical-binding: t; -*-
2+
3+
(setq doom-modeline-height 25)
4+
(setq doom-modeline-buffer-file-name-style 'truncate-upto-root)
5+
6+
(set-face-attribute 'mode-line nil :family "Source Code Pro" :height 150)
7+
(set-face-attribute 'mode-line-inactive nil :family "Source Code Pro" :height 150)
8+
9+
(provide 'init-doom)

.vanilla-emacs.d/lisp/init-gtd.el

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
;; -*- lexical-binding: t; -*-
2+
(setq imi-gtd-path "~/pkm-roam/roam2/gtd/")
3+
(setq imi-gtd-inbox-file (concat imi-gtd-path "inbox.org"))
4+
(setq imi-gtd-tickler-file (concat imi-gtd-path "tickler.org"))
5+
(setq imi-gtd-someday-file (concat imi-gtd-path "someday.org"))
6+
(setq imi-gtd-gtd-file (concat imi-gtd-path "gtd.org"))
7+
(setq imi-gtd-reference-file (concat imi-gtd-path "reference.org"))
8+
9+
(defun open-gtd-dir() (interactive) (find-file imi-gtd-gtd-file))
10+
(global-set-key (kbd "<f6>") 'open-gtd-dir)
11+
12+
;; 定义 org-capture 模版
13+
(setq org-capture-templates '(("t" "Todo [inbox]" entry
14+
(file+headline imi-gtd-inbox-file "Tasks")
15+
"* TODO %i%?")
16+
("T" "Tickler" entry
17+
(file+headline imi-gtd-tickler-file "Tickler")
18+
"* %i%? \n %U")
19+
))
20+
21+
22+
;; 定义触发 capture inbox 的快捷键
23+
(define-key global-map (kbd "C-c j t") (lambda () (interactive) (org-capture nil "t")))
24+
;; 定义触发 capture Tickler 的快捷键
25+
(define-key global-map (kbd "C-c j T") (lambda () (interactive) (org-capture nil "T")))
26+
;; 归档
27+
(define-key global-map (kbd "C-c j a") 'org-archive-subtree-default)
28+
29+
;; Save Org buffers after refiling!
30+
(advice-add 'org-refile :after 'org-save-all-org-buffers)
31+
(setq org-refile-targets '((imi-gtd-gtd-file :maxlevel . 3)
32+
(imi-gtd-someday-file :level . 1)
33+
(imi-gtd-tickler-file :maxlevel . 2)
34+
(imi-gtd-reference-file :maxlevel . 2)
35+
))
36+
37+
(setq org-todo-keywords '((sequence "TODO(t)" "WAITING(w)" "|" "DONE(d)" "CANCELLED(c)")))
38+
39+
(setq org-agenda-files (list imi-gtd-inbox-file imi-gtd-gtd-file imi-gtd-tickler-file))
40+
41+
(setq org-agenda-custom-commands
42+
'(("o" "At the office" tags-todo "@office"
43+
((org-agenda-overriding-header "Office")))))
44+
45+
46+
(provide 'init-gtd)

.vanilla-emacs.d/lisp/init-imi-func.el

+35
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,39 @@ Forward to `org-shifttab' with ARG."
114114
(other-window 1)
115115
)
116116

117+
(defun imi-reveal-in-finder ()
118+
(interactive)
119+
(shell-command (concat "open -R " buffer-file-name)))
120+
121+
(defun imi-open-iTerm ()
122+
"Opens up a new shell in the directory associated with the
123+
current buffer's file. The eshell is renamed to match that
124+
directory to make multiple eshell windows easier."
125+
(interactive)
126+
(shell-command "open -a iTerm ."))
127+
128+
(defun imi-save-all-buffers () (interactive) (save-some-buffers t))
129+
130+
(defun imi-restart-emacs ()
131+
(interactive)
132+
(imi-save-all-buffers)
133+
(call-process "sh" nil nil nil "-c" "sh /Users/fuhongxue/project/vanilla-emacs/setup-vanilla-emacs-by-daemon.sh &")
134+
(save-buffers-kill-terminal))
135+
136+
;; from https://stackoverflow.com/questions/384284/how-do-i-rename-an-open-file-in-emacs
137+
(defun imi-rename-file-and-buffer (new-name)
138+
"Renames both current buffer and file it's visiting to NEW-NAME."
139+
(interactive "sNew name: ")
140+
(let ((name (buffer-name))
141+
(filename (buffer-file-name)))
142+
(if (not filename)
143+
(message "Buffer '%s' is not visiting a file!" name)
144+
(if (get-buffer new-name)
145+
(message "A buffer named '%s' already exists!" new-name)
146+
(progn
147+
(rename-file filename new-name 1)
148+
(rename-buffer new-name)
149+
(set-visited-file-name new-name)
150+
(set-buffer-modified-p nil))))))
151+
117152
(provide 'init-imi-func)

.vanilla-emacs.d/lisp/init-lsp.el

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
;; -*- lexical-binding: t; -*-
2+
3+
(require 'lsp-mode)
4+
5+
;; 性能相关
6+
(setq read-process-output-max (* 1024 1024)) ;; 1mb
7+
(setq lsp-completion-provider :capf)
8+
(setq lsp-idle-delay 0.500)
9+
(setq lsp-enable-file-watchers nil)
10+
(setq lsp-log-io nil) ; if set to true can cause a performance hit
11+
12+
(setq lsp-ui-doc-position 'at-point)
13+
14+
;; 补全
15+
(setq company-minimum-prefix-length 1
16+
company-idle-delay 0.0) ;; default is 0.2
17+
18+
(define-key lsp-mode-map (kbd "C-c l") lsp-command-map)
19+
(with-eval-after-load 'lsp-mode
20+
(add-hook 'lsp-mode-hook (lambda ()
21+
(let ((lsp-keymap-prefix "C-c l"))
22+
(lsp-enable-which-key-integration)))))
23+
24+
25+
(add-hook 'c-mode-hook 'lsp)
26+
27+
(provide 'init-lsp)
+22-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
;; -*- lexical-binding: t; -*-
22

3-
(require 'winum)
4-
(winum-mode)
5-
(delete-selection-mode)
6-
(doom-modeline-mode)
7-
(org-bullets-mode)
8-
(global-company-mode)
3+
(defun imi-load-after-idle-time ()
4+
(winum-mode)
5+
(delete-selection-mode)
6+
(doom-modeline-mode)
7+
(org-bullets-mode)
8+
(global-company-mode)
9+
(recentf-mode) ;; consult consult-recent-file
10+
(which-key-mode)
11+
)
12+
13+
;; daemon 不允许 idle time,会死机
14+
(imi-load-after-idle-time)
15+
16+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17+
;; (setq setup-idle-time-once ;;
18+
;; (run-with-idle-timer 3 t ;;
19+
;; (lambda () ;;
20+
;; (message "imi-load-after-idle-time") ;;
21+
;; (imi-load-after-idle-time) ;;
22+
;; (cancel-timer setup-idle-time-once)))) ;;
23+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24+
925

1026
(provide 'init-mode-enable)
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
;; -*- lexical-binding: t; -*-
2+
3+
(require 'org-download)
4+
5+
(defun imi-im-file-name ()
6+
"copy buffer's full path to kill ring"
7+
(interactive)
8+
(when buffer-file-name
9+
;; (file-name-nondirectory (kill-new (file-truename buffer-file-name)))))
10+
;; (file-name-nondirectory (file-truename buffer-file-name))))
11+
(file-name-sans-extension (buffer-name))))
12+
13+
(defun imi-org-download-paste-clipboard (&optional use-default-filename)
14+
(interactive "P")
15+
(insert "#+ATTR_ORG: :width 500 ")
16+
17+
(setq org-download-image-dir (concat "images/" (imi-im-file-name)))
18+
(let ((file
19+
(if (not use-default-filename)
20+
(read-string (format "Filename [%s]: " org-download-screenshot-basename)
21+
nil nil org-download-screenshot-basename)
22+
nil)))
23+
(org-download-clipboard file)))
24+
25+
(with-eval-after-load "org"
26+
(setq org-download-method 'directory)
27+
(setq org-download-image-dir "images/")
28+
(setq org-download-heading-lvl nil)
29+
(setq org-download-timestamp "%Y%m%d-%H%M%S_")
30+
(setq org-image-actual-width nil)
31+
(setq org-src-window-setup 'split-window-right)
32+
(setq org-download-annotate-function (lambda (_link) ""))
33+
)
34+
35+
36+
(provide 'init-org-download)
37+
+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
;; init-org-mode.el -*- lexical-binding: t; -*-
22

33
(add-hook 'org-mode-hook 'org-indent-mode)
4+
(setq grab-mac-link-dwim-favourite-app 'chrome)
45

56
(provide 'init-org-mode)

.vanilla-emacs.d/lisp/init-package.el

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
(require 'package)
55
(setq package-user-dir "~/project/vanilla-emacs/packages")
66
(setq package-enable-at-startup nil)
7-
(setq package-archives '(("gnu" . "http://elpa.emacs-china.org/gnu/")
7+
(setq package-archives '(
8+
("gnu" . "http://elpa.emacs-china.org/gnu/")
9+
10+
;; ("gnu" . "http://elpa.gnu.org/packages/")
811
("melpa" . "https://melpa.org/packages/")
912
("melpa-stable" . "https://stable.melpa.org/packages/")
10-
("elpy" . "http://jorgenschaefer.github.io/packages/")))
13+
;; ("elpy" . "http://jorgenschaefer.github.io/packages/")
14+
))
1115

1216
(package-initialize)
1317

1418
(setq package-list '(
15-
which-key org-roam selectrum telega selectrum-prescient ctrlf rg company smartparens winum ryo-modal crux expand-region avy consult
19+
which-key org-roam selectrum telega selectrum-prescient ctrlf rg company smartparens winum ryo-modal crux expand-region avy consult lsp-mode yasnippet link-hint grab-mac-link org-download persp-mode magit
1620

1721
))
1822

.vanilla-emacs.d/lisp/init-persp.el

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;; -*- lexical-binding: t; -*-
2+
3+
(require 'persp-mode)
4+
5+
(persp-mode 1)
6+
7+
(setq persp-auto-save-opt 0)
8+
(persp-load-state-from-file imi-persp-path)
9+
10+
(defun imi-close-perspective()
11+
(message (concat "Saving " imi-persp-path ))
12+
;; telega confict with persp, don't save
13+
(when (telega-server-live-p) (telega-kill 1) )
14+
(persp-save-state-to-file imi-persp-path))
15+
(add-hook 'kill-emacs-hook 'imi-close-perspective)
16+
17+
18+
(defun imi-persp-switch-to-n (n)
19+
(let ((names (persp-names-current-frame-fast-ordered))
20+
(count 0))
21+
(dolist (name names)
22+
(when (= count n)
23+
(persp-switch name))
24+
(cl-incf count))))
25+
26+
(defun imi-persp-switch-to-0 () (interactive) (imi-persp-switch-to-n 0))
27+
(defun imi-persp-switch-to-1 () (interactive) (imi-persp-switch-to-n 1))
28+
(defun imi-persp-switch-to-2 () (interactive) (imi-persp-switch-to-n 2))
29+
(defun imi-persp-switch-to-3 () (interactive) (imi-persp-switch-to-n 3))
30+
(defun imi-persp-switch-to-4 () (interactive) (imi-persp-switch-to-n 4))
31+
(defun imi-persp-switch-to-5 () (interactive) (imi-persp-switch-to-n 5))
32+
(defun imi-persp-switch-to-6 () (interactive) (imi-persp-switch-to-n 6))
33+
(defun imi-persp-switch-to-7 () (interactive) (imi-persp-switch-to-n 7))
34+
(defun imi-persp-switch-to-8 () (interactive) (imi-persp-switch-to-n 8))
35+
(defun imi-persp-switch-to-9 () (interactive) (imi-persp-switch-to-n 9))
36+
(defun imi-persp-switch-to-10 () (interactive) (imi-persp-switch-to-n 10))
37+
38+
39+
40+
(provide 'init-persp)

0 commit comments

Comments
 (0)