<\body> > You may invoke programs from in different ways, depending on whether you want to customize some aspects of , to extend the editor with new functionality, to make your markup more dynamic, and so on. In this section, we list the major ways to invoke routines. In order to customize the basic aspects of , you may provide one or both of the initialization files <\verbatim> \ \ \ \ ~/.TeXmacs/progs/my-init-texmacs.scm \ \ \ ~/.TeXmacs/progs/my-init-buffer.scm The file is loaded when booting and is booted each time you open a file. Usually, the file contains personal keyboard bindings and menus. For instance, when putting the following piece of code in this file, the keyboard shortcuts and for starting a new theorem proposition: <\scm-code> (kbd-map \ \ ("D e f ." (make 'definition)) \ \ ("L e m ." (make 'lemma)) \ \ ("P r o p ." (make 'proposition)) \ \ ("T h ." (make 'theorem))) Similarly, the following command extends the standard menu with a special section for the insertion of greetings: <\scm-code> (menu-bind insert-menu \ \ (former) \ \ --- \ \ (-\ "Opening" \ \ \ \ \ \ ("Dear Sir" (insert "Dear Sir,")) \ \ \ \ \ \ ("Dear Madam" (insert "Dear Madam,"))) \ \ (-\ "Closing" \ \ \ \ \ \ ("Yours sincerely" (insert "Yours sincerely,")) \ \ \ \ \ \ ("Greetings" (insert "Greetings,")))) The customization of the and is described in more detail in the chapter about the extensions of . Notice also that, because of the , you can not always assume that the standard key-bindings and menus are loaded before . This implies that some care is needed in the case of . The file can for instance be used in order to automatically select a certain style when starting a new document: <\scm-code> (if (not (buffer-has-name? (current-buffer))) \ \ \ \ (begin \ \ \ \ \ \ (init-style "article") \ \ \ \ \ \ (buffer-pretend-saved (current-buffer)))) Notice that the ``no name'' check is important: when omitted, the styles of existing documents would also be changed to . The function is used in order to avoid to complain about unsaved documents when leaving without changing the document. Another typical use of is when you mainly want to use as a front-end to another system. For instance, the following code will force to automatically launch a session for every newly opened document: <\scm-code> (if (not (buffer-has-name? (current-buffer))) \ \ \ \ (make-session "maxima" (url-\string (current-buffer)))) Using string (current-buffer))> as the second argument of ensures that a different session will be opened for every new buffer. If you want all buffers to share a common instance of , then you should use instead, for the second argument. The above technique of initialization files is sufficient for personal customizations of , but not very convenient if you want to share extensions with other users. A more portable way to extend the editor is therefore to regroup your programs into a . The simplest way to write a plug-in > with some additional functionality is to create two directories and a file <\verbatim> \ \ \ \ ~/.TeXmacs/plugins/ \ \ \ ~/.TeXmacs/plugins//progs \ \ \ ~/.TeXmacs/plugins//progs/init-.scm Furthermore, the file .scm> should a piece of configuration code of the form <\scm-code> (plugin-configure \ \ (:require #t)) Any other code present in .scm> will then be executed when the plug-in is booted, that is, shortly after is started up. By using the additional option, you may force the plug-in to be loaded earlier during the boot procedure. Of course, the plug-in mechanism is more interesting when the plug-in contains more than a few customization routines. In general, a plug-in may also contain additional style files or packages, scripts for launching extern binaries, additional icons and internationalization files, and so on. Furthermore, extensions are usually regrouped into modules in the directory <\verbatim> \ \ \ \ ~/.TeXmacs/plugins//progs The initialization file .scm> should then be kept as short as possible so as to save boot time: it usually only contains which allow to load the appropriate modules only when needed. For more information about how to write plug-ins, we refer to the . commands> In order to rapidly test the effect of commands, it is convenient to execute them directly from within the editor. provides two mechanisms for doing this: directly type the command on the footer using the shortcut, or start a session using . The first mechanism is useful when you do not want to alter the document or when the current cursor position is important for the command you wish to execute. For instance, the command to test whether the cursor is inside a theorem usually makes no sense when you are inside a session. sessions are useful when the results of the commands do not fit on the footer, or when you want to keep your session inside a document for later use. Some typical commands you might want to use inside a session are as follows (try positioning your cursor inside the session and execute them): <\session|scheme|default> <\folded-io|scheme] > (define (square x) (* x x)) <\folded-io|scheme] > (square 1111111) <\folded-io|scheme] > (kbd-map ("h i ." (insert "Hi there!"))) <\folded-io|scheme] > ;; try typing ``hi.'' commands> also provides several command-line options for the execution of commands. This is useful when you want to use as a batch processor. The -related options are the following: <\description-long> >>>Executes the scheme command > when booting has completed. For instance, <\shell-code> texmacs -x "(display \\"Hi there\\\\n\\")" causes to print ``Hi there!'' when starting up. Notice that the option may be used several times. >>This option causes to quit. It is usually used after a option. For instance, <\shell-code> texmacs text.tm -x "(print)" -q will cause to load the file , to print it, and quit. >>>This options may be used to convert the input file > into the output file >. The suffixes of > and > determine their file formats. scrips from markup> provides three major tags for invoking scripts from within the markup: <\description-long> >>This tag works like a hyperlink with body , but such that the command is invoked when clicking on the . For instance, when clicking , you will launch an. >>This tag is used in order to implement macros whose body is written in rather than the macro language. The first argument is a scheme function with arguments. During the typesetting phase, passes the arguments until to, and the result will be typeset. For instance, the code <\tm-fragment> > produces the output ``''. Notice that the argument ``Piet'' remains editable. It should be noticed that the direct invocation of scripts from within documents carries as risk: an evil person might send you a document with a script which attempts to erase your hard disk (for instance). For this reason, implements a way to test whether scripts can be considered secure or not. For instance, when clicking (so as to launch an ), the editor will prompt you by default in order to confirm whether you wish to execute this script. The desired level of security can be specified in . When writing your own extensions to , it is also possible to define routines as being secure.