1 ;; bootstart.el - Basic functions for literate scholium-based programming
3 ;; Copyright (C) 2012, 2013 Raymond S. Puzio
5 ;; This program is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU Affero General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU Affero General Public License for more details.
15 ;; You should have received a copy of the GNU Affero General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
24 (defun tangle-module (node retrieve-cont retrieve-links
)
26 (funcall retrieve-cont node
)
27 (funcall retrieve-links node
)
31 (defun insert-chunk (body chunks retrieve-cont retrieve-links
)
32 (cond ((null body
) nil
)
36 (cadr (assoc body chunks
))
40 (t (cons (insert-chunk (car body
) chunks retrieve-cont retrieve-links
)
41 (insert-chunk (cdr body
) chunks retrieve-cont retrieve-links
)))))
43 (defun node-fun (node retrieve-code
47 (funcall retrieve-vars node
)
49 (cons (mapcar (quote (lambda (item)
51 (funcall retrieve-vars
(cadr item
))))
54 (apply (node-fun (\
, (cadr item
))
55 (quote (\
, retrieve-code
))
56 (quote (\
, retrieve-vars
))
57 (quote (\
, retrieve-link
)))
58 (\
, (cons (quote list
) var-list
))))))))
59 (funcall retrieve-link node
))
60 (funcall retrieve-code node
)))))
63 (car (nth 0 (cdr (assoc n
(cdr article-list
))))))
66 (cdr (nth 0 (cdr (assoc n
(cdr article-list
))))))
69 (nth 1 (cdr (assoc n
(cdr article-list
)))))
72 (car (nth 2 (cdr (assoc n
(cdr article-list
))))))
75 (cdr (nth 2 (cdr (assoc n
(cdr article-list
))))))
78 (mapcar (quote car
) (cdr article-list
)))
85 (progn (let ((old-backlink
86 (nth 1 (assoc (get-src n
) (cdr article-list
)))))
87 (setcdr old-backlink
(delete n
(cdr old-backlink
))))
89 `(nth 1 (assoc x
(cdr article-list
)))))
90 (setcdr new-backlink
(cons n
(cdr new-backlink
))))
91 (setcar (nth 1 (assoc n
(cdr article-list
))) x
))))
94 (setcar (cdr (cdr (assoc n
(cdr article-list
)))) x
))
99 (progn (let ((old-backlink
100 (nth 3 (assoc (get-snk n
) (cdr article-list
)))))
101 (setcdr old-backlink
(delete n
(cdr old-backlink
))))
103 (nth 3 (assoc x
(cdr article-list
)))))
104 (setcdr new-backlink
(cons n
(cdr new-backlink
))))
105 (setcar (nth 3 (assoc n
(cdr article-list
))) x
))))
107 (defun ins-nod (src txt snk
)
108 (progn (setcdr article-list
109 (cons (list (car article-list
)
115 (nth 3 (assoc snk
(cdr article-list
)))))
116 (setcdr backlink
(cons (car article-list
) (cdr backlink
))))
118 (nth 1 (assoc src
(cdr article-list
)))))
119 (setcdr backlink
(cons (car article-list
) (cdr backlink
))))
120 (- (setcar article-list
(+ 1 (car article-list
))) 1)))
127 (progn (let ((old-backlink
128 (nth 3 (assoc (get-snk n
) (cdr article-list
)))))
129 (setcdr old-backlink
(delete n
(cdr old-backlink
))))
131 (nth 1 (assoc (get-src n
) (cdr article-list
)))))
132 (setcdr old-backlink
(delete n
(cdr old-backlink
))))
134 (delete (assoc n
(cdr article-list
))