-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmy-sgml-funcs.el
239 lines (205 loc) · 5.99 KB
/
my-sgml-funcs.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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
(setq sgml-basic-offset 0)
(define-skeleton html-paragraph
"HTML paragraph tag."
nil
(if (bolp) nil ?\n)
\n "<p>" \n _ \n "</p>" \n \n )
(define-skeleton html-emphasis
"HTML emphasis mode."
nil
"<em>" _ "</em>")
(define-skeleton html-bold
"HTML bold mode."
nil
"<b>" _ "</b>")
(define-skeleton html-typewriter
"HTML typewriter mode."
nil
"<tt>" _ "</tt>")
(define-skeleton html-code
"HTML code mode."
nil
"<code>" _ "</code>")
(define-skeleton html-code-block
"HTML code block."
nil
(if (bolp) nil ?\n)
\n "<pre class='code'>" \n _ \n "</pre>" \n \n )
(define-skeleton html-entity-lt
"HTML less than entity."
nil
"<")
(define-skeleton html-entity-gt
"HTML greater than entity."
nil
">")
(define-skeleton insert-mdash
"Insert an mdash entity at point"
nil
"—"
)
(define-skeleton google-link
"HTML anchor tag with href attribute."
"word: "
'(setq input "")
"<a href=\"http://www.google.com/search?q=" str "\">" str "</a>")
(define-skeleton twitter-link
"HTML anchor tag with href attribute."
"twitter ID: "
'(setq input "")
"<a href=\"http://www.twitter.com/" str "\">@" str "</a>")
(define-skeleton wikipedia-link
"HTML anchor tag with href attribute."
"word: "
'(setq input "")
"<a href=\"http://en.wikipedia.org/wiki/" str "\">" str "</a>")
(define-skeleton twitter-link
"Twitter link"
"twitter id without the @: "
'(setq input "")
"<a href=\"http://twitter.com/" str "\">@" str "</a>")
(define-skeleton tag-link
"HTML anchor tag with href attribute."
"tag: "
'(setq input "")
"<a href=\"http://www.windley.com/tags/" str "\">" str "</a>")
(define-skeleton amazon-image
"HTML image tag for an Amazon book"
"ASIN: "
'(setq input "")
"<a href=\"http://www.amazon.com/exec/obidos/ASIN/" str "/windleyofente-20\"><img src=\"http://images.amazon.com/images/P/" str ".01.MZZZZZZZ.jpg\" border=\"0\" align=\"right\" hspace=\"5\" vspace=\"5\" /></a>"
)
(define-skeleton amazon-link
"HTML anchor for an Amazon book"
"ASIN: "
'(setq input "")
"<a href=\"http://www.amazon.com/exec/obidos/ASIN/" str "/windleyofente-20\">" _ "</a>"
)
(define-skeleton mp3-player
"HTML image tag for an Amazon book"
"MP3 URL: "
'(setq input "")
"<embed type=\"application/x-shockwave-flash\" flashvars=\"audioUrl=" str "\" src=\"http://www.google.com/reader/ui/3523697345-audio-player.swf\" width=\"400\" height=\"27\" quality=\"best\"></embed>"
)
(define-skeleton readings
"HTML for what I'm reading"
nil
'(setq v1 nil
v2 nil)
("Value: "
"<li><a href=\"" (skeleton-read "URL: ")
"\">" (skeleton-read "Anchor: ")
"</a> - "(skeleton-read "Commentary: ")"</li>"
\n))
(define-skeleton ruleset-image
"HTML anchor and card image for a Kynetx ruleset"
"RID: "
'(setq input "")
"<a href=\"http://apps.kynetx.com/app/"str"\"><img style=\"margin-top: 10px; margin-left:10px\" src=\"http://appresource.s3.amazonaws.com/appdir/" str "/appimage.jpg\" border=\"0\" hspace=\"3\" vspace=\"3\" align=\"right\" title=\"Kynetx App\" alt=\"Kynetx Logo\" width=\"150px\" /></a>"
)
(define-skeleton ruleset-link
"HTML anchor for a Kynetx ruleset in the app directory"
"RID: "
'(setq input "")
"<a href=\"http://apps.kynetx.com/app/"str"\">" _ "</a>"
)
(define-skeleton picture-table
"Create a table of pictures"
nil
'(setq v1 nil
v2 nil)
"<table cellpadding=\"5\" border=\"0\" width=\"90%\"><tr>"
("picture thumbnail: "
(if (not (string-equal v2 "")) (identity "<tr>") "")
\n
-1
"<td valign=\"top\" align=\"center\">"
\n
" <a href=\"" (setq v1 (skeleton-read "picture url: "))
"\">" \n "<img src=\"" str
"\" border=\"1\" />" \n "</a>"
" <div class=\"caption\">"
(skeleton-read "caption: " "")
"</div>"
\n
"</td>"
(setq v2 (if (y-or-n-p "End of row? ")
(funcall skeleton-transformation "</tr>") ""))
\n
-2
\n)
resume:
"</table>"
\n
)
(define-skeleton make-event
"Create HTML for hCalendar formatted event"
nil
'(setq v1 nil
v2 nil
v3 nil
y1 nil
m1 nil
d1 nil
h1 nil
mi1 nil
yc (format-time-string "%Y")
mc (format-time-string "%m")
dc (format-time-string "%d")
hc (format-time-string "%H")
mic (format-time-string "%M")
duration 1
)
"<div class=\"vevent\">"
\n
"<span class=\"summary\"><a href=\""
(or v2 (setq v3 (skeleton-read "URL: ")))
"\">"
(or v2 (setq v2 (skeleton-read "What: ")))
"</a></span> on <abbr class=\"dtstart\" title=\""
(format "%04d%02d%02dT%02d%02d00"
(or y1 (setq y1 (string-to-number (skeleton-read "Start Year: " yc))))
(or m1 (setq m1 (string-to-number (skeleton-read "Start Month: " mc))))
(or d1 (setq d1 (string-to-number (skeleton-read "Start Day: " dc))))
(or h1 (setq h1 (string-to-number (skeleton-read "Start Hour: " hc))))
(or mi1 (setq mi1 (string-to-number (skeleton-read "Start Minute: " mic))))
)
"\">"
(format-time-string "%B" (encode-time 0 mi1 h1 d1 m1 y1)) " "
(number-to-string d1) ", "
(number-to-string y1) " from "
(number-to-string h1) ":" (format "%02d" mi1)
"</abbr> until <abbr class=\"dtend\" title=\""
(format "%04d%02d%02dT%02d%02d00"
y1
m1
d1
(setq h2 (+ h1 duration))
mi1
)
"\">"
(number-to-string h2) ":" (format "%02d" mi1)
"</abbr> at "
"<span class=\"location\">"
(or v1 (setq v1 (skeleton-read "Where: "))) "</span>"
\n
"</div>"
)
(defun markdown-preview-file ()
"run Marked on the current file and revert the buffer"
(interactive)
(shell-command
(format "open -a '/Applications/Marked 2.app' %s"
(shell-quote-argument (buffer-file-name))))
)
(let ((map html-mode-map))
(define-key map "\C-c\C-ee" 'html-emphasis)
(define-key map "\C-c\C-eb" 'html-bold)
(define-key map "\C-c\C-et" 'html-typewriter)
(define-key map "\C-c\C-ec" 'html-code)
(define-key map "\C-c>" 'html-entity-gt)
(define-key map "\C-c<" 'html-entity-lt)
(define-key map "\C-c-" 'insert-mdash)
(define-key map "\C-cp" 'html-code-block)
(define-key map "\C-c\C-cn" 'html-name-anchor)
)