aboutsummaryrefslogtreecommitdiff
path: root/ekdosis.el
blob: 845c004aef7ed7f30779fa0ae609f5680b8a7e35 (plain)
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
;;; ekdosis.el --- AUCTeX style for `ekdosis.sty'
;; This file is part of the `ekdosis' package

;; ekdosis -- TEI xml compliant critical editions
;; Copyright (C) 2020--2021  Robert Alessi

;; Please send error reports and suggestions for improvements to Robert
;; Alessi <alessi@robertalessi.net>

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see
;; <http://www.gnu.org/licenses/>.

(defvar LaTeX-ekdosis-preamble-options
  '(("parnotes" ("true" "false" "roman"))
    ("teiexport" ("true" "false" "tidy"))
    ("layout" ("float" "footins" "keyfloat" "fitapp"))
    ("divs" ("ekdosis" "latex"))
    ("poetry" ("verse"))
    ("parnotes" ("true" "false" "roman"))
    ("teiexport" ("true" "false" "tidy")))
  "Package options for the ekdosis package.")

(defun LaTeX-ekdosis-package-options ()
  "Prompt for package options for ekdosis package."
  (TeX-read-key-val t LaTeX-ekdosis-preamble-options))

(defun LaTeX-ekdosis-long-key-val (optional arg)
  (let ((crm-local-completion-map
	 (remove (assoc 32 crm-local-completion-map)
		 crm-local-completion-map))
	(minibuffer-local-completion-map
	 (remove (assoc 32 minibuffer-local-completion-map)
		 minibuffer-local-completion-map)))
    (TeX-argument-insert
     (TeX-read-key-val optional arg)
     optional)))

(defvar LaTeX-ekdosis-ekdsetup-options
  '(("showpagebreaks" ("true" "false"))
    ("spbmk")
    ("hpbmk"))
  "List of local options for ekdsetup macro.")

(defvar LaTeX-ekdosis-declarewitness-options
  '(("settlement")
    ("institution")
    ("repository")
    ("collection")
    ("idno")
    ("msName")
    ("origDate")
    ("locus"))
  "List of local options for DeclareWitness macro.")

(defvar LaTeX-ekdosis-declarehand-options
  '(("note"))
  "List of local options for DeclareHand macro.")

(defvar LaTeX-ekdosis-declarescholar-options
  '(("rawname")
    ("forename")
    ("surname")
    ("addname")
    ("note"))
  "List of local options for DeclareScholar macro.")

(defvar LaTeX-ekdosis-app-options
  '(("type"))
  "Local option for app|note macro.")

(defvar LaTeX-ekdosis-lem-options
  '(("wit")
    ("source")
    ("resp")
    ("alt")
    ("pre")
    ("post")
    ("prewit")
    ("postwit")
    ("sep")
    ("type")
    ("num")
    ("nonum")
    ("nolem" ("true" "false"))
    ("nosep" ("true" "false")))
  "Local options for lem macro")

(defvar LaTeX-ekdosis-rdg-options
  '(("wit")
    ("source")
    ("resp")
    ("alt")
    ("pre")
    ("post")
    ("prewit")
    ("postwit")
    ("type")
    ("nordg" ("true" "false")))
  "Local options for rdg macro.")

(defvar LaTeX-ekdosis-note-options
  '(("type")
    ("lem")
    ("labelb")
    ("labele")
    ("sep")
    ("nosep")
    ("num")
    ("nonum")
    ("pre")
    ("post"))
  "Local options for note macro.")

(defvar LaTeX-ekdosis-note-star-options
  '(("pre")
    ("post"))
  "Local options for note* macro.")

(defvar LaTeX-ekdosis-rdggrp-options
  '(("type"))
  "Local options for rdgGrp macro.")

(defvar LaTeX-ekdosis-setcritsymbols-options
  '(("suppbegin")
    ("suppend")
    ("delbegin")
    ("delend")
    ("sicbegin")
    ("sicend")
    ("gapmark"))
  "List of local options for setcritsymbols macro.")

(defvar LaTeX-ekdosis-sethooks-options
  '(("appfontsize")
    ("refnumstyle")
    ("postrefnum")
    ("lemmastyle")
    ("readingstyle")
    ("initialrule")
    ("noinitialrule")
    ("keyparopts")
    ("appheight")
    ("fitalgorithm" ("fontsize" "hybrid" "areasize" "squeeze")))
  "List of local options for sethooks macro.")

(defvar LaTeX-ekdosis-gap-options
  '(("reason")
    ("unit")
    ("quantity")
    ("extent"))
  "List of local options for gap macro.")

(defvar LaTeX-ekdosis-setapparatus-options
  '(("direction" ("LR" "RL"))
    ("sep")
    ("delim")
    ("bhook")
    ("ehook")
    ("rule")
    ("norule")
    ("lang")
    ("notelang"))
  "List of local options for setapparatus macro.")

(defvar LaTeX-ekdosis-declareapparatus-options
  '(("direction" ("LR" "RL"))
    ("sep")
    ("delim")
    ("bhook")
    ("ehook")
    ("rule")
    ("norule")
    ("lang")
    ("notelang")
    ("maxentries"))
  "List of local options for declareapparatus macro.")

(defvar LaTeX-ekdosis-setlineation-options
  '(("lineation" ("page" "document" "none"))
    ("sep")
    ("modulo")
    ("modulonum")
    ("margin" ("right" "left" "inner" "outer"))
    ("numbers" ("elided" "full"))
    ("vlineation" ("page" "document"))
    ("vmodulo")
    ("vmargin" ("right" "left"))
    ("continuousvnum"))
  "List of local options for setlineation macro.")

(defvar LaTeX-ekdosis-ekddiv-options
  '(("type")
    ("n")
    ("head")
    ("barehead")
    ("depth" ("1" "2" "3" "4" "5" "6" "7" "8" "9"))
    ("toc" ("book" "part" "chapter" "section" "subsection"
	    "subsubsection" "paragraph" "subparagraph"))
    ("mark"))
  "List of local options for ekddiv macro.")

(defvar LaTeX-ekdosis-setteixmlexport-options
  '(("autopar" ("true" "false")))
  "List of local options for SetTEIxmlExport macro.")

(defvar LaTeX-ekdosis-alignment-key-val-options
  '(("tcols")
    ("lcols")
    ("texts")
    ("apparatus")
    ("flush" ("true" "false"))
    ("paired" ("true" "false"))
    ("lineation" ("page" "document")))
  "Local options for alignment env.")

(defvar LaTeX-ekdosis-ekdverse-key-val-options
  '(("width")
    ("type"))
  "Local options for ekdverse env.")

(defvar LaTeX-ekdosis-ekdstanza-key-val-options
  '(("type"))
  "Local options for ekdstanza env.")

(TeX-add-style-hook
 "ekdosis"
 (lambda ()
   ;; Folding features:
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("{1}" ("app"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("{7}||{6}||{5}||{4}||{3}||{2}||{1}" ("lem"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("[r]" ("rdg"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("[n]" ("note"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("[l]" ("linelabel"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("{{1}}" ("surplus"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("<{1}>" ("supplied"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("{1}" ("sic"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("[g]" ("gap"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("{1}" ("mbox"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("{1}" ("rdgGrp"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("[pb]" ("ekdpb"))
   		t)
   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
   		'("[t]" ("teidirect"))
   		t)
   ;; This package relies on lualatex, so check for it:
   (TeX-check-engine-add-engines 'luatex)
   (TeX-add-symbols
    '("ekdsetup" (TeX-arg-key-val LaTeX-ekdosis-ekdsetup-options))
    '("DeclareWitness" "xml:id" "rendition" "description"
      [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-declarewitness-options ]
      0)
    '("DeclareHand" "xml:id" "base ms." "rendition"
      [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-declarehand-options ]
      0)
    '("DeclareSource" "xml:id" "rendition"
      0)
    '("DeclareScholar" "xml:id" "rendition"
      [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-declarescholar-options ]
      0)
    '("DeclareShorthand" "xml:id" "rendition" "csv-list of ids"
      0)
    '("getsiglum" "csv-list"
      0)
    '("SigLine" "unique id"
      0)
    '("linelabel" "label"
      0)
    '("app" [ TeX-arg-key-val LaTeX-ekdosis-app-options ]
      t)
    '("lem" [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-lem-options ]
      t)
    '("rdg" [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-rdg-options ]
      t)
    '("note" [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-note-options ]
      t)
    '("note*" [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-note-star-options ]
      t)
    '("rdgGrp" [ TeX-arg-key-val LaTeX-ekdosis-rdggrp-options ]
      t)
    '("SetCritSymbols" (TeX-arg-key-val LaTeX-ekdosis-setcritsymbols-options))
    '("supplied" "supplied text" 0)
    '("surplus" "surplus text" 0)
    '("gap" (TeX-arg-key-val LaTeX-ekdosis-gap-options))
    '("sic" "sic text" 0)
    '("SetAlignment"
      (TeX-arg-key-val LaTeX-ekdosis-alignment-key-val-options))
    '("columnratio" "fraction(s)" [ "fraction(s)" ] )
    '("setcolumnwidth" "width/gap" [ "width/gap" ] )
    '("marginparthreshold" "number of columns" [ "number of columns" ] )
    '("footnotelayout"
      (TeX-arg-eval completing-read
                    (TeX-argument-prompt nil nil "Layout")
                    '("c" "m" "p")))
    '("SetHooks" (TeX-arg-key-val LaTeX-ekdosis-sethooks-options))
    '("SetLTRapp" 0)
    '("SetRTLapp" 0)
    '("SetSeparator" "separator" 0)
    '("SetBeginApparatus" "chars|commands" 0)
    '("SetEndApparatus" "chars" 0)
    '("SetUnitDelimiter" "delimiter" 0)
    '("SetDefaultRule" "command" 0)
    '("SetApparatusLanguage" "lang name" 0)
    '("SetApparatusNoteLanguage" "lang name" 0)
    '("SetApparatus" (TeX-arg-key-val LaTeX-ekdosis-setapparatus-options))
    '("footnoteruletrue" 0)
    '("footnoterulefalse" 0)
    '("SetDefaultApparatus" "apparatus name" 0)
    '("DeclareApparatus" "apparatus name"
      [ TeX-arg-key-val LaTeX-ekdosis-declareapparatus-options ] 0)
    '("indentpattern" "pattern" 0)
    '("vin" 0)
    '("SetLineation" (TeX-arg-key-val LaTeX-ekdosis-setlineation-options))
    '("innerlinenumbers" 0)
    '("outerlinenumbers" 0)
    '("modulolinenumbers" [ "number" ] )
    '("resetlinenumber" [ "number" ] )
    '("resetvlinenumber" [ "number" ] )
    '("verselinenumfont" "commands" 0)
    '("SetLR" 0)
    '("SetRL" 0)
    '("MkBodyDivs" "div1" "div2" "div3" "div4" "div5" "div6" 0)
    '("ekddiv" (LaTeX-ekdosis-long-key-val LaTeX-ekdosis-ekddiv-options))
    '("FormatDiv" "number" "code before" "code after" 0)
    '("ekdmark" 0)
    '("endmark" 0)
    '("ekdprintmark"
      (TeX-arg-eval completing-read
                    (TeX-argument-prompt nil nil "selector")
                    '("HEL" "HEC" "HER" "HOL" "HOC" "HOR"
		      "FEL" "FEC" "FER" "FOL" "FOC" "FOR"))
      "signpost" 0 )
    '("ekdnohfmark" 0)
    '("ekdresethfmarks" 0)
    '("ekdpb" [ "page number" ] "line number" 0)
    '("ekdpb*")
    '("addentries" [ "layer" ] "number" 0)
    '("SetTEIFilename" "base name" 0)
    '("SetTEIxmlExport" (TeX-arg-key-val
			 LaTeX-ekdosis-setteixmlexport-options))
    '("TeXtoTEI" "csname" "TEI element" [ "TEI attributes" ] 0)
    '("EnvtoTEI" "env name" "TEI element" [ "TEI attributes" ] 0)
    '("EnvtoTEI*" "env name" "TEI element" [ "TEI attributes" ] 0)
    '("TeXtoTEIPat" "TeX pattern" "TEI pattern" 0)
    '("teidirect" [ "xml attributes" ] "xml element" "code" 0)
    '("AddxmlBibResource" "basename or name.xml" 0)
    )
 (LaTeX-add-environments
  "ekdosis"
  "edition"
  "translation"
  "edition*"
  "translation*"
  "patverse"
  "ekdpar"
  '("alignment" LaTeX-env-args
    [ TeX-arg-key-val LaTeX-ekdosis-alignment-key-val-options ] )
  '("ekdverse" LaTeX-env-args
    [ TeX-arg-key-val LaTeX-ekdosis-ekdverse-key-val-options ] )
  '("ekdstanza" LaTeX-env-args
    [ TeX-arg-key-val LaTeX-ekdosis-ekdstanza-key-val-options ] )
  )
 )
 LaTeX-dialect)

;;; ekdosis.el ends here