As @jeroen says you are not using properly the quotation mechanism. There are two quotations notations, the one you are using '(code ...)
(with apostrophe) and another one `(code ....)
(with backtick), it is called “quasi quote”. This second one allow an “escape” back to evaluation mode (unquoting) with ,
(comma), so your code should read instead
(define (centered-pygments language)
(insert
`(code
(document
(script-input "pygments" "default"
(document ,(string-append "%" language "; texmacs")))))))
note the backtick and the comma in the right places. The quasi quoting mechanism and be freely mixed with the quoting and also iterated. Note there is another operator ,@
(comma-at) which evaluates an expression that should return a list and then splice the list in the outer expression., example:
`(1 2 3 ,@(list 4 5 6)) == '(1 2 3 4 5 6)
compare with
`(1 2 3 ,(list 4 5 6)) == '(1 2 3 (4 5 6))
Note also that TeXmacs has the concat
macro so instead of string-append
I think you can write more simply
(define (centered-pygments language)
(insert
`(code
(document
(script-input "pygments" "default"
(document (concat "%" ,language "; texmacs")))))))
and probably get rid of the document
tag altogether, but I haven’t tested it.