/
templates
149 lines (128 loc) · 5.7 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
;; -*- 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)")
;;;; org-mode
org-mode
(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\"")
(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)
;;;;; Consider "The One Ring" minor mode to inject these.
(rune "{{{rune(" (completing-read "Rune: " jf/gaming/runes) ")}}}")
(asl "As {{{i(Loremaster)}}}, ")
;;;; 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) ?=))
;;;; 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 " }")