New document with style from command line

Is it possible to start TeXmacs from the command line opening a new document with a given style?

I tried the -x command line option in the following way:

texmacs -x "(set-style-list '("note-scuola" "SIUnits"))" test.tm &

and got a new file with default settings and an error message (which I post below). The Scheme command between double quotes works in a Scheme session.

Of course there are workarounds (e.g. execute the command on a new file with a keyboard shortcut or a new menu item). I am curious about the command line and it seems to me quicker too (bash alias).

Thanks in advance.

Giovanni

Here is the error message.

Backtrace:
In ice-9/boot-9.scm:
  1784:12  5 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
           4 (apply-smob/0 #<thunk 7c5e3830d240>)
In ice-9/boot-9.scm:
  1784:12  3 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
           2 (apply-smob/0 #<thunk 7c5e0a518180>)
In ice-9/psyntax.scm:
  3246:18  1 (_ _)
In unknown file:
           0 (tm->tree (tuple note-scuola SIUnits))

ERROR: In procedure tm->tree:
In procedure tm->tree: Wrong type argument in position 1: (tuple note-scuola SIUnits)

Hi Giovanni,

there are two separate things going on.

1. The quoting. The double quotes inside your command close the shell’s double-quoted string. So TeXmacs receives

(set-style-list '(note-scuola SIUnits))

with symbols instead of strings, which gives the tm->tree error. Use single quotes on the outside, and list instead of '(...), which doesn’t fit inside single quotes:

texmacs -x '(set-style-list (list "note-scuola" "SIUnits"))'

2. Where the command runs. In the current TeXmacs, the -x commands run before the files on the command line are loaded, wherever you put them. So with test.tm on the command line, the style goes to a scratch buffer and not to test.tm.

For a new document, leave out the file name. The command then acts on the empty document TeXmacs opens at startup:

alias tmscuola='texmacs -x '\''(set-style-list (list "note-scuola" "SIUnits"))'\'' &'

For a given file, load it inside the command itself. $PWD is needed because the path must be absolute:

texmacs -x "(begin (load-buffer \"$PWD/test.tm\") (set-style-list (list \"note-scuola\" \"SIUnits\")))" &

We have changed this in our development version: commands and files now run in the order they appear on the command line, so texmacs test.tm -x '...' will also work there.

Best,
Massimiliano