GNU TeXmacsUser manualReferenceAboutEnglish
Projects

A project consists of a master file and a number of chapter files. The master includes the chapters with include (see the next page); each chapter which should be editable on its own is attached to the master. The buffer level routines (project_attach, project_attached, project_get, implicit projects) are described in buffers; this page explains what attaching a project actually changes.

1.Declaring masters and chapters

The master

A buffer is a master (an implicit project) if its file name ends in .tp, or if the initial variable project-flag is true. The latter is toggled by Tools\(\rightarrow\)Project\(\rightarrow\)Use as master (buffer-toggle-master in

generic/document-part.scm

, which calls init-env).

A chapter

Tools\(\rightarrow\)Project\(\rightarrow\)Attach master asks for a file and calls project-attach with its name relative to the current buffer (project-attach*). The C++ routine project_attach (

Texmacs/Data/new_project.cpp

) stores the name in the project field of the buffer data, re-initializes the editors (init_update, notify_change (THE_DECORATIONS)), marks the buffer as modified and loads the master buffer into buf->prj with concrete_buffer_insist. Tools\(\rightarrow\)Project\(\rightarrow\)Detach master (project-detach) calls the same routine with an empty name. The name is saved in the project part of the document.

When a chapter is loaded later, set_buffer_tree (

new_buffer.cpp

) sees the project attribute and loads the master in the background, without any view. The master therefore must exist on disk; unless it is already open, its references are those of its last save.

2.Shared reference and auxiliary tables

The typesetting environment of an editor holds two tables of each kind: a local one and a global one. They are bound in the constructor of edit_typeset_rep (

Edit/Editor/edit_typeset.cpp

):

References

local: buf->data->ref; global: the references of the master (buf->prj->data->ref) if there is a project, otherwise the private table grefs.

Auxiliary data

local: buf->data->aux; global: the auxiliary data of the master, or the local table again.

Attachments

likewise, with att.

The two kinds of tables are used asymmetrically:

When the master is typeset, its chapters are typeset as part of it through include, so the master's own table collects the labels of all chapters; saving the master stores them in its references section. When a chapter is typeset on its own, its local table only contains its own labels, and a reference to a label in another chapter is found in the master's table. Consequently, cross references between chapters are only correct after the master has been typeset and saved; updating a chapter does not update the master.

A buffer which has no project but whose initial variable part-flag is true gets a copy of its own references as global table (grefs, set by init_update). This is the case of the part views of the last page, whose references are those of the master.

3.Numbering of chapters and pages

The include macro of the standard style calls part-info with the name of the included file, which does two things while the master is typeset (

std-automatic.ts

):

edit_typeset_rep::init_update uses this information when a chapter is (re)initialized: it computes the name of the chapter relative to the master (delta (prj->buf->name, buf->name)), looks for an entry with that name in the master's parts and copies the recorded counters, as well as the page of part:name (into page-first), to the initial environment of the editor and of the buffer data. As a result, a chapter edited on its own is numbered as in the book.

Conversely, when a chapter is included, extract_document (

Data/Convert/Texmacs/fromtm.cpp

) keeps its initial environment as a with around the body, but drops the page layout variables and, if the included file belongs to a project, its page-first and chapter and section counters, so that the copies stored in the chapter do not override the numbering of the master.

4.Menus and updates

Document\(\rightarrow\)Project

Shown when a project is attached (

texmacs/menus/main-menu.scm

). project-menu (

generic/document-menu.scm

) offers the master and the list of files included by the master (project-file-list, computed by include-list from the master's tree).

Tools\(\rightarrow\)Project

project-manage-menu: use as master, expand inclusions, attach and detach the master.

Document\(\rightarrow\)Update\(\rightarrow\)Clear local information

Only shown for a chapter; clear_local_info empties the local reference and auxiliary tables of the buffer, so that only the master's information is used.

The other update commands (update-document) act on the current buffer only. To refresh the cross references of a book, update and save the master, then reopen or re-initialize the chapters.

5.Pitfalls

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".