![]() |
Writing your own initialization files | ![]() |
When starting up, TeXmacs executes the file
$TEXMACS_PATH/progs/init-texmacs.scm
as well as your personal initialization file
$TEXMACS_HOME_PATH/progs/my-init-texmacs.scm
if it exists. By default, the path $TEXMACS_HOME_PATH equals %appdata%\TeXmacs on Windows or $HOME/.TeXmacs on GNU/Linux and macOS. Similarly, each time you create a new buffer (either by creating a new file or opening an already existing one), the file
$TEXMACS_PATH/progs/init-buffer.scm
is executed, as well as
$TEXMACS_HOME_PATH/progs/my-init-buffer.scm
if it exists.
Example 1. Suppose you want to add a style package CustomStyle.ts of your own to every new document you create. You can add the following lines to $TEXMACS_HOME_PATH/progs/my-init-buffer.scm:
(when (buffer-newly-created? (current-buffer))
(set-style-list (append (get-style-list) '("CustomStyle")))
(buffer-pretend-saved (current-buffer))) |
First we check whether the current-buffer has been newly created in order not to apply the style to existing files when we open them. Then we add the new package (instead of changing it with init-style) using set-style-list and finally we call buffer-pretend-saved to prevent TeXmacs from thinking the buffer has been modified by the change of style, or it would always prompt asking for confirmation before closing an empty buffer.