2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4
;; MODULE : plugin-cmd.scm
5
;; DESCRIPTION : Commanding applications from TeXmacs and vice versa
6
;; COPYRIGHT : (C) 1999 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 (texmacs plugin plugin-cmd)
16
(:export pre-serialize verbatim-serialize generic-serialize plugin-serialize
17
plugin-serializer-set! format-command plugin-commander-set!
19
plugin-supports-completions-set! plugin-supports-completions?
20
plugin-supports-input-done-set! plugin-supports-input-done?))
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26
(define plugin-serializer (make-ahash-table))
28
(define (pre-serialize lan t)
29
(cond ((func? t 'document 1) (pre-serialize lan (cadr t)))
31
(pre-serialize lan (plugin-math-input (list 'tuple lan (cadr t)))))
34
(define (verbatim-serialize lan t)
35
(with u (pre-serialize lan t)
37
(escape-verbatim (texmacs->verbatim (object->tree u))) "\n")))
39
(define (generic-serialize lan t)
40
(with u (pre-serialize lan t)
41
(string-append (char->string #\002) "verbatim:"
42
(escape-generic (texmacs->verbatim (object->tree u)))
43
(char->string #\005))))
45
(define (plugin-serialize lan t)
46
(with fun (ahash-ref plugin-serializer lan)
49
(verbatim-serialize lan t))))
51
(define (plugin-serializer-set! lan val)
52
(ahash-set! plugin-serializer lan val))
54
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
58
(define plugin-commander (make-ahash-table))
60
(define (default-format-command s)
61
(string-append (char->string #\020) s "\n"))
63
(define (format-command lan s)
64
(with fun (ahash-ref plugin-commander lan)
67
(default-format-command s))))
69
(define (plugin-commander-set! lan val)
70
(ahash-set! plugin-commander lan val))
72
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
73
;; evaluation + simplification of documents with one paragraph
74
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
76
(define (plugin-output-simplify t)
77
(cond ((func? t 'document 1) (plugin-output-simplify (cadr t)))
78
((func? t 'with) (rcons (cDr t) (plugin-output-simplify (cAr t))))
81
(define (plugin-eval name session t)
82
(let* ((u (connection-eval name session (object->tree t)))
83
(v (plugin-output-simplify (tree->object u))))
86
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
88
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
90
(define plugin-supports-completions (make-ahash-table))
92
(define (plugin-supports-completions-set! key)
93
(ahash-set! plugin-supports-completions key #t))
95
(define (plugin-supports-completions? key)
96
(ahash-ref plugin-supports-completions key))
98
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
99
;; testing whether more input is needed
100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
102
(define plugin-supports-input-done (make-ahash-table))
104
(define (plugin-supports-input-done-set! key)
105
(ahash-set! plugin-supports-input-done key #t))
107
(define (plugin-supports-input-done? key)
108
(ahash-ref plugin-supports-input-done key))