2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4
;; MODULE : prologue.scm
5
;; DESCRIPTION : subroutines which are not well implemented in guile
6
;; COPYRIGHT : (C) 2003 Joris van der Hoeven
8
;; This software falls under the GNU general public license and comes WITHOUT
9
;; ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for details.
10
;; If you don't have this file, write to the Free Software Foundation, Inc.,
11
;; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
(texmacs-module (kernel boot prologue)
16
(:use (kernel boot ahash-table))
18
list->module ;; for module-load macro
20
set-symbol-procedure! symbol-procedure
23
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24
;; Additional support for loading modules
25
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27
(define module-loaded-table (make-ahash-table))
29
(define (list->module module)
30
(let* ((aux (lambda (s) (string-append "/" (symbol->string s))))
31
(name* (apply string-append (map aux module)))
32
(name (substring name* 1 (string-length name*)))
33
(u (url "$GUILE_LOAD_PATH" (string-append name ".scm"))))
34
(url-materialize u "r")))
36
(define (module-load module*)
38
(let* ((module (list->module module*))
39
(loaded (ahash-ref module-loaded-table module)))
40
(ahash-set! module-loaded-table module #t)
41
;(if (not loaded) (display* "TeXmacs] Loading module " module* "\n"))
42
(if (not loaded) (load-module module)))))
44
;; FIXME: why does this not work?
45
;(define (module-load name)
46
; (module-use! (current-module) (resolve-module name)))
48
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49
;; Work around broken 'symbol-property'
50
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52
(define symbol-procedure-table (make-ahash-table))
54
(define (set-symbol-procedure! symb proc)
55
(ahash-set! symbol-procedure-table symb proc))
57
(define (symbol-procedure symb)
58
(ahash-ref symbol-procedure-table symb))
60
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64
(define (list-sort-insert x l comp?)
65
(cond ((null? l) (list x))
66
((comp? x (car l)) (cons x l))
67
(else (cons (car l) (list-sort-insert x (cdr l) comp?)))))
69
(define (list-sort l comp?)
70
"Sort @l using the comparison @comp?."
71
;; Should be replaced by built-in 'sort' routine later on (Guile > 1.3.4)
73
(let ((r (list-sort (cdr l) comp?)))
74
(list-sort-insert (car l) r comp?))))