Default new document settings

Hi, I’ve recently started using TeXmacs and noticed new documents always revert to default settings.

I want some settings for page, theme, style, paragraphs, etc., automatically applied to new documents. But the manuals didn’t give any clues.

Some googling returned TeXmacs website that suggests writing initialization files-- both for initial startup and the buffer.

That doesn’t seem easy. Is there a better way?

Hi and welcome to the forum.

Till now I have done all of my customizations of TeXmacs using the initialization files. I am not aware of other general ways of doing this, but as far as I remember at least some of the settings are retained (I do not recall which ones :slight_smile: ). If you write down what you would like to have, we can try setting that up.

With a bit of practice, writing your own initialization files is reasonably easy, I agree though that extending the current possibilities of customization of defaults through the menus would be nice.

hi, thanks for the offer, but I don’t think I’m too comfortable directly editing program files at this stage. As a workaround, I’ve saved a blank document with the required settings and will save as any new files using that template.

For info:
I think that the “right way” of doing this occurred to me, and that is generating a style file. I have a vague feeling that there is a way to extract a style file from a document, so that would be quite close to what you want (perhaps that would be it).
I searched for it in the menus and in the Internet for a few minutes but I did not find anything. I’ll write a new message if I find something (maybe someone else will, also).

It’s under Tools->Macros->Extract style file

It’s less scary than it might seem. TeXmacs provides a way of editing the initialization files. If you enable Tools->Developer tool in the menus, then a new Developer menu appears, where you have Developer -> Open my-init-buffer.scm.

Clicking extract style file opens a new file showing the settings. So how do I save this as a .ts file? — at least that’s what the manual needs.

Also, where do I save this file? The user guide example with CustomStyle.ts shows a putting filename into the code. Is that sufficient?

You save it as a .ts file by writing the file name extension as .ts in the save dialog. If this description is not enough for you let me know and I’ll make a screenshot.
After that, you can put the file into the “packages” subfolder of the user TeXmacs folder. To find the user TeXmacs folder the easiest way (works in all operating systems) is to follow the instructions of @jeroen above

then start the procedure of Save as onto the open file my-init-buffer.scm. The folder proposed by the save dialog is the progs subfolder of the user TeXmacs folder, so after that you locate its parent folder in the file system and use its packages subfolder (where you can create sub-subfolders) to save your style file.

After you do that, TeXmacs should recognize your style file and present it in the list of packages (under
Document -> Style-> Add package); you can then include it when you open a new document.

I think that there is a way to automatically include it in new documents, but I need to figure out how, when I do I shall write it here.

Please let me know if some of the steps are unclear. The aim is that once you have done it, then using TeXmacs with your settings will become automatic under creation of a new file.

yep I got it, the new package shows in the style menu and loading it applies the settings, thanks for the help :slight_smile:

Nice! Then let me get back to this thread when (and if :slight_smile: ) I have learnt how to automatically include a package at startup.

There is an code snippet to do that in this post:

Specificaly, this needs to go into my-init-buffer.scm (assuming the style file is called CustomStyle.ts):

(if (not (buffer-has-name? (current-buffer)))
  (set-style-list (append (get-style-list) '("CustomStyle")))
  (buffer-pretend-saved (current-buffer))))

This is very nice and it had not occurred to me to look in there.
Said this, it would be even better if that post was kept in a prominent place, in the way the forum works now it fades away from my memory. @darcy and @mgubi, can we do something?