-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path03_outline.el
89 lines (82 loc) · 2.57 KB
/
03_outline.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
;; -*- encoding: utf-8-unix; -*-
;; * 定义函数
(defun set-outline-minor-mode ()
(outline-minor-mode 1)
(make-local-variable 'outline-regexp)
(setq outline-regexp
(or
(car (gethash major-mode *outline-minor-mode-hash*))
outline-regexp))
(make-local-variable 'outline-heading-alist)
(setq outline-heading-alist
(or
(cadr (gethash major-mode *outline-minor-mode-hash*))
outline-heading-alist))
(hide-body))
;; * 定义数据
;; (defvar *outline-minor-mode-hash* (make-hash-table :test 'equal :size 30))
;; (mapc (lambda (x)
;; (puthash (car x)(cdr x)
;; *outline-minor-mode-hash*))
;; (to-alist '(
;; lisp-interaction-mode ";;;\\(;* [^ \n]\\|###autoload\\)\\|("
;; ;emacs-lisp-mode ";;\\ \\*+\\|;;;\\(;* [^ \n]\\|###autoload\\)\\|("
;; emacs-lisp-mode ";;\\ \\*+"
;; shell-mode ".*[bB]ash.*[#\$] \\|^.:\.*>"
;; sh-mode "function"
;; eshell-mode ".*[#\$]\\|^.:\.*>"
;; )))
(defvar *outline-minor-mode-hash*
(mkht
lisp-interaction-mode
(";;;\\(;* [^ \n]\\|###autoload\\)\\|(")
emacs-lisp-mode
(";;\\ \\*+\\|;;;\\(;* [^ \n]\\|###autoload\\)\\|("
((";;\\ \\*+" . 1)
(";;;\\(;* [^ \n]\\|###autoload\\)" . 2)
("(" . 3)))
shell-mode
(".*[bB]ash.*[#\$] \\|^.:\.*>")
sh-mode
("function")
eshell-mode
(".*[#\$]\\|^.:\.*>")
diff-mode
("diff\\|@@\\|*\\{10,\\}"
(("diff" . 1)
("@@" . 2)
("*\\{10,\\}" . 2)))
))
;; * 应用数据
(mapc
(lambda(h)
(add-hook h 'set-outline-minor-mode t))
(let (z)
(maphash
(lambda(x y)(setq z (cons (concat-symbol x "-hook") z)))
*outline-minor-mode-hash*)
z))
;; * 定义键位
(setq outline-minor-mode-prefix [(control t)])
;; * 自定义省略提示
;; ** 字符
; (set-display-table-slot standard-display-table
; 'selective-display
; (string-to-vector " [...] "))
;; ** 主题
(set-display-table-slot
standard-display-table
'selective-display
(let ((face-offset (* (face-id 'shadow) (lsh 1 22))))
(vconcat (mapcar (lambda (c) (+ face-offset c)) " {...} "))))
;; * outline-magic
;; (add-hook 'outline-mode-hook
;; (lambda ()
;; (require 'outline-cycle)))
(add-hook 'outline-minor-mode-hook
(lambda ()
(require 'outline-magic)
;; 定义快捷键 tab | f1
(define-key outline-minor-mode-map [(f1)] 'outline-cycle)))
;; 在正文中模拟tab,用tab作快捷键时开启
;(setq outline-cycle-emulate-tab t)