-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.dir-locals.el
147 lines (114 loc) · 7.33 KB
/
.dir-locals.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
;;; -*- lexical-binding: t; -*-
;; 读取本文件时, 似乎本来就默认开启了‘lexical-binding’.
;;; Comments:
;;
;; 能放到该文件的配置都放到该文件, file local variable 要尽可能少.
;; 因为 Emacs 启动时会读取本文件, 将结果加到 ‘safe-local-variable-values’ 中, 当启用这些配置时, _无需确认_.
((auto-mode-alist . (;; 诸如 auto-save 之类的文件.
("[~#]\\'" . (ignore t)) ; e.g., ‘a.txt~’, ‘#a.txt#’.
("/[^/[:blank:]]+\\.ps1\\'" . powershell-mode)
("/[^/[:blank:]]+\\.md\\'" . markdown-mode)
("/[^/[:blank:]]+\\.textile\\'" . textile-mode)
("/\\.nosearch\\'" . text-mode)
("/[^/[:blank:]]+\\.ya?ml\\'" . yaml-mode)
("/var/yas-snippets/[^/[:blank:]]+-mode/\\(?:\\.yas-skip\\|\\.yas-parents\\|[^/[:blank:]]+\\.yasnippet\\)\\'" . snippet-mode)
("/\\.gitignore\\'" . gitignore-mode)
("/\\.gitmodules\\'" . gitconfig-mode)
("/media/images/shynur-[^/]+\\.xpm\\'" . c-mode)
))
(nil . ((make-backup-files . nil)
(mode . auto-save)
(auto-revert-verbose . nil)
(outline-minor-mode-cycle . t)
(outline-minor-mode-prefix . [nil])
(lexical-binding . t)
(no-byte-compile . t)
(project-vc-merge-submodules . nil)
(imenu-auto-rescan . t)
(imenu-sort-function . imenu--sort-by-name)
(eval . (ignore-error 'imenu-unavailable
(imenu-add-menubar-index)))
(mode . which-function)
(which-func-modes . t)
(eval . (when-let ((buffer-file-name (buffer-file-name)))
(when (string-match-p "\\`\\(?:LICENSE\\|COPYING\\)\\(?:\\.[^.[:blank:]]+\\)?\\'" ; ‘LICENSE’ 没有注释语法, 只能写在这里了.
(file-name-nondirectory buffer-file-name))
(setq-local buffer-read-only t))))
(eval . (let ((case-fold-search t))
(highlight-phrase "[.:~/]*\\(?:shynur\\|谢骐\\)\\(?:[_.:/-]+[[:alnum:]_.:/*-]*\\)?"
'underline)))
(tab-width . 4)
(indent-tabs-mode . nil) ; 为什么不是 “(mode . indent-tabs)”? 不知道, manual 中的示例如此.
(delete-trailing-lines . t)
(require-final-newline . t)
(sentence-end-double-space . t)
(before-save-hook . ((lambda ()
"自动加 UTF-8-UNIX 编码的声明."
(save-excursion
(funcall (if (bound-and-true-p shynur/.emacs.d:add-coding-at-propline?)
#'add-file-local-variable-prop-line
#'add-file-local-variable)
'coding 'utf-8-unix)))
delete-trailing-whitespace
whitespace-cleanup
(lambda () ; 在 ‘whitespace-cleanup’ 之后查看第一行的内容.
"给 XPM 文件 的 第一行 加 声明."
(when-let ((buffer-file-name (buffer-file-name)))
(when (string-match-p "/media/images/shynur-[^/]+\\.xpm\\'" buffer-file-name)
(without-restriction
(save-excursion
(goto-char 1)
(when (not (string-match-p "\\`[[:blank:]]*/\\*[[:blank:]]*XPM[[:blank:]]*\\*/[[:blank:]]*\\'" (buffer-substring-no-properties 1 (line-end-position))))
(insert "/* XPM */\n" ?\n)))))))
t))
))
(prog-mode . ((mode . electric-quote-local)))
(emacs-lisp-mode . ((eval . (imenu-add-menubar-index))
(prettify-symbols-alist . (("lambda" . ?λ)))
(mode . prettify-symbols)
))
(org-mode . ((eval . (keymap-local-set "<f9>"
"\N{ZERO WIDTH SPACE}"))
;; 链接🔗 保持原样渲染.
(org-link-descriptive . nil)))
(gitignore-mode . ((outline-regexp . "^#+outline:\\(?1:[[:blank:]]+\\(?:[._[:alnum:]-]+/\\)+\\)?")
(outline-heading-end-regexp . "/\n")
(outline-level . (lambda ()
(let ((slash-amount 0))
(seq-doseq (character (match-string-no-properties 1))
(when (char-equal character ?/)
(cl-incf slash-amount)))
slash-amount)))
(mode . outline-minor)
(eval . (define-key gitignore-mode-map (kbd "TAB")
(lambda ()
(interactive)
(back-to-indentation)
(delete-horizontal-space))))))
(makefile-gmake-mode . ((mode . indent-tabs)))
(yaml-mode . ((tab-width . 2)))
("media/images/" . ((nil . ((mode . image-minor)))))
("var/" . ((nil . ())
("yas-snippets/" . ((snippet-mode . ((require-final-newline . nil)
(mode . whitespace-newline)
(shynur/.emacs.d:add-coding-at-propline? . t)))))))
("local-elpa/" . ((nil . ((before-save-hook . (t))))))
("modules/src/" . ((nil . ((eval . (when-let ((buffer-file-name (buffer-file-name)))
(when (string-match-p "emacs-module" ; 这玩意有 GPL 污染, 切割!
(file-name-nondirectory buffer-file-name))
(setq-local buffer-read-only t))))
(tags-file-name . "ETAGS.txt")
(eval . (when-let ((--buffer-file-name (buffer-file-name))) ; 正在访问文件, 而不是 ‘Dired’ 之类的 buffer.
(let ((default-directory (file-name-concat (with-temp-buffer
(insert --buffer-file-name)
(search-backward "/modules/src/")
(buffer-substring-no-properties 1 (point)))
"modules/src/")))
(when (or (not (file-exists-p tags-file-name))
(> (time-to-number-of-days (time-since (file-attribute-modification-time (file-attributes tags-file-name))))
1))
(eshell-command (format "ls *.[ch] | etags --output=%s - "
tags-file-name)))))))))))
;; Local Variables:
;; coding: utf-8-unix
;; End: