Previous: , Up: Version Control   [Contents][Index]


14.6.10 Inserting Version Control Headers

Sometimes it is convenient to put version identification strings directly into working files. Certain special strings called version headers are replaced in each successive version by the number of that version.

You can use the C-x v h command (vc-insert-headers) to insert a suitable header string.

C-x v h

Insert headers in a file for use with your version-control system.

The default header string is ‘\$Id\$’ for RCS and ‘\%W\%’ for SCCS. (The actual strings inserted do not have the backslashes in them. They were placed in the Info source file so that the strings don’t get interpreted as version-control headers when the Info source files are maintained under version control.) You can specify other headers to insert by setting the variable vc-header-alist. Its value is a list of elements of the form (program . string) where program is RCS or SCCS and string is the string to use.

Instead of a single string, you can specify a list of strings; then each string in the list is inserted as a separate header on a line of its own.

It is often necessary to use “superfluous” backslashes when writing the strings that you put in this variable. This is to prevent the string in the constant from being interpreted as a header itself if the Emacs Lisp file containing it is maintained with version control.

Each header is inserted surrounded by tabs, inside comment delimiters, on a new line at the start of the buffer. Normally the ordinary comment start and comment end strings of the current mode are used, but for certain modes, there are special comment delimiters for this purpose; the variable vc-comment-alist specifies them. Each element of this list has the form (mode starter ender).

The variable vc-static-header-alist specifies further strings to add based on the name of the buffer. Its value should be a list of elements of the form (regexp . format). Whenever regexp matches the buffer name, format is inserted as part of the header. A header line is inserted for each element that matches the buffer name, and for each string specified by vc-header-alist. The header line is made by processing the string from vc-header-alist with the format taken from the element. The default value for vc-static-header-alist is:

(("\\.c$" .
  "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
#endif /* lint */\n"))

which specifies insertion of a string of this form:

#ifndef lint
static char vcid[] = "string";
#endif /* lint */

Previous: , Up: Version Control   [Contents][Index]