When and how to use |
You may invoke
In order to customize the basic aspects of TeXmacs, you may provide one or both of the initialization files
~/.TeXmacs/progs/my-init-texmacs.scm
~/.TeXmacs/progs/my-init-buffer.scm
The file my-init-texmacs.scm is loaded when booting TeXmacs and my-init-texmacs.scm is booted each time you open a file.
Usually, the file my-init-texmacs.scm contains personal keyboard bindings and menus. For instance, when putting the following piece of code in this file, the keyboard shortcuts T h . and P r o p . for starting a new theorem resp. proposition:
(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-extend insert-menu
–-
(-> "Opening"
("Dear Sir" (insert "Dear
Sir,"))
("Dear Madam" (insert "Dear
Madam,")))
(-> "Closing"
("Yours sincerely" (insert "Yours
sincerely,"))
("Greetings" (insert
"Greetings,"))))
The customization of the keyboard and menus
is described in more detail in the chapter about the TeXmacs
extensions of
The file my-init-buffer.scm can for instance be used in order to automatically select a certain style when starting a new document:
(if (no-name?)
(begin
(init-style "article")
(pretend-save-buffer)))
Notice that the check (no-name?) is important: when omitted, the styles of existing documents would also be changed to article. The command (pretend-save-buffer) is used in order to avoid TeXmacs to complain about unsaved documents when leaving TeXmacs without changing the document.
Another typical use of my-init-buffer.scm is when you
mainly want to use TeXmacs as a front-end to another system. For
instance, the following code will force TeXmacs to automatically
launch a
(if (no-name?)
(make-session "maxima" (url->string
(get-name-buffer))))
Using (url->string (get-name-buffer)) as the second argument of
make-session ensures that a different session will be opened for every
new buffer. If you want all buffers to share a common instance of
The above technique of
The simplest way to write a plug-in name with
some additional
~/.TeXmacs/plugins/name
~/.TeXmacs/plugins/name/progs
~/.TeXmacs/plugins/name/progs/init-name.scm
Furthermore, the file init-name.scm should a piece of configuration code of the form
(plugin-configure name
(:require #t))
Any other
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,
~/.TeXmacs/plugins/name/progs
The initialization file init-name.scm should then be kept as short as possible so as to save boot time: it usually only contains lazy declarations which allow TeXmacs to load the appropriate modules only when needed.
For more information about how to write plug-ins, we refer to the corresponding chapter.
In order to rapidly test the effect of
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 (inside? 'theorem) to test whether the cursor is inside a theorem usually makes no sense when you are inside a session.
scheme] |
(define (square x) (* x x))
|
scheme] |
(square 1111111)
|
scheme] |
(kbd-map ("h i ." (insert "Hi
there!")))
|
scheme] |
;; try typing “hi.”
|
TeXmacs also provides several command-line options for the execution
of
Executes the scheme command cmd when booting has completed. For instance,
texmacs -x "(display \"Hi there\\n\")"
causes TeXmacs to print “Hi there!” when starting up. Notice that the -x option may be used several times.
This option causes TeXmacs to quit. It is usually used after a -x option. For instance,
texmacs text.tm -x "(print)" -q
will cause TeXmacs to load the file text.tm, to print it, and quit.
TeXmacs provides three major tags for invoking
This tag is used in order to implement macros whose body is
written in
<extern|(lambda (x) ‘(concat "Hallo
" ,x))|Piet>
produces the output “Hallo Piet”. Notice that the argument “Piet” remains editable.
It should be noticed that the direct invocation of