Debian Codegraph @

texmf-dist/doc/latex/struktex/struktex.el

raw
1 ;;; struktex.el -*-coding: utf-8; lexical-binding: t-*-
2 ;;; AUCTeX style for `struktex.sty'
3
4 ;; Copyright (C) 2006 - 2025 Free Software Foundation, Inc.
5
6 ;; Author: J. Hoffmann <j.hoffmann_(at)_fh-aachen.de>
7 ;; Maintainer: j.hoffmann_(at)_fh-aachen.de
8 ;; Created: 2017/06/06
9 ;; Keywords: tex
10
11 ;;; Commentary:
12 ;; This file adds support for `struktex.sty'
13
14 ;;; Code:
15
16 (TeX-add-style-hook
17 "struktex"
18 (lambda ()
19 ;; Add declaration to the list of environments which have
20 ;; an optional argument for each item.
21 (add-to-list 'LaTeX-item-list
22 '("declaration" . LaTeX-item-argument))
23 (LaTeX-add-environments
24 "centernss"
25 '("struktogramm" LaTeX-env-struktogramm)
26 '("declaration" LaTeX-env-declaration))
27 (TeX-add-symbols
28 '("PositionNSS" 1)
29 '("assert" [ "Height" ] "Assertion")
30 '("assign" [ "Height" ] "Statement")
31 "StrukTeX"
32 '("case" TeX-mac-case)
33 "switch" "Condition"
34 "caseend"
35 '("declarationtitle" "Title")
36 '("description" "Name" "Meaning")
37 "emptyset"
38 '("exit" [ "Height" ] "What" )
39 '("forever" TeX-mac-forever)
40 "foreverend"
41 '("forallin" TeX-mac-forallin)
42 "forallin"
43 '("ifthenelse" TeX-mac-ifthenelse)
44 "change"
45 "ifend"
46 '("inparallel" TeX-mac-inparallel)
47 '("task" "Description")
48 "inparallelend"
49 "sProofOn"
50 "sProofOff"
51 '("until" TeX-mac-until)
52 "untilend"
53 '("while" TeX-mac-while)
54 "whileend"
55 '("return" [ "Height" ] "Return value")
56 '("sub" [ "Height" ] "Task")
57 '("CenterNssFile" TeX-arg-file)
58 '("centernssfile" TeX-arg-file))
59 (TeX-run-style-hooks
60 "pict2e"
61 "emlines2"
62 "curves"
63 "struktxp"
64 "struktxf"
65 "ifthen")
66 ;; Filling
67 ;; Fontification
68 ))
69
70 (defun LaTeX-env-struktogramm (environment)
71 "Insert ENVIRONMENT with width, height specifications and
72 optional title."
73 (let ((width (read-string "Width: "))
74 (height (read-string "Height: "))
75 (title (read-string "Title (optional): ")))
76 (LaTeX-insert-environment environment
77 (concat
78 (format "(%s,%s)" width height)
79 (if (not (zerop (length title)))
80 (format "[%s]" title))))))
81
82 (defun LaTeX-env-declaration (environment)
83 "Insert ENVIRONMENT with an optional title."
84 (let ((title (read-string "Title (optional): ")))
85 (LaTeX-insert-environment environment
86 (if (not (zerop (length title)))
87 (format "[%s]" title)))))
88
89 (defun TeX-mac-case (macro)
90 "Insert \\case with all arguments, the needed \\switch(es) and
91 the final \\caseend. These are optional height and the required
92 arguments slope, number of cases, condition, and the texts for
93 the different cases"
94 (let ((height (read-string "Height (optional): "))
95 (slope (read-string "Slope: "))
96 (number (read-string "Number of cases: "))
97 (condition (read-string "Condition: "))
98 (text (read-string "Case no. 1: "))
99 (count 1)
100 )
101 (setq number-int (string-to-number number))
102 (insert (concat (if (not (zerop (length height)))
103 (format "[%s]" height))
104 (format "{%s}{%s}{%s}{%s}"
105 slope number condition text)))
106 (while (< count number-int)
107 (end-of-line)
108 (newline-and-indent)
109 (newline-and-indent)
110 (setq prompt (format "Case no. %d: " (+ 1 count)))
111 (insert (format "\\switch{%s}" (read-string prompt)))
112 (setq count (1+ count)))
113 (end-of-line)
114 (newline-and-indent)
115 (newline-and-indent)
116 (insert "\\caseend")))
117
118 (defun TeX-mac-forallin (macro)
119 "Insert \\forallin-block with all arguments.
120 This is the optional height and the description of the loop"
121 (let ((height (read-string "Height (optional): "))
122 (loop-description (read-string "Description of loop: ")))
123 (insert (concat (if (not (zerop (length height)))
124 (format "[%s]" height))
125 (format "{%s}"
126 loop-description)))
127 (end-of-line)
128 (newline-and-indent)
129 (newline-and-indent)
130 (insert "\\forallinend")))
131
132 (defun TeX-mac-forever (macro)
133 "Insert \\forever-block with all arguments.
134 This is only the optional height"
135 (let ((height (read-string "Height (optional): ")))
136 (insert (if (not (zerop (length height)))
137 (format "[%s]" height)))
138 (end-of-line)
139 (newline-and-indent)
140 (newline-and-indent)
141 (insert "\\foreverend")))
142
143 (defun TeX-mac-ifthenelse (macro)
144 "Insert \\ifthenelse with all arguments.
145 These are optional height and the required arguments
146 left slope, right slope, condition, and the possible
147 values of the condition"
148 (let ((height (read-string "Height (optional): "))
149 (lslope (read-string "Left slope: "))
150 (rslope (read-string "Right slope: "))
151 (condition (read-string "Condition: "))
152 (conditionvl (read-string "Condition value left: "))
153 (conditionvr (read-string "Condition value right: ")))
154 (insert (concat (if (not (zerop (length height)))
155 (format "[%s]" height))
156 (format "{%s}{%s}{%s}{%s}{%s}"
157 lslope rslope condition conditionvl
158 conditionvr)))
159 (end-of-line)
160 (newline-and-indent)
161 (newline-and-indent)
162 (insert "\\change")
163 (end-of-line)
164 (newline-and-indent)
165 (newline-and-indent)
166 (insert "\\ifend")))
167
168 (defun TeX-mac-inparallel (macro)
169 "Insert \\inparallel with all arguments, the needed \\task(s)
170 and the final \\inparallelend. These are optional height and the
171 required arguments number of tasks and the descriptions for the
172 parallel tasks"
173 (let ((height (read-string "Height (optional): "))
174 (number (read-string "Number of parallel tasks: "))
175 (text (read-string "Task no. 1: "))
176 (count 1)
177 )
178 (setq number-int (string-to-number number))
179 (insert (concat (if (not (zerop (length height)))
180 (format "[%s]" height))
181 (format "{%s}{%s}" number text)))
182 (while (< count number-int)
183 (end-of-line)
184 (newline-and-indent)
185 (newline-and-indent)
186 (setq prompt (format "Task no. %d: " (+ 1 count)))
187 (insert (format "\\task{%s}" (read-string prompt)))
188 (setq count (1+ count)))
189 (end-of-line)
190 (newline-and-indent)
191 (newline-and-indent)
192 (insert "\\inparallelend")))
193
194 (defun TeX-mac-until (macro)
195 "Insert \\until with all arguments.
196 These are the optional height and the required argument condition"
197 (let ((height (read-string "Height (optional): "))
198 (condition (read-string "Condition: ")))
199 (insert (concat (if (not (zerop (length height)))
200 (format "[%s]" height))
201 (format "{%s}" condition)))
202 (end-of-line)
203 (newline-and-indent)
204 (newline-and-indent)
205 (insert "\\untilend")))
206
207 (defun TeX-mac-while (macro)
208 "Insert \\while with all arguments.
209 These are the optional height and the required argument condition"
210 (let ((height (read-string "Height (optional): "))
211 (condition (read-string "Condition: ")))
212 (insert (concat (if (not (zerop (length height)))
213 (format "[%s]" height))
214 (format "{-%s-}" condition)))
215 (end-of-line)
216 (newline-and-indent)
217 (newline-and-indent)
218 (insert "\\whileend")))
219
220 (defvar LaTeX-struktex-package-options '("curves" "debug"
221 "draft" "emlines" "final"
222 "fixedindent" "nofiller"
223 "outer" "pict2e" "verification")
224 "Package options for the struktex package.")
225
226 ;;; struktex.el ends here.
227