2 (defvar simple-ui-buff
(list nil
(make-list 7 nil
) nil
))
3 ;; This variable stores three items: the buffer in which
4 ;; the nema is to be edited, markers inside that buffer
5 ;; which delimit the text which the user supplies, and
6 ;; the number of the nema being edited.
8 (defun simple-ui-init ()
9 "Initialize the buffer for editing nemata."
11 (let ((buff (get-buffer-create "nema-edit"))
14 (cl-flet ((add-rubric (pre mid post
)
31 'rear-nonsticky t
)))))
32 ;; Since the buffer may contain read-only
33 ;; text, we must inhibit the read-only
34 ;; property in order to erase such text.
35 (with-current-buffer buff
36 (let ((inhibit-read-only t
))
39 (push (make-marker) marx
))
40 (add-rubric "" "Editing nema" ":")
41 (push (- (point) 1) places
)
42 (push (+ (point) 1) places
)
43 (add-rubric "\n" "Source" ":")
44 (push (- (point) 1) places
)
46 (push (+ (point) 1) places
)
47 (add-rubric "\n" "Sink" ":")
48 (push (- (point) 1) places
)
50 (push (+ (point) 1) places
)
51 (add-rubric "\n" "Content" ":")
52 (push (- (point) 1) places
)
54 (mapply 'set-marker
`(,marx
,(reverse places
)))
55 (setq simple-ui-buff
(list buff marx nil
)))))
58 (defun simple-ui-load (nema)
59 "Load a nema into the editing buffer."
60 (interactive "xNema uid:")
63 ;; Helper function to figure out character
64 ;; positions between which text goes.
68 (nth n
(nth 1 simple-ui-buff
)))
71 (with-current-buffer (nth 0 simple-ui-buff
)
73 (delete-region (spot 0) (spot 1))
75 (insert (prin1-to-string nema
))
77 (delete-region (spot 2) (spot 3))
79 (insert (prin1-to-string (get-source nema
)))
81 (delete-region (spot 4) (spot 5))
83 (insert (prin1-to-string (get-sink nema
)))
85 (delete-region (spot 6) (spot 7))
87 (insert (prin1-to-string (get-content nema
)))
88 (setcar (cddr simple-ui-buff
) nema
))
92 (defun simple-ui-new ()
93 "Make a new nema and edit it."
99 (defun simple-ui-save ()
100 "Save the nema in the editing buffer."
102 (if (uid-p (nth 2 simple-ui-buff
))
104 ;; Helper function to figure out character
105 ;; positions between which text goes.
109 (nth n
(nth 1 simple-ui-buff
)))
112 (with-current-buffer (nth 0 simple-ui-buff
)
114 (nth 2 simple-ui-buff
)
115 (car (read-from-string
116 (buffer-substring (spot 2) (spot 3)))))
118 (nth 2 simple-ui-buff
)
119 (car (read-from-string
120 (buffer-substring (spot 4) (spot 5)))))
122 (nth 2 simple-ui-buff
)
123 (car (read-from-string
124 (buffer-substring (spot 6) (spot 7))))))
125 (nth 2 simple-ui-buff
))