1 (defun riece-insert-struct-template (prefix struct) -*- lexical-binding: t -*-
2 (interactive "sPrefix: \nsStruct: ")
11 (not (string-match "-\\'" prefix)))
12 (setq prefix (concat prefix "-")))
15 (setq name (read-from-minibuffer "Attribute: "))
20 (y-or-n-p "Optional? ")
21 (y-or-n-p "Readable? ")
22 (y-or-n-p "Writable? "))
24 (setq attributes (nreverse attributes)
25 pointer (cons (vector "" nil nil nil) attributes))
27 (if (aref (car (cdr pointer)) 1)
29 (setq optional-attributes (cons (car (cdr pointer))
31 (setcdr pointer (nthcdr 2 pointer)))
32 (setq pointer (cdr pointer))))
33 (setq optional-attributes (nreverse optional-attributes)
34 arglist (mapconcat (lambda (attribute)
37 (if optional-attributes
38 (setq arglist (concat arglist " &optional "
39 (mapconcat (lambda (attribute)
41 optional-attributes " "))))
42 (setq strings (list (format "\
43 \(defun %smake-%s (%s)
48 (mapconcat (lambda (attribute)
53 (setq pointer (append attributes optional-attributes))
55 (if (aref (car pointer) 2)
56 (setq strings (cons (format "\
60 prefix struct (aref (car pointer) 0)
62 (aref (car pointer) 0)
66 (if (aref (car pointer) 3)
67 (setq strings (cons (format "\
68 \(defun %s%s-set-%s (%s %s)
69 \"Set %s of %s to %s.\"
71 prefix struct (aref (car pointer) 0)
72 struct (aref (car pointer) 0)
73 (aref (car pointer) 0)
75 (upcase (aref (car pointer) 0))
76 struct index (aref (car pointer) 0))
78 (setq pointer (cdr pointer)
80 (insert (mapconcat #'identity (nreverse strings) "\n\n"))))