-
Notifications
You must be signed in to change notification settings - Fork 2
/
templates
188 lines (163 loc) · 7.63 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
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
;; -*- mode: lisp -*-
;;; Commentary
;;
;; Organize this file by mode then by abbreviation. Multi-modes have their own
;; section
;;; Single Mode Entries
;;;; emacs-lisp
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) ")")
(package ";;; " (file-name-base (or (buffer-file-name) (buffer-name))) " --- " p " -*- lexical-binding: t -*-"
n n
";; Copyright (C) " (format-time-string "%Y") " Jeremy Friesen" n
";; Author: Jeremy Friesen <jeremy@jeremyfriesen.com>" n n
";; This file is NOT part of GNU Emacs." n
";;; Commentary:" n p n
";;; Code:" n p n
"(provide '" (file-name-base (or (buffer-file-name) (buffer-name))) ")" n
";;; " (file-name-nondirectory (or (buffer-file-name) (buffer-name))) " ends here" n)
;;;; fundamental-mode
fundamental-mode
;;;; markdown-mode
markdown-mode markdown-ts-mode
(tor "[Take on Rules](https://takeonrules.com)")
(ghcallout "> [!" (p (completing-read "Callout Type:" '("NOTE" "TIP" "IMPORTANT" "CAUTION" "WARNING") nil t)) "]" n "> " q)
;;;; org-mode
org-mode
(utoday "[[date:" (format-time-string "%Y-%m-%d") "][Today]]")
(ltoday "[[date:" (format-time-string "%Y-%m-%d") "][today]]")
(beamer
n "#+OPTIONS: H:2 num:t"
n "#+BEAMER_THEME: Madrid"
n "#+LATEX_CLASS: beamer"
n "#+TOC: headlines [currentsection]"
n "#+STARTUP: beamer"
n "#+latex_header: \\AtBeginSection[]{\\begin{frame}<beamer>\\frametitle{Topic}\\tableofcontents[currentsection]\\end{frame}}" n)
(eg "([[abbr:20230824T082549][e.g.]], " q ")")
(aka "([[abbr:20221009T115519][a.k.a.]] " q ")")
(dnd "[[abbr:20221009T115753][D&D]] " q )
(rpg "[[abbr:20221009T115226][RPG]] " q)
(ie "[[abbr:20230825T130802][i.e.]] " q "")
(clocktable "#+BEGIN: clocktable :scope file :tcolumns 1 :block untilnow :narrow 80! :step year :stepskip0 t :fileskip0 t :filetitle t\n#+END:")
;; (lore24-transclude "#+TRANSCLUDE: [[id:" p "]] :only-contents :exclude-elements \"drawer keyword headline\"")
(ntable "#+CAPTION: " (p "Caption: " caption) n "#+NAME: " (jf/tor-convert-text-to-slug caption) n "|" q "|" n)
;; (tsomb-date (p "Day: " day t) "[[date:1627-05-" (format "%02d" (string-to-number day)) "][May " day "]]" q)
(local-var "# -*- " (p "Variable name: ")": " (p "Value: ") "; -*-")
(macro-cite "{{{cite(" (p (completing-read "Cite: " (jf/org-macro-value-list "cite"))) ")}}}")
(macro-keyboard "{{{kbd(" (p (completing-read "Keyboard: " (jf/org-macro-value-list "kbd"))) ")}}}")
(macro-idiomatic "{{{i(" (p (completing-read "Idiom: " (jf/org-macro-value-list "i"))) ")}}}")
(macro-mechanic "{{{m(" (p (completing-read "Mechanic: " (jf/org-macro-value-list "m(?:echanic)?"))) ")}}}")
(errant-monster "** " (p "Monster Name") n
":PROPERTIES:" n
":ID: " (org-id-new) n
":SOURCE:" p n
":THREAT: " p n
":HP: " p n
":ATTACKS: " p n
":MD: " p n
":MORALE: " p n
":ALIGNMENT: " p n
":END:" n q)
(update_block "#+attr_shortcode: :date " (format-time-string "%Y-%m-%d")
" :mode " (p (completing-read "Mode: " '(inline paragraph marginnote sidenote section fallback) nil t) mode)
n "#+begin_update"
n q
n "#+end_update" n)
(verb_block
(p (completing-read "Method: " '("get" "post" "put") nil t) method t)
(p (read-string "URL: ") url t)
(p (completing-read "Content-Type: " '("text/html" "text/plain" "application/json" "application/xml") nil t) type t)
"#+begin_src verb :wrap src ob-verb-response" n
> method " " url n
> "Content-Type: " type "; charset=utf-8" n
> q
"#+end_src")
;;;; text-mode
text-mode
;; This is an example of using the value of `(s str)' to populate the above and
;; below line!
(asciibox "+-" (make-string (length str) ?-) "-+" n
"| " (s str) " |" n
"+-" (make-string (length str) ?-) "-+" n)
;; (banner comment-start (make-string (length title) ?=) n comment-start (p "Title: " title) n comment-start (make-string (length title) ?=))
go-ts-mode go-mode
(db "runtime.Breakpoint()" n)
(tnew "package " p "_test" n n "import(" n " \"testing\"" n " \"github.com/stretchr/testify/assert\"" n ")" n n "func Test" p "(t *testing.T) {" n q n " assert.Nil(t, nil)" n "}")
(thelper "func helper" p "(t *testing.T) {" n > "t.Helper()" n > q n "}")
(tfunc "func Test" p "(t *testing.T) {" n > q n "}")
(trun "t.Run(\"" p "\", func(t *testing.T) {" n > q n "})")
(ttable "test_cases := struct {" n > p n "}{" n > "{" p "}" n "}" n n "for _, test_case := range test_cases {" n > q n "}")
(options "type " (p "Options for: " optInterface) "Option interface {"
n> "apply(*" optInterface ")" n
"}"
n n"type " (string-inflection-camelcase-function optInterface) "Option_" (p "Option Name: " withOpt) " struct {}"
n n "func (o " (string-inflection-camelcase-function optInterface) "Option_" withOpt ") apply(i *" optInterface ") {"
n> "// Make it so!"
n> q
n "}"
n n "func " optInterface "Option_" withOpt "() " optInterface "Option {"
n> "return " (string-inflection-camelcase-function optInterface) "Option_" withOpt "{}"
n "}")
;;;; web-mode
web-mode
(bb "<% byebug %>" n)
(db "<% require \"debug\"; binding.break %>" n)
(tor "<cite><a href=\"https://takeonrules.com\">Take on Rules</a></cite>")
(today "<time datetime=\"" (format-time-string "%Y-%m-%d") "\">today</time>")
;;; Multi-Mode Entries
;;;; enh-ruby-mode ruby-mode
enh-ruby-mode ruby-mode rspec-mode ruby-ts-mode
(bench "require \"benchmark\"" n "Benchmark.bmbm do |b|" n " b.report(\"\") do" n " # Stuff" n " end" n "end")
(cattr > "##" n>
"# @!group Class Attributes" n>
"#" n>
"# @!attribute " (s attr) n>
"# " p n>
"class_attribute :" attr ", " q n>
"# @!endgroup Class Attributes" n>
"##")
(db (jf/require-debugger) n)
(frozen "# frozen_string_literal: true")
(shell "#!/usr/bin/env ruby -w")
(dc "described_class")
(rspec "# frozen_string_literal: true" n n "require 'spec_helper'" n n "RSpec.describe " q " do" n n "end")
(subject "subject(:" p ") { " p " }")
(struct p " = Struct.new(" p ", keyword_init: true)")
;; A little experiment in mixing tempel behavior and multiple values.
(init (p "Parameters (comma separated): " given-params t)
(let* ((params (mapcar #'s-trim (s-split "," given-params)))
(kwargs (mapcar (lambda (el) (concat el ":")) params))
(symbols (mapcar (lambda (el) (concat ":" el)) params)))
(dolist (param params) (insert "# @param " param " [Object]\n"))
(insert "def initialize(" (s-join ", " kwargs) ")\n")
(dolist (param params) (insert " @" param " = " param "\n"))
(insert "end\n\n"
"attr_reader " (s-join ", " symbols) "\n")))
(it_is "it { is_expected.to " q " }")