GNU TeXmacsUser manualReferenceAboutEnglish
The macro and shortcut editors

1.Finding definitions

macro-edit.scm

looks for the definition of a tag in two places:

edit-macro-source (Focus\(\rightarrow\)Preferences\(\rightarrow\)Edit source) goes to the definition: in the preamble, which is shown for the purpose, or in the .ts file found on $TEXMACS_STYLE_PATH, which is opened in a new buffer.

2.The macro editor

open-macro-editor (

macro-widgets.scm

) edits one macro in a dialog, or in the side tool when side tools are enabled. It builds a small document in the auxiliary buffer tmfs://aux/edit-name, whose master is the edited buffer, with the style package macro-editor: the preamble of the edited document (so that its macros are known) followed by an edit-macro tag with the name, the arguments and the body of the macro, or an edit-tag tag for a definition which is not a macro. The body is shown in one of three modes, chosen in the dialog: Text, Source (the body wrapped in inactive*) or Mathematics (edit-math).

Apply (macro-apply) reads the definition back and stores it according to the mode of the editor:

:global

The definition replaces the existing assign of the document wherever it is, or, if there is none, is added to its preamble, which is created if needed (macro-set-value); in the latter case, when the edited buffer has a master (a project), the definition is added to the master as well. The style files are never modified; a macro defined in a style file is overridden by a definition in the preamble.

(:local name)

The definition only applies to the tag under focus: it is stored in a with around that tag (tree-with-set). This is Focus\(\rightarrow\)Rendering\(\rightarrow\)Customize macro. The macro-valued parameters of a tag are edited in either mode, depending on the menu: :global from Focus\(\rightarrow\)Preferences, :local from Focus\(\rightarrow\)Rendering.

Variants of the editor:

3.Options and parameters of a tag

The focus menus of a tag offer its style options and its parameters, both computed by

macro-search.scm

from the definitions of the tag and of the macros it expands to. search-tag-options collects the style packages declared for each of these tags with standard-options (for instance the packages which change the rendering of theorems); search-tag-parameters collects the environment variables which the macros read, so that they can be changed for the document (:global) or around the tag. Both results are cached per tag during one search.

4.User keyboard shortcuts

shortcut-edit.scm

keeps a list of pairs (key sequence, command), where the command is Scheme code in a string, in $TEXMACS_HOME_PATH/system/shortcuts.scm. Shortly after start-up (when the editor is first idle), if the file exists, init-user-shortcuts reads it and defines each pair with kbd-map (

init-texmacs.scm:306

); set-user-shortcut and remove-user-shortcut update the list, save the file and apply the change with kbd-map or kbd-unmap. The shortcuts are defined without a mode condition.

The shortcut editor (

shortcut-widgets.scm

) records the keys in a preview-shortcut tag: while the cursor is in such a tag, keyboard-press is overloaded to append each key to it instead of executing it. The macro editor and the focus menus open it with the command (make 'name), to create a shortcut which inserts the tag.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".