-
Notifications
You must be signed in to change notification settings - Fork 1
/
templates
136 lines (112 loc) · 4.96 KB
/
templates
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
;; ~/.config/emacs/templates
fundamental-mode ;; Available everywhere
(today (format-time-string "%Y-%m-%d"))
prog-mode
(fixme (cond
((derived-mode-p 'emacs-lisp-mode) ";; " comment-start)
((derived-mode-p 'python-mode) "# " comment-start)
(t "// " comment-start) ;; default
) "FIXME ")
(todo (cond
((derived-mode-p 'emacs-lisp-mode) ";; " comment-start)
((derived-mode-p 'python-mode) "# " comment-start)
((t) "// " comment-start) ;; default
) "TODO ")
(bug (cond
((derived-mode-p 'emacs-lisp-mode) ";; " comment-start)
((derived-mode-p 'python-mode) "# " comment-start)
((t) "// " comment-start) ;; default
) "BUG ")
(hack (cond
((derived-mode-p 'emacs-lisp-mode) ";; " comment-start)
((derived-mode-p 'python-mode) "# " comment-start)
((t) "// " comment-start) ;; default
) "HACK ")
latex-mode
(begin "\\begin{" (s env) "}" r> n> "\\end{" (s env) "}")
(frac "\\frac{" p "}{" q "}")
(enumerate "\\begin{enumerate}\n\\item " r> n> "\\end{enumerate}")
(itemize "\\begin{itemize}\n\\item " r> n> "\\end{itemize}")
lisp-mode emacs-lisp-mode ;; Specify multiple modes
(lambda "(lambda (" p ")" n> r> ")")
emacs-lisp-mode
(autoload ";;;###autoload")
(pt "(point)")
(lambda "(lambda (" p ")" n> r> ")")
(var "(defvar " p "\n \"" p "\")")
(local "(defvar-local " p "\n \"" p "\")")
(const "(defconst " p "\n \"" p "\")")
(custom "(defcustom " p "\n \"" p "\"" n> ":type '" p ")")
(face "(defface " p " '((t :inherit " p "))\n \"" p "\")")
(group "(defgroup " p " nil\n \"" p "\"" n> ":group '" p n> ":prefix \"" p "-\")")
(macro "(defmacro " p " (" p ")\n \"" p "\"" n> r> ")")
(alias "(defalias '" p " '" p ")")
(fun "(defun " p " (" p ")\n \"" p "\"" n> r> ")")
(iflet "(if-let (" p ")" n> r> ")")
(whenlet "(when-let (" p ")" n> r> ")")
(iflet* "(if-let* (" p ")" n> r> ")")
(whenlet* "(when-let* (" p ")" n> r> ")")
(andlet* "(and-let* (" p ")" n> r> ")")
(cond "(cond" n "(" q "))" >)
(pcase "(pcase " (p "scrutinee") n "(" q "))" >)
(let "(let (" p ")" n> r> ")")
(let* "(let* (" p ")" n> r> ")")
(rec "(letrec (" p ")" n> r> ")")
(dotimes "(dotimes (" p ")" n> r> ")")
(dolist "(dolist (" p ")" n> r> ")")
(loop "(cl-loop for " p " in " p " do" n> r> ")")
(command "(defun " p " (" p ")\n \"" p "\"" n> "(interactive" p ")" n> r> ")")
(advice "(defun " (p "adv" name) " (&rest app)" n> p n> "(apply app))" n>
"(advice-add #'" (p "fun") " " (p ":around") " #'" (s name) ")")
(provide "(provide '" (file-name-base (or (buffer-file-name) (buffer-name))) ")" n
";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name))) " ends here" n)
eshell-mode
(for "for " (p "i") " in " p " { " q " }")
(while "while { " p " } { " q " }")
(until "until { " p " } { " q " }")
(if "if { " p " } { " q " }")
(ife "if { " p " } { " p " } { " q " }")
(unl "unless { " p " } { " q " }")
(unle "unless { " p " } { " p " } { " q " }")
text-mode
(cut "--8<---------------cut here---------------start------------->8---" n r n
"--8<---------------cut here---------------end--------------->8---" n)
(asciibox "+-" (make-string (length str) ?-) "-+" n
"| " (s str) " |" n
"+-" (make-string (length str) ?-) "-+" n)
(rot13 (p "plain text" text) n "----" n (rot13 text))
(calc (p "taylor(sin(x),x=0,3)" formula) n "----" n (format "%s" (calc-eval formula)))
rst-mode
(title (make-string (length title) ?=) n (p "Title: " title) n (make-string (length title) ?=) n)
java-mode
(class "public class " (p (file-name-base (or (buffer-file-name) (buffer-name)))) " {" n> r> n "}")
c-mode :when (re-search-backward "^\\S-*$" (line-beginning-position) 'noerror)
(inc "#include <" (p (concat (file-name-base (or (buffer-file-name) (buffer-name))) ".h")) ">")
(incc "#include \"" (p (concat (file-name-base (or (buffer-file-name) (buffer-name))) ".h")) "\"")
js-mode js-ts-mode js2-mode typescript-mode typescript-ts-mode
(forEach "forEach((" p ") => { " q " })")
(for "for (let i = 0;" " i < " p "; i++) { " q " }")
(while "while (" p ") { " q " }")
(if "if (" p ") { " q " }")
(elseif "else if (" p ") { " q " }")
(else "else { " q " }")
(switch "switch (" p ") { " q " }")
(case "case " p ": " q "break")
(func "" p " (" p ") { " q " }")
(arrow "const " p " = (" p ") => { " q " }")
(log "console.log(" p ")")
(error "console.error(" p ")")
org-mode
(title "#+title: " p n "#+author: " user-full-name n "#+email: " user-mail-address n "#+date: " (format-time-string "%Y-%m-%d") n n)
(quote "#+begin_quote" n> r> n> "#+end_quote")
(quote "#+name: " p)
(example "#+begin_example" n> r> n> "#+end_example")
(center "#+begin_center" n> r> n> "#+end_center")
(comment "#+begin_comment" n> r> n> "#+end_comment")
(verse "#+begin_verse" n> r> n> "#+end_verse")
(src "#+begin_src " p n> r> n> "#+end_src" :post (org-edit-src-code))
(elisp "#+begin_src emacs-lisp" n> r> n "#+end_src" :post (org-edit-src-code))
;; Local Variables:
;; mode: lisp-data
;; outline-regexp: "[a-z]"
;; End: