6 (defvar simple-ui-buff
(list nil
(make-list 7 nil
) nil
))
7 ;; This variable stores three items: the buffer in which
8 ;; the nema is to be edited, markers inside that buffer
9 ;; which delimit the text which the user supplies, and
10 ;; the number of the nema being edited.
12 (defun simple-ui-init ()
13 "Initialize the buffer for editing nemata."
15 (let ((buff (get-buffer-create "nema-edit"))
18 (cl-flet ((add-rubric (pre mid post
)
35 'rear-nonsticky t
)))))
36 ;; Since the buffer may contain read-only
37 ;; text, we must inhibit the read-only
38 ;; property in order to erase such text.
39 (with-current-buffer buff
40 (let ((inhibit-read-only t
))
43 (push (make-marker) marx
))
44 (add-rubric "" "Editing nema" ":")
45 (push (- (point) 1) places
)
46 (push (+ (point) 1) places
)
47 (add-rubric "\n" "Source" ":")
48 (push (- (point) 1) places
)
50 (push (+ (point) 1) places
)
51 (add-rubric "\n" "Sink" ":")
52 (push (- (point) 1) places
)
54 (push (+ (point) 1) places
)
55 (add-rubric "\n" "Content" ":")
56 (push (- (point) 1) places
)
58 (mapply 'set-marker
`(,marx
,(reverse places
)))
59 (setq simple-ui-buff
(list buff marx nil
)))))
62 (defun simple-ui-load (nema)
63 "Load a nema into the editing buffer."
64 (interactive "xNema uid:")
67 ;; Helper function to figure out character
68 ;; positions between which text goes.
72 (nth n
(nth 1 simple-ui-buff
)))
75 (with-current-buffer (nth 0 simple-ui-buff
)
77 (delete-region (spot 0) (spot 1))
79 (insert (prin1-to-string nema
))
81 (delete-region (spot 2) (spot 3))
83 (insert (prin1-to-string (get-source nema
)))
85 (delete-region (spot 4) (spot 5))
87 (insert (prin1-to-string (get-sink nema
)))
89 (delete-region (spot 6) (spot 7))
91 (insert (prin1-to-string (get-content nema
)))
92 (setcar (cddr simple-ui-buff
) nema
))
96 (defun simple-ui-new ()
97 "Make a new nema and edit it."
100 (put-article 0 0 "")))
103 (defun simple-ui-save ()
104 "Save the nema in the editing buffer."
106 (if (uid-p (nth 2 simple-ui-buff
))
108 ;; Helper function to figure out character
109 ;; positions between which text goes.
113 (nth n
(nth 1 simple-ui-buff
)))
116 (with-current-buffer (nth 0 simple-ui-buff
)
118 (nth 2 simple-ui-buff
)
119 (car (read-from-string
120 (buffer-substring (spot 2) (spot 3)))))
122 (nth 2 simple-ui-buff
)
123 (car (read-from-string
124 (buffer-substring (spot 4) (spot 5)))))
126 (nth 2 simple-ui-buff
)
127 (car (read-from-string
128 (buffer-substring (spot 6) (spot 7))))))
129 (nth 2 simple-ui-buff
))