]> code.delx.au - gnu-emacs/blob - doc/emacs/maintaining.texi
More updates for VC documentation.
[gnu-emacs] / doc / emacs / maintaining.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2011
3 @c Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Maintaining, Abbrevs, Building, Top
6 @chapter Maintaining Large Programs
7
8 This chapter describes Emacs features for maintaining large
9 programs.
10
11 @menu
12 * Version Control:: Using version control systems.
13 * Change Log:: Maintaining a change history for your program.
14 * Tags:: Go directly to any function in your program in one
15 command. Tags remembers which file it is in.
16 * EDE:: An integrated development environment for Emacs.
17 @ifnottex
18 * Emerge:: A convenient way of merging two versions of a program.
19 @end ifnottex
20 @end menu
21
22 @node Version Control
23 @section Version Control
24 @cindex version control
25
26 A @dfn{version control system} is a program that can record multiple
27 versions of a source file, storing information such as the creation
28 time of each version, who made it, and a description of what was
29 changed.
30
31 The Emacs version control interface is called @dfn{VC}. VC commands
32 work with several different version control systems; currently, it
33 supports GNU Arch, Bazaar, CVS, Git, Mercurial, Monotone, RCS,
34 SCCS/CSSC, and Subversion. Of these, the GNU project distributes CVS,
35 Arch, RCS, and Bazaar.
36
37 VC is enabled automatically whenever you visit a file governed by a
38 version control system. To disable VC entirely, set the customizable
39 variable @code{vc-handled-backends} to @code{nil}
40 @iftex
41 (@pxref{Customizing VC,,,emacs-xtra, Specialized Emacs Features}).
42 @end iftex
43 @ifnottex
44 (@pxref{Customizing VC}).
45 @end ifnottex
46
47 @menu
48 * Introduction to VC:: How version control works in general.
49 * VC Mode Line:: How the mode line shows version control status.
50 * Basic VC Editing:: How to edit a file under version control.
51 * Log Buffer:: Features available in log entry buffers.
52 * Registering:: Putting a file under version control.
53 * Old Revisions:: Examining and comparing old versions.
54 * VC Change Log:: Viewing the VC Change Log.
55 * VC Undo:: Canceling changes before or after committing.
56 * VC Directory Mode:: Listing files managed by version control.
57 * Branches:: Multiple lines of development.
58 @ifnottex
59 * Remote Repositories:: Efficient access to remote CVS servers.
60 * Revision Tags:: Symbolic names for revisions.
61 * Miscellaneous VC:: Various other commands and features of VC.
62 * Customizing VC:: Variables that change VC's behavior.
63 @end ifnottex
64 @end menu
65
66 @node Introduction to VC
67 @subsection Introduction to Version Control
68
69 VC allows you to use a version control system from within Emacs,
70 integrating the version control operations smoothly with editing. It
71 provides a uniform interface for common operations in many version
72 control operations.
73
74 Some uncommon or intricate version control operations, such as
75 altering repository settings, are not supported in VC. You should
76 perform such tasks outside Emacs, e.g.@: via the command line.
77
78 This section provides a general overview of version control, and
79 describes the version control systems that VC supports. You can skip
80 this section if you are already familiar with the version control system
81 you want to use.
82
83 @menu
84 * Why Version Control?:: Understanding the problems it addresses.
85 * Version Control Systems:: Supported version control back-end systems.
86 * VCS Concepts:: Words and concepts related to version control.
87 * VCS Merging:: How file conflicts are handled.
88 * VCS Changesets:: How changes are grouped.
89 * VCS Repositories:: Where version control repositories are stored.
90 * Types of Log File:: The VCS log in contrast to the ChangeLog.
91 @end menu
92
93 @node Why Version Control?
94 @subsubsection Understanding the problems it addresses
95
96 Version control systems provide you with three important
97 capabilities:
98
99 @itemize @bullet
100 @item
101 @dfn{Reversibility}: the ability to back up to a previous state if you
102 discover that some modification you did was a mistake or a bad idea.
103
104 @item
105 @dfn{Concurrency}: the ability to have many people modifying the same
106 collection of files knowing that conflicting modifications can be
107 detected and resolved.
108
109 @item
110 @dfn{History}: the ability to attach historical data to your data,
111 such as explanatory comments about the intention behind each change to
112 it. Even for a programmer working solo, change histories are an
113 important aid to memory; for a multi-person project, they are a
114 vitally important form of communication among developers.
115 @end itemize
116
117 @node Version Control Systems
118 @subsubsection Supported Version Control Systems
119
120 @cindex back end (version control)
121 VC currently works with many different version control systems,
122 which it refers to as @dfn{back ends}:
123
124 @itemize @bullet
125
126 @cindex SCCS
127 @item
128 SCCS was the first version control system ever built, and was long ago
129 superseded by more advanced ones. VC compensates for certain features
130 missing in SCCS (e.g.@: tag names for releases) by implementing them
131 itself. Other VC features, such as multiple branches, are simply
132 unavailable. Since SCCS is non-free, we recommend avoiding it.
133
134 @cindex CSSC
135 @item
136 CSSC is a free replacement for SCCS. You should use CSSC only if, for
137 some reason, you cannot use a more recent and better-designed version
138 control system.
139
140 @cindex RCS
141 @item
142 RCS is the free version control system around which VC was initially
143 built. It is relatively primitive: it cannot be used over the
144 network, and works at the level of individual files. Almost
145 everything you can do with RCS can be done through VC.
146
147 @cindex CVS
148 @item
149 CVS is the free version control system that was, until recently (circa
150 2008), used by the majority of free software projects. Nowadays, it
151 is slowly being superseded by newer systems. CVS allows concurrent
152 multi-user development either locally or over the network. Unlike
153 newer systems, it lacks support for atomic commits and file
154 moving/renaming. VC supports all basic editing operations under CVS.
155
156 @cindex SVN
157 @cindex Subversion
158 @item
159 Subversion (svn) is a free version control system designed to be
160 similar to CVS but without its problems (e.g., it supports atomic
161 commits of filesets, and versioning of directories, symbolic links,
162 meta-data, renames, copies, and deletes).
163
164 @cindex GNU Arch
165 @cindex Arch
166 @item
167 GNU Arch is one of the earliest @dfn{distributed} version control
168 systems (the other being Monotone). @xref{VCS Concepts}, for a
169 description of distributed version control systems. It is no longer
170 under active development, and has been deprecated in favor of Bazaar.
171
172 @cindex git
173 @item
174 Git is a distributed version control system originally invented by
175 Linus Torvalds to support development of Linux (his kernel). VC
176 supports many common Git operations, but others, such as repository
177 syncing, must be done from the command line.
178
179 @cindex hg
180 @cindex Mercurial
181 @item
182 Mercurial (hg) is a distributed version control system broadly
183 resembling Git. VC supports most Mercurial commands, with the
184 exception of repository sync operations.
185
186 @cindex bzr
187 @cindex Bazaar
188 @item
189 Bazaar (bzr) is a distributed version control system that supports
190 both repository-based and distributed versioning. VC supports most
191 basic editing operations under Bazaar.
192 @end itemize
193
194 @node VCS Concepts
195 @subsubsection Concepts of Version Control
196
197 @cindex repository
198 @cindex registered file
199 When a file is under version control, we say that it is
200 @dfn{registered} in the version control system. The system has a
201 @dfn{repository} which stores both the file's present state and its
202 change history---enough to reconstruct the current version or any
203 earlier version. The repository also contains other information, such
204 as @dfn{log entries} that describe the changes made to each file.
205
206 @cindex work file
207 @cindex checking out files
208 The copy of a version-controlled file that you actually edit is
209 called the @dfn{work file}. You can change each work file as you
210 would an ordinary file. After you are done with a set of changes, you
211 may @dfn{commit} (or @dfn{check in}) the changes; this records the
212 changes in the repository, along with a descriptive log entry.
213
214 @cindex revision
215 @cindex revision ID
216 Each commit creates a new @dfn{revision} in the repository. The
217 version control system keeps track of all past revisions and the
218 changes that were made in each revision. Each revision is named by a
219 @dfn{revision ID}, whose format depends on the version control system;
220 in the simplest case, it is just an integer.
221
222 To go beyond these basic concepts, you will need to understand three
223 aspects in which version control systems differ. As explained in the
224 next three sections, they can be lock-based or merge-based; file-based
225 or changeset-based; and centralized or decentralized. VC handles all
226 these modes of operation, but it cannot hide the differences.
227
228 @node VCS Merging
229 @subsubsection Merge-based vs lock-based Version Control
230 @cindex locking versus merging
231
232 A version control system typically has some mechanism to coordinate
233 between users who want to change the same file. There are two ways to
234 do this: merging and locking.
235
236 In a version control system that uses merging, each user may modify
237 a work file at any time. The system lets you @dfn{merge} your work
238 file, which may contain changes that have not been committed, with the
239 latest changes that others have committed.
240
241 Older version control systems use a @dfn{locking} scheme instead.
242 Here, work files are normally read-only. To edit a file, you ask the
243 version control system to make it writable for you by @dfn{locking}
244 it; only one user can lock a given file at any given time. This
245 procedure is analogous to, but different from, the locking that Emacs
246 uses to detect simultaneous editing of ordinary files
247 (@pxref{Interlocking}). When you commit your changes, that unlocks
248 the file, and the work file becomes read-only again. Other users may
249 then lock the file to make their own changes.
250
251 Both locking and merging systems can have problems when multiple
252 users try to modify the same file at the same time. Locking systems
253 have @dfn{lock conflicts}; a user may try to check a file out and be
254 unable to because it is locked. In merging systems, @dfn{merge
255 conflicts} happen when you commit a change to a file that conflicts
256 with a change committed by someone else after your checkout. Both
257 kinds of conflict have to be resolved by human judgment and
258 communication. Experience has shown that merging is superior to
259 locking, both in convenience to developers and in minimizing the
260 number and severity of conflicts that actually occur.
261
262 SCCS always uses locking. RCS is lock-based by default but can be
263 told to operate in a merging style. CVS and Subversion are
264 merge-based by default but can be told to operate in a locking mode.
265 Distributed version control systems, such as GNU Arch, Git, and
266 Mercurial, are exclusively merging-based.
267
268 VC mode supports both locking and merging version control. The
269 terms ``commit'' and ``update'' are used in newer version control
270 systems; older lock-based systems use the terms ``check in'' and
271 ``check out''. VC hides the differences between them as much as
272 possible.
273
274 @node VCS Changesets
275 @subsubsection Changeset-based vs File-based Version Control
276
277 @cindex changesets
278 On SCCS, RCS, CVS, and other early version control systems, version
279 control operations are @dfn{file-based}: each file has its own comment
280 and revision history separate from that of all other files. Newer
281 systems, beginning with Subversion, are @dfn{changeset-based}: a
282 commit may include changes to several files, and the entire set of
283 changes is handled as a unit. Any comment associated with the change
284 does not belong to a single file, but to the changeset itself.
285
286 Changeset-based version control is more flexible and powerful than
287 file-based version control; usually, when a change to multiple files
288 has to be reversed, it's good to be able to easily identify and remove
289 all of it.
290
291 @node VCS Repositories
292 @subsubsection Decentralized vs Centralized Repositories
293
294 @cindex centralized version control
295 @cindex decentralized version control
296 Early version control systems were designed around a
297 @dfn{centralized} model in which each project has only one repository
298 used by all developers. SCCS, RCS, CVS, and Subversion share this
299 kind of model. One of its drawbacks is that the repository is a choke
300 point for reliability and efficiency.
301
302 GNU Arch pioneered the concept of @dfn{decentralized} version
303 control, later implemented in Git, Mercurial, and Bazaar. A project
304 may have several different repositories, and these systems support a
305 sort of super-merge between repositories that tries to reconcile their
306 change histories. In effect, there is one repository for each
307 developer, and repository merges take the place of commit operations.
308
309 VC helps you manage the traffic between your personal workfiles and
310 a repository. Whether the repository is a single master, or one of a
311 network of peer repositories, is not something VC has to care about.
312
313 @node Types of Log File
314 @subsubsection Types of Log File
315 @cindex types of log file
316 @cindex log File, types of
317 @cindex version control log
318
319 Projects that use a version control system can have two types of log
320 for changes. One is the log maintained by the version control system:
321 each time you commit a change, you fill out a @dfn{log entry} for the
322 change (@pxref{Log Buffer}). This is called the @dfn{version control
323 log}.
324
325 The other kind of log is the file @file{ChangeLog} (@pxref{Change
326 Log}). It provides a chronological record of all changes to a large
327 portion of a program---typically one directory and its subdirectories.
328 A small program would use one @file{ChangeLog} file; a large program
329 may have a @file{ChangeLog} file in each major directory.
330 @xref{Change Log}. Programmers have used change logs since long
331 before version control systems.
332
333 Changeset-based version systems typically maintain a changeset-based
334 modification log for the entire system, which makes change log files
335 somewhat redundant. One advantage that they retain is that it is
336 sometimes useful to be able to view the transaction history of a
337 single directory separately from those of other directories.
338
339 A project maintained with version control can use just the version
340 control log, or it can use both kinds of logs. It can handle some
341 files one way and some files the other way. Each project has its
342 policy, which you should follow.
343
344 When the policy is to use both, you typically want to write an entry
345 for each change just once, then put it into both logs. You can write
346 the entry in @file{ChangeLog}, then copy it to the log buffer with
347 @kbd{C-c C-a} when committing the change (@pxref{Log Buffer}). Or you
348 can write the entry in the log buffer while committing the change, and
349 later use the @kbd{C-x v a} command to copy it to @file{ChangeLog}
350 @iftex
351 (@pxref{Change Logs and VC,,,emacs-xtra, Specialized Emacs Features}).
352 @end iftex
353 @ifnottex
354 (@pxref{Change Logs and VC}).
355 @end ifnottex
356
357 @node VC Mode Line
358 @subsection Version Control and the Mode Line
359 @cindex VC, mode line indicator
360
361 When you visit a file that is under version control, Emacs indicates
362 this on the mode line. For example, @samp{Bzr-1223} says that Bazaar
363 is used for that file, and the current revision ID is 1223.
364
365 The character between the back-end name and the revision ID
366 indicates the status of the work file. In a merge-based version
367 control system, a @samp{-} character indicates that the work file is
368 unmodified, and @samp{:} indicates that it has been modified.
369 @samp{!} indicates that the file contains conflicts as result of a
370 recent merge operation (@pxref{Merging}), or that the file was removed
371 from the version control. Finally, @samp{?} means that the file is
372 under version control, but is missing from the working tree.
373
374 In a lock-based system, @samp{-} indicates an unlocked file, and
375 @samp{:} a locked file; if the file is locked by another user (for
376 instance, @samp{jim}), that is displayed as @samp{RCS:jim:1.3}.
377 @samp{@@} means that the file was locally added, but not yet committed
378 to the master repository.
379
380 On a graphical display, you can move the mouse over this mode line
381 indicator to pop up a ``tool-tip'', which displays a more verbose
382 description of the version control status. Pressing @kbd{Mouse-1}
383 over the indicator pops up a menu of VC commands, identical to
384 @samp{Tools / Version Control} on the menu bar.
385
386 @vindex auto-revert-check-vc-info
387 When Auto Revert mode (@pxref{Reverting}) reverts a buffer that is
388 under version control, it updates the version control information in
389 the mode line. However, Auto Revert mode may not properly update this
390 information if the version control status changes without changes to
391 the work file, from outside the current Emacs session. If you set
392 @code{auto-revert-check-vc-info} to @code{t}, Auto Revert mode updates
393 the version control status information every
394 @code{auto-revert-interval} seconds, even if the work file itself is
395 unchanged. The resulting CPU usage depends on the version control
396 system, but is usually not excessive.
397
398 @node Basic VC Editing
399 @subsection Basic Editing under Version Control
400
401 @cindex filesets, VC
402 Most VC commands operate on @dfn{VC filesets}. A VC fileset is a
403 collection of one or more files that a VC operation acts on. When you
404 type VC commands in a buffer visiting a version-controlled file, the
405 VC fileset is simply that one file. When you type them in a VC
406 Directory buffer, and some files in it are marked, the VC fileset
407 consists of the marked files (@pxref{VC Directory Mode}).
408
409 On Subversion and on decentralized version control systems,
410 multi-file VC filesets are handled as a single group by the relevant
411 version control commands. For example, committing a multi-file VC
412 fileset generates a single revision, consisting of all the changes to
413 those files. But on older version control systems which lack support
414 for group operations, such as CVS, the files in a multi-file VC
415 fileset are passed individually to version control commands (e.g.@: a
416 commit generates one revision for each changed file).
417
418 @table @kbd
419 @itemx C-x v v
420 Perform the next appropriate version control operation on the current
421 VC fileset.
422 @end table
423
424 @findex vc-next-action
425 @kindex C-x v v
426 The principal VC command is an all-purpose command, @kbd{C-x v v}
427 (@code{vc-next-action}), which performs the ``most appropriate''
428 action on the current VC fileset: either registering it with a version
429 control system, or committing it, or unlocking it, or merging changes
430 into it. The precise actions are described in detail in the following
431 subsections. You can use @kbd{C-x v v} either in a file-visiting
432 buffer or in a VC Directory buffer.
433
434 Note that VC filesets are distinct from the ``named filesets'' used
435 for viewing and visiting files in functional groups
436 (@pxref{Filesets}). Unlike named filesets, VC filesets are not named
437 and don't persist across sessions.
438
439 @menu
440 * VC With A Merging VCS:: Without locking: default mode for CVS.
441 * VC With A Locking VCS:: RCS in its default mode, SCCS, and optionally CVS.
442 * Advanced C-x v v:: Advanced features available with a prefix argument.
443 @end menu
444
445 @node VC With A Merging VCS
446 @subsubsection Basic Version Control with Merging
447
448 On a merging-based version control system (i.e.@: most modern ones;
449 @pxref{VCS Merging}), @kbd{C-x v v} does the following:
450
451 @itemize @bullet
452 @item
453 If there is more than one file in the VC fileset and the files have
454 inconsistent version control states, signal an error. (Note, however,
455 that a fileset is allowed to include both ``newly-added'' files and
456 ``modified'' files; @pxref{Registering}.)
457
458 @item
459 If none of the files in the VC fileset are registered with a version
460 control system, register the VC fileset, i.e.@: place it under version
461 control. @xref{Registering}. If Emacs cannot find a system to
462 register under, it prompts for a repository type, creates a new
463 repository, and registers the VC fileset with it.
464
465 @item
466 If every work file in the VC fileset is unchanged, do nothing.
467
468 @item
469 If every work file in the VC fileset has been modified, commit the
470 changes. To do this, Emacs pops up a @samp{*vc-log*} buffer; type the
471 desired log entry for the new revision, followed by @kbd{C-c C-c} to
472 commit. @xref{Log Buffer}.
473
474 If committing to a shared repository, the commit may fail if the
475 repository that has been changed since your last update. In that
476 case, you must perform an update before trying again. If using a
477 decentralized version control system, use @kbd{C-x v +} or @kbd{C-x v
478 m} (@pxref{Merging}). If using a centralized version control system,
479 type @kbd{C-x v v} again to merge in the repository changes.
480
481 @item
482 Finally, if you are using a centralized version control system, check
483 if each work file in the VC fileset is up-to-date. If any file has
484 been changed in the repository, offer to update it.
485 @end itemize
486
487 These rules also apply when you use RCS in its ``non-locking'' mode,
488 except that changes are not automatically merged from the repository.
489 Nothing informs you if another user has committed changes in the same
490 file since you began editing it; when you commit your revision, his
491 changes are removed (however, they remain in the repository and are
492 thus not irrevocably lost). Therefore, you must verify that the
493 current revision is unchanged before committing your changes. In
494 addition, locking is possible with RCS even in this mode: @kbd{C-x v
495 v} with an unmodified file locks the file, just as it does with RCS in
496 its normal locking mode (@pxref{VC With A Locking VCS}).
497
498 @node VC With A Locking VCS
499 @subsubsection Basic Version Control with Locking
500
501 On a locking-based version control system (such as SCCS, and RCS in
502 its default mode), @kbd{C-x v v} does the following:
503
504 @itemize @bullet
505 @item
506 If there is more than one file in the VC fileset and the files have
507 inconsistent version control states, signal an error.
508
509 @item
510 If each file in the VC fileset is not registered with a version
511 control system, register the VC fileset. @xref{Registering}. If
512 Emacs cannot find a system to register under, it prompts for a
513 repository type, creates a new repository, and registers the VC
514 fileset with it.
515
516 @item
517 If each file is registered and unlocked, lock it and make it writable,
518 so that you can begin to edit it.
519
520 @item
521 If each file is locked by you and contains changes, commit the
522 changes. To do this, Emacs pops up a @samp{*vc-log*} buffer; type the
523 desired log entry for the new revision, followed by @kbd{C-c C-c} to
524 commit (@pxref{Log Buffer}).
525
526 @item
527 If each file is locked by you, but you have not changed it, release
528 the lock and make the file read-only again.
529
530 @item
531 If each file is locked by another user, ask whether you want to
532 ``steal the lock''. If you say yes, the file becomes locked by you,
533 and a warning message is sent to the user who had formerly locked the
534 file.
535 @end itemize
536
537 These rules also apply when you use CVS in locking mode, except
538 that CVS does not support stealing locks.
539
540 @node Advanced C-x v v
541 @subsubsection Advanced Control in @kbd{C-x v v}
542
543 @cindex revision ID in version control
544 When you give a prefix argument to @code{vc-next-action} (@kbd{C-u
545 C-x v v}), it still performs the next logical version control
546 operation, but accepts additional arguments to specify precisely how
547 to do the operation.
548
549 @itemize @bullet
550 @item
551 If the file is modified (or locked), you can specify the revision ID
552 to use for the new version that you commit. This is one way to create
553 a new branch (@pxref{Branches}).
554
555 @item
556 If the file is not modified (and unlocked), you can specify the
557 revision to select; this lets you start working from an older
558 revision, or on another branch. If you do not enter any revision,
559 that takes you to the highest (``head'') revision on the current
560 branch; therefore @kbd{C-u C-x v v @key{RET}} is a convenient way to
561 get the latest version of a file from the repository.
562
563 @item
564 @cindex specific version control system
565 Instead of the revision ID, you can also specify the name of a
566 version control system. This is useful when one file is being managed
567 with two version control systems at the same time
568 @iftex
569 (@pxref{Local Version Control,,,emacs-xtra, Specialized Emacs
570 Features}).
571 @end iftex
572 @ifnottex
573 (@pxref{Local Version Control}).
574 @end ifnottex
575
576 @end itemize
577
578 @node Log Buffer
579 @subsection Features of the Log Entry Buffer
580
581 @cindex C-c C-c @r{(Log Edit mode)}
582 @findex log-edit-done
583 When you tell VC to commit a change, it pops up a buffer named
584 @samp{*vc-log*}. In this buffer, you should write a @dfn{log entry}
585 describing the changes you have made (@pxref{Why Version Control?}).
586 After you are done, type @kbd{C-c C-c} (@code{log-edit-done}) to exit
587 the buffer and commit the change, together with your log entry.
588
589 @cindex Log Edit mode
590 @cindex mode, Log Edit
591 @vindex vc-log-mode-hook
592 The major mode for the @samp{*vc-log*} buffer is Log Edit mode, a
593 variant of Text mode (@pxref{Text Mode}). On entering Log Edit mode,
594 Emacs runs the hooks @code{text-mode-hook} and @code{vc-log-mode-hook}
595 (@pxref{Hooks}).
596
597 While in the @samp{*vc-log*} buffer, you can write one or more
598 @dfn{header lines}, specifying additional information to be supplied
599 to the version control system. Each header line must occupy a single
600 line at the top of the buffer; the first line that is not a header
601 line is treated as the start of the log entry. For example, the
602 following header line states that the present change was not written
603 by you, but by another developer:
604
605 @smallexample
606 Author: J. R. Hacker <jrh@@example.com>
607 @end smallexample
608
609 @noindent
610 Apart from the @samp{Author} header, Emacs recognizes the headers
611 @samp{Date} (a manually-specified commit time) and @samp{Fixes} (a
612 reference to a bug fixed by the change). Not all version control
613 systems recognize all headers: Bazaar recognizes all three headers,
614 while Git, Mercurial, and Monotone recognize only @samp{Author} and
615 @samp{Date}. If you specify a header for a version control that does
616 not support it, the header is treated as part of the log entry.
617
618 @kindex C-c C-f @r{(Log Edit mode)}
619 @findex log-edit-show-files
620 Type @kbd{C-c C-f} (@code{log-edit-show-files}) in the
621 @samp{*vc-log*} buffer to view a list of files for the VC fileset that
622 is to be committed. If you called @kbd{C-x v v} directly from a work
623 file, the fileset consists of that single file. If you called
624 @kbd{C-x v v} from a VC directory buffer (@pxref{VC Directory Mode}),
625 the fileset may consist of multiple files; in that case, @kbd{C-c C-c}
626 will commit those files together, as a single revision, if that is
627 supported by the version control system (on older version control
628 systems, such as CVS, each file in a multi-file VC fileset is
629 committed as an individual revision).
630
631 @kindex C-c C-d @r{(Log Edit mode)}
632 @findex log-edit-show-diff
633 Type @kbd{C-c C-d} (@code{log-edit-show-diff}) to show a @dfn{diff}
634 of the changes between the current VC fileset and the repository
635 revision from which you started editing. @xref{Old Revisions}.
636
637 @kindex C-c C-a @r{(Log Edit mode)}
638 @findex log-edit-insert-changelog
639 If the VC fileset that is to be committed includes one or more
640 @file{ChangeLog} files (@pxref{Change Log}), type @kbd{C-c C-a}
641 (@code{log-edit-insert-changelog}) to pull the relevant entries into
642 the @samp{*vc-log*} buffer. If the topmost item in each
643 @file{ChangeLog} was made under your user name on the current date,
644 this command searches that item for entries matching the file(s) to be
645 committed, and inserts them.
646 @ifnottex
647 @xref{Change Logs and VC}, for the opposite way of
648 working---generating ChangeLog entries from the revision control log.
649 @end ifnottex
650
651 To abort a commit, just @strong{don't} type @kbd{C-c C-c} in that
652 buffer. You can switch buffers and do other editing. As long as you
653 don't try to make another commit, the entry you were editing remains
654 in the @samp{*vc-log*} buffer, and you can go back to that buffer at
655 any time to complete the commit.
656
657 @kindex M-n @r{(Log Edit mode)}
658 @kindex M-p @r{(Log Edit mode)}
659 @kindex M-s @r{(Log Edit mode)}
660 @kindex M-r @r{(Log Edit mode)}
661 You can also browse the history of previous log entries to duplicate
662 a commit comment. This can be useful when you want to make several
663 commits with similar comments. The commands @kbd{M-n}, @kbd{M-p},
664 @kbd{M-s} and @kbd{M-r} for doing this work just like the minibuffer
665 history commands (@pxref{Minibuffer History}), except that they are
666 used outside the minibuffer.
667
668 @node Registering
669 @subsection Registering a File for Version Control
670
671 @table @kbd
672 @item C-x v i
673 Register the visited file for version control.
674 @end table
675
676 @kindex C-x v i
677 @findex vc-register
678 The command @kbd{C-x v i} (@code{vc-register}) @dfn{registers} each
679 file in the current VC fileset, placing it under version control.
680 This is essentially equivalent to the action of @kbd{C-x v v} on an
681 unregistered VC fileset (@pxref{Basic VC Editing}), except that if the
682 VC fileset is already registered, @kbd{C-x v i} signals an error
683 whereas @kbd{C-x v v} performs some other action.
684
685 To register a file, Emacs must choose a version control system. For
686 a multi-file VC fileset, the VC Directory buffer specifies the system
687 to use (@pxref{VC Directory Mode}). For a single-file VC fileset, if
688 the file's directory already contains files registered in a version
689 control system, or if the directory is part of a directory tree
690 controlled by a version control system, Emacs chooses that system. In
691 the event that more than one version control system is applicable,
692 Emacs uses the one that appears first in the variable
693 @iftex
694 @code{vc-handled-backends}.
695 @end iftex
696 @ifnottex
697 @code{vc-handled-backends} (@pxref{Customizing VC}).
698 @end ifnottex
699 If Emacs cannot find a version control system to register the file
700 under, it prompts for a repository type, creates a new repository, and
701 registers the file into that repository.
702
703 On most version control systems, registering a file with @kbd{C-x v
704 i} or @kbd{C-x v v} adds it to the ``working tree'' but not to the
705 repository. Such files are labeled as @samp{added} in the VC
706 Directory buffer, and show a revision ID of @samp{@@@@} in the mode
707 line. To make the registration take effect in the repository, you
708 must perform a commit (@pxref{Basic VC Editing}). Note that on
709 changeset-based version control systems, commits can consist of both
710 file additions and modifications.
711
712 On a locking-based version control system (@pxref{VCS Merging}),
713 registering a file leaves it unlocked and read-only. Type @kbd{C-x v
714 v} if you wish to start editing it.
715
716 @node Old Revisions
717 @subsection Examining And Comparing Old Revisions
718
719 @table @kbd
720 @item C-x v =
721 Compare the work files in the current VC fileset with the versions you
722 started from (@code{vc-diff}). With a prefix argument, prompt for two
723 revisions of the current VC fileset and compare them. You can also
724 call this command from a Dired buffer (@pxref{Dired}).
725
726 @ifnottex
727 @item M-x vc-ediff
728 Like @kbd{C-x v =}, but using an Ediff session. @xref{Top, Ediff,
729 ediff, The Ediff Manual}.
730 @end ifnottex
731
732 @item C-x v D
733 Compare all work files in the current version controlled directory
734 tree to the tree you started from (@code{vc-root-diff}). With a
735 prefix argument, prompt for two revisions and compare their trees.
736
737 @item C-x v ~
738 Prompt for a revision of the current file, and visit it in a separate
739 buffer (@code{vc-revision-other-window}).
740
741 @item C-x v g
742 Display an annotated version of the current file: for each line, show
743 the latest revision in which it was modified (@code{vc-annotate}).
744 @end table
745
746 @findex vc-diff
747 @kindex C-x v =
748 @kbd{C-x v =} (@code{vc-diff}) displays a @dfn{diff} which compares
749 each work file in the current VC fileset to the version(s) from which
750 you started editing. The diff is displayed in another window, in a
751 Diff mode buffer (@pxref{Diff Mode}) named @file{*vc-diff*}. The
752 usual Diff mode commands are available in this buffer. In particular,
753 the @kbd{g} (@code{revert-buffer}) command performs the file
754 comparison again, generating a new diff.
755
756 @kindex C-u C-x v =
757 To compare two arbitrary revisions of the current VC fileset, call
758 @code{vc-diff} with a prefix argument: @kbd{C-u C-x v =}. This
759 prompts for two revision IDs (@pxref{VCS Concepts}), and displays a
760 diff between those versions of the fileset. This will not work
761 reliably for multi-file VC filesets, if the version control system is
762 file-based rather than changeset-based (e.g.@: CVS), since then
763 revision IDs for different files would not be related in any
764 meaningful way.
765
766 Instead of the revision ID, some version control systems let you
767 specify revisions in other formats. For instance, under Bazaar you
768 can enter @samp{date:yesterday} for the argument to @kbd{C-u C-x v =}
769 (and related commands) to specify the first revision committed after
770 yesterday. See the documentation of the version control system for
771 details.
772
773 If you invoke @kbd{C-x v =} or @kbd{C-u C-x v =} from a Dired buffer
774 (@pxref{Dired}), the file listed on the current line is treated as the
775 current VC fileset.
776
777 @ifnottex
778 @findex vc-ediff
779 @kbd{M-x vc-ediff} works like @kbd{C-x v =}, except that it uses an
780 Ediff session. @xref{Top, Ediff, ediff, The Ediff Manual}.
781 @end ifnottex
782
783 @findex vc-root-diff
784 @kindex C-x v D
785 @kbd{C-x v D} (@code{vc-root-diff}) is similar to @kbd{C-x v =}, but
786 it displays a comparison between the entire current version controlled
787 tree (i.e.@: the tree controlled by the version control system
788 associated with the current VC fileset, which may include files that
789 are not part of that fileset) and the tree you started with. If you
790 invoke this command from a Dired buffer, it applies to the entire
791 version controlled tree containing the directory.
792
793 @vindex vc-diff-switches
794 You can customize the @command{diff} options that @kbd{C-x v =} and
795 @kbd{C-x v D} use for generating diffs. The options used are taken
796 from the first non-@code{nil} value amongst the variables
797 @code{vc-@var{backend}-diff-switches}, @code{vc-diff-switches}, and
798 @code{diff-switches} (@pxref{Comparing Files}), in that order. Here,
799 @var{backend} stands for the current version control system,
800 e.g.@: @code{bzr} for Bazaar. Since @code{nil} means to check the
801 next variable in the sequence, either of the first two may use the
802 value @code{t} to mean no switches at all. Most of the
803 @code{vc-@var{backend}-diff-switches} variables default to @code{nil},
804 but some default to @code{t}; these are for version control systems,
805 such as Subversion, whose @code{diff} implementations do not accept
806 common diff options.
807
808 @findex vc-revision-other-window
809 @kindex C-x v ~
810 To directly examine an older version of a file, visit the work file
811 and type @kbd{C-x v ~ @var{revision} @key{RET}}
812 (@code{vc-revision-other-window}). This retrieves the file version
813 corresponding to @var{revision}, saves it to
814 @file{@var{filename}.~@var{revision}~}, and visits it in a separate
815 window.
816
817 @findex vc-annotate
818 @kindex C-x v g
819 Many version control systems allow you to view files @dfn{annotated}
820 with per-line revision information, by typing @kbd{C-x v g}
821 (@code{vc-annotate}). This creates a new buffer (the ``annotate
822 buffer'') displaying the file's text, with each line colored to show
823 how old it is. Red text is new, blue is old, and intermediate colors
824 indicate intermediate ages. By default, the color is scaled over the
825 full range of ages, such that the oldest changes are blue, and the
826 newest changes are red.
827
828 When you give a prefix argument to this command, Emacs reads two
829 arguments using the minibuffer: the revision to display and annotate
830 (instead of the current file contents), and the time span in days the
831 color range should cover.
832
833 From the annotate buffer, these and other color scaling options are
834 available from the @samp{VC-Annotate} menu. In this buffer, you can
835 also use the following keys to browse the annotations of past revisions,
836 view diffs, or view log entries:
837
838 @table @kbd
839 @item p
840 Annotate the previous revision, i.e.@: the revision before the one
841 currently annotated. A numeric prefix argument is a repeat count, so
842 @kbd{C-u 10 p} would take you back 10 revisions.
843
844 @item n
845 Annotate the next revision, i.e.@: the revision after the one
846 currently annotated. A numeric prefix argument is a repeat count.
847
848 @item j
849 Annotate the revision indicated by the current line.
850
851 @item a
852 Annotate the revision before the one indicated by the current line.
853 This is useful to see the state the file was in before the change on
854 the current line was made.
855
856 @item f
857 Show in a buffer the file revision indicated by the current line.
858
859 @item d
860 Display the diff between the current line's revision and the previous
861 revision. This is useful to see what the current line's revision
862 actually changed in the file.
863
864 @item D
865 Display the diff between the current line's revision and the previous
866 revision for all files in the changeset (for VC systems that support
867 changesets). This is useful to see what the current line's revision
868 actually changed in the tree.
869
870 @item l
871 Show the log of the current line's revision. This is useful to see
872 the author's description of the changes in the revision on the current
873 line.
874
875 @item w
876 Annotate the working revision--the one you are editing. If you used
877 @kbd{p} and @kbd{n} to browse to other revisions, use this key to
878 return to your working revision.
879
880 @item v
881 Toggle the annotation visibility. This is useful for looking just at
882 the file contents without distraction from the annotations.
883 @end table
884
885 @node VC Change Log
886 @subsection VC Change Log
887
888 @table @kbd
889 @item C-x v l
890 Display revision control state and change history
891 (@code{vc-print-log}).
892
893 @item C-x v L
894 Display the change history for the current repository
895 (@code{vc-print-root-log}).
896
897 @item C-x v I
898 Display the changes that will be received with a pull operation
899 (@code{vc-log-incoming}).
900
901 @item C-x v O
902 Display the changes that will be sent by the next push operation
903 (@code{vc-log-outgoing}).
904 @end table
905
906 @kindex C-x v l
907 @findex vc-print-log
908 The command @kbd{C-x v l} (@code{vc-print-log}) displays a buffer
909 named @samp{*vc-change-log*}, showing the history of changes made to
910 the current file, including who made the changes, the dates, and the
911 log entry for each change (these are the same log entries you would
912 enter via the @samp{*vc-log*} buffer; @pxref{Log Buffer}). Point is
913 centered at the revision of the file currently being visited. With a
914 prefix argument, the command prompts for the revision to center on,
915 and the maximum number of revisions to display.
916
917 If you call @kbd{C-x v l} from a VC Directory buffer (@pxref{VC
918 Directory Mode}) or a Dired buffer (@pxref{Dired}), it applies to the
919 file listed on the current line.
920
921 @findex vc-print-root-log
922 @findex log-view-toggle-entry-display
923 @kbd{C-x v L} (@code{vc-print-root-log}) displays a
924 @samp{*vc-change-log*} buffer showing the history of the entire
925 version-controlled directory tree (RCS, SCCS, and CVS do not support
926 this feature). With a prefix argument, the command prompts for the
927 maximum number of revisions to display.
928
929 The @kbd{C-x v L} history is shown in a compact form, usually
930 omitting all but the first line of each log entry. However, you can
931 type @key{RET} (@code{log-view-toggle-entry-display}) in the
932 @samp{*vc-change-log*} buffer to reveal the entire log entry for the
933 revision at point. A second @key{RET} hides it again.
934
935 On a distributed version control system, the @kbd{C-x v I}
936 (@code{vc-log-incoming}) command displays a log buffer showing the
937 changes that will be applied, the next time you run the version
938 control system's ``pull'' command to get new revisions from another
939 repository. This other repository is the default one from which
940 changes are pulled, as defined by the version control system; with a
941 prefix argument, @code{vc-log-incoming} prompts for a specific
942 repository. Similarly, @kbd{C-x v O} (@code{vc-log-outgoing}) shows
943 the changes that will be sent to another repository, the next time you
944 run the ``push'' command; with a prefix argument, it prompts for a
945 specific destination repository.
946
947 In the @samp{*vc-change-log*} buffer, you can use the following keys
948 to move between the logs of revisions and of files, and to examine and
949 compare past revisions (@pxref{Old Revisions}):
950
951 @table @kbd
952 @item p
953 Move to the previous revision entry. (Revision entries in the log
954 buffer are usually in reverse-chronological order, so the previous
955 revision-item usually corresponds to a newer revision.) A numeric
956 prefix argument is a repeat count.
957
958 @item n
959 Move to the next revision entry. A numeric prefix argument is a
960 repeat count.
961
962 @item P
963 Move to the log of the previous file, if showing logs for a multi-file
964 VC fileset. Otherwise, just move to the beginning of the log. A
965 numeric prefix argument is a repeat count.
966
967 @item N
968 Move to the log of the next file, if showing logs for a multi-file VC
969 fileset. A numeric prefix argument is a repeat count.
970
971 @item a
972 Annotate the revision on the current line (@pxref{Old Revisions}).
973
974 @item e
975 Modify the change comment displayed at point. Note that not all VC
976 systems support modifying change comments.
977
978 @item f
979 Visit the revision indicated at the current line.
980
981 @item d
982 Display a diff between the revision at point and the next earlier
983 revision, for the specific file.
984
985 @item D
986 Display the changeset diff between the revision at point and the next
987 earlier revision. This shows the changes to all files made in that
988 revision.
989
990 @item @key{RET}
991 In a compact-style log buffer (e.g.@: the one created by @kbd{C-x v
992 L}), toggle between showing and hiding the full log entry for the
993 revision at point.
994 @end table
995
996 @vindex vc-log-show-limit
997 Because fetching many log entries can be slow, the
998 @samp{*vc-change-log*} buffer displays no more than 2000 revisions by
999 default. The variable @code{vc-log-show-limit} specifies this limit;
1000 if you set the value to zero, that removes the limit. You can also
1001 increase the number of revisions shown in an existing
1002 @samp{*vc-change-log*} buffer by clicking on the @samp{Show 2X
1003 entries} or @samp{Show unlimited entries} buttons at the end of the
1004 buffer. However, RCS, SCCS, and CVS do not support this feature.
1005
1006 @node VC Undo
1007 @subsection Undoing Version Control Actions
1008
1009 @table @kbd
1010 @item C-x v u
1011 Revert the buffer and the file to the working revision from which you started
1012 editing the file.
1013
1014 @item C-x v c
1015 Remove the last-entered change from the master for the visited file.
1016 This undoes your last commit.
1017 @end table
1018
1019 @kindex C-x v u
1020 @findex vc-revert-buffer
1021 If you want to discard your current set of changes and revert to the
1022 working revision from which you started editing the file, use @kbd{C-x
1023 v u} (@code{vc-revert-buffer}). If the version control system is
1024 locking-based, this leaves the file unlocked, and you must lock it
1025 again before making new changes. @kbd{C-x v u} requires confirmation,
1026 unless it sees that you haven't made any changes with respect to the
1027 master copy of the working revision.
1028
1029 @kbd{C-x v u} is also the command to unlock a file if you lock it and
1030 then decide not to change it.
1031
1032 @kindex C-x v c
1033 @findex vc-rollback
1034 To cancel a change that you already committed, use @kbd{C-x v c}
1035 (@code{vc-rollback}). This command discards all record of the most
1036 recent checked-in revision, but only if your work file corresponds to
1037 that revision---you cannot use @kbd{C-x v c} to cancel a revision that
1038 is not the latest on its branch. Note that many version control
1039 systems do not support rollback at all; this command is something of a
1040 historical relic.
1041
1042 @node VC Directory Mode
1043 @subsection VC Directory Mode
1044
1045 @kindex C-x v d
1046 @findex vc-dir
1047 When you are working on a large program, it is often useful to find
1048 out which files have changed within an entire directory tree, or to
1049 view the status of all files under version control at once, and to
1050 perform version control operations on collections of files. You can
1051 use the command @kbd{C-x v d} (@code{vc-dir}) to make a directory
1052 listing that includes only files relevant for version control. This
1053 creates a @dfn{VC Directory buffer} and displays it in a separate
1054 window.
1055
1056 @cindex PCL-CVS
1057 @pindex cvs
1058 @cindex CVS directory mode
1059 The VC Directory buffer works with all the version control systems
1060 that VC supports. For CVS, Emacs also offers a more powerful facility
1061 called PCL-CVS. @xref{Top, , About PCL-CVS, pcl-cvs, PCL-CVS --- The
1062 Emacs Front-End to CVS}.
1063
1064 @menu
1065 * Buffer: VC Directory Buffer. What the buffer looks like and means.
1066 * Commands: VC Directory Commands. Commands to use in a VC directory buffer.
1067 @end menu
1068
1069 @node VC Directory Buffer
1070 @subsubsection The VC Directory Buffer
1071
1072 The VC Directory buffer contains a list of version-controlled files
1073 in the current directory and its subdirectories. Files which are
1074 up-to-date (have no local differences from the repository copy) are
1075 usually hidden; if all files in a subdirectory are up-to-date, the
1076 subdirectory is hidden as well. There is an exception to this rule:
1077 if VC mode detects that a file has changed to an up-to-date state
1078 since you last looked at it, that file and its state are shown.
1079
1080 If a directory uses more that one version control system, you can
1081 select which system to use for the @code{vc-dir} command by invoking
1082 @code{vc-dir} with a prefix argument: @kbd{C-u C-x v d}.
1083
1084 The line for an individual file shows the version control state of
1085 the file. Under RCS and SCCS, the name of the user locking the file
1086 is shown; under CVS, an abbreviated version of the @samp{cvs status}
1087 output is used. Here is an example using CVS:
1088
1089 @smallexample
1090 @group
1091 ./
1092 modified file1.c
1093 needs-update file2.c
1094 needs-merge file3.c
1095 @end group
1096 @end smallexample
1097
1098 @noindent
1099 In this example, @samp{file1.c} is modified with respect to the
1100 repository, and @samp{file2.c} is not. @samp{file3.c} is modified,
1101 but other changes have also been committed---you need to merge them
1102 with the work file before you can check it in.
1103
1104 @vindex vc-stay-local
1105 @vindex vc-cvs-stay-local
1106 In the above, if the repository were on a remote machine, VC only
1107 contacts it when the variable @code{vc-stay-local} (or
1108 @code{vc-cvs-stay-local}) is @code{nil}
1109 @iftex
1110 (@pxref{CVS Options,,,emacs-xtra, Specialized Emacs Features}).
1111 @end iftex
1112 @ifnottex
1113 (@pxref{CVS Options}).
1114 @end ifnottex
1115 This is because access to the repository may be slow, or you may be
1116 working offline and not have access to the repository at all. As a
1117 consequence, VC would not be able to tell you that @samp{file3.c} is
1118 in the ``merge'' state; you would learn that only when you try to
1119 commit your modified copy of the file, or use a command such as
1120 @kbd{C-x v m}.
1121
1122 In practice, this is not a problem because CVS handles this case
1123 consistently whenever it arises. In VC, you'll simply get prompted to
1124 merge the remote changes into your work file first. The benefits of
1125 less network communication usually outweigh the disadvantage of not
1126 seeing remote changes immediately.
1127
1128 @vindex vc-directory-exclusion-list
1129 When a VC directory displays subdirectories it omits some that
1130 should never contain any files under version control. By default,
1131 this includes Version Control subdirectories such as @samp{RCS} and
1132 @samp{CVS}; you can customize this by setting the variable
1133 @code{vc-directory-exclusion-list}.
1134
1135 @node VC Directory Commands
1136 @subsubsection VC Directory Commands
1137
1138 VC Directory mode has a full set of navigation and marking commands
1139 for picking out filesets. Some of these are also available in a
1140 context menu invoked by @kbd{mouse-2}.
1141
1142 Up- and down-arrow keys move in the buffer; @kbd{n} and @kbd{p} also
1143 move vertically as in other list-browsing modes. @key{SPC} and
1144 @key{TAB} behave like down-arrow, and @key{BackTab} behaves like
1145 up-arrow.
1146
1147 Both @kbd{C-m} and @kbd{f} visit the file on the current
1148 line. @kbd{o} visits that file in another window. @kbd{q} dismisses
1149 the directory buffer.
1150
1151 @kbd{x} hides up-to-date files.
1152
1153 @kbd{m} marks the file or directory on the current line. If the
1154 region is active, @kbd{m} marks all the files in the region. There
1155 are some restrictions when marking: a file cannot be marked if any of
1156 its parent directories are marked, and a directory cannot be marked if
1157 any files in it or in its child directories are marked.
1158
1159 @kbd{M} marks all the files with the same VC state as the current
1160 file if the cursor is on a file. If the cursor is on a directory, it
1161 marks all child files. With a prefix argument: marks all files and
1162 directories.
1163
1164 @kbd{u} unmarks the file or directory on the current line. If the
1165 region is active, it unmarks all the files in the region.
1166
1167 @kbd{U} marks all the files with the same VC state as the current file
1168 if the cursor is on a file. If the cursor is on a directory, it
1169 unmarks all child files. With a prefix argument: unmarks all marked
1170 files and directories.
1171
1172 It is possible to do search, search and replace, incremental search,
1173 and incremental regexp search on multiple files. These commands will
1174 work on all the marked files or the current file if nothing is marked.
1175 If a directory is marked, the files in that directory shown in the VC
1176 directory buffer will be used.
1177
1178 @kbd{S} searches the marked files.
1179
1180 @kbd{Q} does a query replace on the marked files.
1181
1182 @kbd{M-s a C-s} does an incremental search on the marked files.
1183
1184 @kbd{M-s a C-M-s} does an incremental regular expression search
1185 on the marked files.
1186
1187 @cindex stashes in version control
1188 @cindex shelves in version control
1189 Commands are also accessible from the VC-dir menu. Note that some
1190 VC backends use the VC-dir menu to make available extra,
1191 backend-specific, commands. For example, Git and Bazaar allow you to
1192 manipulate @dfn{stashes} and @dfn{shelves}. (These provide a
1193 mechanism to temporarily store uncommitted changes somewhere out of
1194 the way, and bring them back at a later time.)
1195
1196 Normal VC commands with the @kbd{C-x v} prefix work in VC directory
1197 buffers. Some single-key shortcuts are available as well; @kbd{=},
1198 @kbd{+}, @kbd{l}, @kbd{i}, and @kbd{v} behave as through prefixed with
1199 @kbd{C-x v}.
1200
1201 The command @kbd{C-x v v} (@code{vc-next-action}) operates on all
1202 the marked files, so that you can commit several files at once. If
1203 the underlying VC supports atomic commits of multiple-file changesets,
1204 @kbd{C-x v v} with a selected set of modified but not committed files
1205 will commit all of them at once as a single changeset.
1206
1207 When @kbd{C-x v v} (@code{vc-next-action}) operates on multiple
1208 files, all of those files must be either in the same state or in
1209 compatible states (added, modified and removed states are considered
1210 compatible). Otherwise it signals an error. This differs from the
1211 behavior of older versions of VC, which did not have fileset
1212 operations and simply did @code{vc-next-action} on each file
1213 individually.
1214
1215 If any files are in a state that calls for commit, @kbd{C-x v v} reads a
1216 single log entry and uses it for the changeset as a whole. If the
1217 underling VCS is file- rather than changeset-oriented, the log entry
1218 will be replicated into the history of each file.
1219
1220 @node Branches
1221 @subsection Multiple Branches of a File
1222 @cindex branch (version control)
1223 @cindex trunk (version control)
1224
1225 One use of version control is to maintain multiple ``current''
1226 revisions of a file. For example, you might have different revisions of a
1227 program in which you are gradually adding various unfinished new
1228 features. Each such independent line of development is called a
1229 @dfn{branch}. VC allows you to create branches, switch between
1230 different branches, and merge changes from one branch to another.
1231 Please note, however, that branches are not supported for SCCS.
1232
1233 A file's main line of development is usually called the @dfn{trunk}.
1234 You can create multiple branches from the trunk. How the difference
1235 between trunk and branch is made visible is dependent on whether the
1236 VCS uses dot-pair or monotonic version IDs.
1237
1238 In VCSes with dot-pair revision IDs, the revisions on the trunk are
1239 normally IDed 1.1, 1.2, 1.3, etc. At any such revision, you can
1240 start an independent branch. A branch starting at revision 1.2 would
1241 have revision ID 1.2.1.1, and consecutive revisions on this branch
1242 would have IDs 1.2.1.2, 1.2.1.3, 1.2.1.4, and so on. If there is
1243 a second branch also starting at revision 1.2, it would consist of
1244 revisions 1.2.2.1, 1.2.2.2, 1.2.2.3, etc.
1245
1246 In VCSes with monotonic revision IDs, trunk revisions are IDed as
1247 1, 2, 3, etc. A branch from (say) revision 2 might start with 2.1 and
1248 continue through 2.2, 2.3, etc. But naming conventions for branches
1249 and subbranches vary widely on these systems, and some (like
1250 Mercurial) never depart from the monotonic integer sequence at all.
1251 Consult the documentation of the VCS you are using.
1252
1253 @cindex head revision
1254 If you omit the final component of a dot-pair revision ID, that is called a
1255 @dfn{branch ID}. It refers to the highest existing revision on that
1256 branch---the @dfn{head revision} of that branch. The branches in the
1257 dot-pair example above have branch IDs 1.2.1 and 1.2.2.
1258
1259 @menu
1260 * Switching Branches:: How to get to another existing branch.
1261 * Creating Branches:: How to start a new branch.
1262 * Merging:: Transferring changes between branches.
1263 * Multi-User Branching:: Multiple users working at multiple branches
1264 in parallel.
1265 @end menu
1266
1267 @node Switching Branches
1268 @subsubsection Switching between Branches
1269
1270 To switch between branches, type @kbd{C-u C-x v v} and specify the
1271 revision ID you want to select. On a locking-based system, this
1272 version is then visited @emph{unlocked} (write-protected), so you can
1273 examine it before locking it. Switching branches in this way is allowed
1274 only when the file is not locked.
1275
1276 On a VCS with dot-pair IDs, you can omit the minor part, thus giving
1277 only the branch ID; this takes you to the head version on the
1278 chosen branch. If you only type @key{RET}, Emacs goes to the highest
1279 version on the trunk.
1280
1281 After you have switched to any branch (including the main branch), you
1282 stay on it for subsequent VC commands, until you explicitly select some
1283 other branch.
1284
1285 @node Creating Branches
1286 @subsubsection Creating New Branches
1287
1288 To create a new branch from a head revision (one that is the latest
1289 in the branch that contains it), first select that revision if
1290 necessary, lock it with @kbd{C-x v v}, and make whatever changes you
1291 want. Then, when you commit the changes, use @kbd{C-u C-x v v}. This
1292 lets you specify the revision ID for the new revision. You should
1293 specify a suitable branch ID for a branch starting at the current
1294 revision. For example, if the current revision is 2.5, the branch ID
1295 should be 2.5.1, 2.5.2, and so on, depending on the number of existing
1296 branches at that point.
1297
1298 To create a new branch at an older revision (one that is no longer the
1299 head of a branch), first select that revision (@pxref{Switching
1300 Branches}). Your procedure will then differ depending on whether you
1301 are using a locking or merging-based VCS.
1302
1303 On a locking VCS, you will need to lock the old revision branch with
1304 @kbd{C-x v v}. You'll be asked to confirm, when you lock the old
1305 revision, that you really mean to create a new branch---if you say no,
1306 you'll be offered a chance to lock the latest revision instead. On
1307 a merging-based VCS you will skip this step.
1308
1309 Then make your changes and type @kbd{C-x v v} again to commit a new
1310 revision. This automatically creates a new branch starting from the
1311 selected revision. You need not specially request a new branch,
1312 because that's the only way to add a new revision at a point that is
1313 not the head of a branch.
1314
1315 After the branch is created, you ``stay'' on it. That means that
1316 subsequent commits create new revisions on that branch. To leave the
1317 branch, you must explicitly select a different revision with @kbd{C-u C-x
1318 v v}. To transfer changes from one branch to another, use the merge
1319 command, described in the next section.
1320
1321 @node Merging
1322 @subsubsection Merging Branches
1323
1324 @cindex merging changes
1325 When you have finished the changes on a certain branch, you will
1326 often want to incorporate them into the file's main line of development
1327 (the trunk). This is not a trivial operation, because development might
1328 also have proceeded on the trunk, so that you must @dfn{merge} the
1329 changes into a file that has already been changed otherwise. VC allows
1330 you to do this (and other things) with the @code{vc-merge} command.
1331
1332 @table @kbd
1333 @item C-x v m (vc-merge)
1334 Merge changes into the work file.
1335 @end table
1336
1337 @kindex C-x v m
1338 @findex vc-merge
1339 @kbd{C-x v m} (@code{vc-merge}) takes a set of changes and merges it
1340 into the current version of the work file. It firsts asks you in the
1341 minibuffer where the changes should come from. If you just type
1342 @key{RET}, Emacs merges any changes that were made on the same branch
1343 since you checked the file out (we call this @dfn{merging the news}).
1344 This is the common way to pick up recent changes from the repository,
1345 regardless of whether you have already changed the file yourself.
1346
1347 You can also enter a branch ID or a pair of revision IDs in
1348 the minibuffer. Then @kbd{C-x v m} finds the changes from that
1349 branch, or the differences between the two revisions you specified, and
1350 merges them into the current revision of the current file.
1351
1352 As an example, suppose that you have finished a certain feature on
1353 branch 1.3.1. In the meantime, development on the trunk has proceeded
1354 to revision 1.5. To merge the changes from the branch to the trunk,
1355 first go to the head revision of the trunk, by typing @kbd{C-u C-x v v
1356 @key{RET}}. Revision 1.5 is now current. If locking is used for the file,
1357 type @kbd{C-x v v} to lock revision 1.5 so that you can change it. Next,
1358 type @kbd{C-x v m 1.3.1 @key{RET}}. This takes the entire set of changes on
1359 branch 1.3.1 (relative to revision 1.3, where the branch started, up to
1360 the last revision on the branch) and merges it into the current revision
1361 of the work file. You can now commit the changed file, thus creating
1362 revision 1.6 containing the changes from the branch.
1363
1364 It is possible to do further editing after merging the branch, before
1365 the next commit. But it is usually wiser to commit the merged
1366 revision, then lock it and make the further changes. This will keep
1367 a better record of the history of changes.
1368
1369 @cindex conflicts
1370 @cindex resolving conflicts
1371 When you merge changes into a file that has itself been modified, the
1372 changes might overlap. We call this situation a @dfn{conflict}, and
1373 reconciling the conflicting changes is called @dfn{resolving a
1374 conflict}.
1375
1376 Whenever conflicts occur during merging, VC detects them, tells you
1377 about them in the echo area, and asks whether you want help in merging.
1378 If you say yes, it starts an Ediff session (@pxref{Top,
1379 Ediff, Ediff, ediff, The Ediff Manual}).
1380
1381 If you say no, the conflicting changes are both inserted into the
1382 file, surrounded by @dfn{conflict markers}. The example below shows how
1383 a conflict region looks; the file is called @samp{name} and the current
1384 master file revision with user B's changes in it is 1.11.
1385
1386 @c @w here is so CVS won't think this is a conflict.
1387 @smallexample
1388 @group
1389 @w{<}<<<<<< name
1390 @var{User A's version}
1391 =======
1392 @var{User B's version}
1393 @w{>}>>>>>> 1.11
1394 @end group
1395 @end smallexample
1396
1397 @findex vc-resolve-conflicts
1398 Then you can resolve the conflicts by editing the file manually. Or
1399 you can type @code{M-x vc-resolve-conflicts} after visiting the file.
1400 This starts an Ediff session, as described above. Don't forget to
1401 commit the merged version afterwards.
1402
1403 @findex vc-find-conflicted-file
1404 If there is more than one conflicted file in a merge, type @kbd{M-x
1405 vc-find-conflicted-file} after resolving the conflicts in each file.
1406 This command visits the next conflicted file, and moves point to the
1407 first conflict marker in that file.
1408
1409 @node Multi-User Branching
1410 @subsubsection Multi-User Branching
1411
1412 It is often useful for multiple developers to work simultaneously on
1413 different branches of a file. CVS and later systems allow this by
1414 default; for RCS, it is possible if you create multiple source
1415 directories. Each source directory should have a link named
1416 @file{RCS} which points to a common directory of RCS master files.
1417 Then each source directory can have its own choice of selected
1418 revisions, but all share the same common RCS records.
1419
1420 This technique works reliably and automatically, provided that the
1421 source files contain RCS version headers
1422 @iftex
1423 (@pxref{Version Headers,,,emacs-xtra, Specialized Emacs Features}).
1424 @end iftex
1425 @ifnottex
1426 (@pxref{Version Headers}).
1427 @end ifnottex
1428 The headers enable Emacs to be sure, at all times, which revision
1429 ID is present in the work file.
1430
1431 If the files do not have version headers, you must instead tell Emacs
1432 explicitly in each session which branch you are working on. To do this,
1433 first find the file, then type @kbd{C-u C-x v v} and specify the correct
1434 branch ID. This ensures that Emacs knows which branch it is using
1435 during this particular editing session.
1436
1437 @ifnottex
1438 @include vc1-xtra.texi
1439 @end ifnottex
1440
1441 @node Change Log
1442 @section Change Logs
1443
1444 @cindex change log
1445 A change log file contains a chronological record of when and why you
1446 have changed a program, consisting of a sequence of entries describing
1447 individual changes. Normally it is kept in a file called
1448 @file{ChangeLog} in the same directory as the file you are editing, or
1449 one of its parent directories. A single @file{ChangeLog} file can
1450 record changes for all the files in its directory and all its
1451 subdirectories.
1452
1453 @menu
1454 * Change Log Commands:: Commands for editing change log files.
1455 * Format of ChangeLog:: What the change log file looks like.
1456 @end menu
1457
1458 @node Change Log Commands
1459 @subsection Change Log Commands
1460
1461 @kindex C-x 4 a
1462 @findex add-change-log-entry-other-window
1463 The Emacs command @kbd{C-x 4 a} adds a new entry to the change log
1464 file for the file you are editing
1465 (@code{add-change-log-entry-other-window}). If that file is actually
1466 a backup file, it makes an entry appropriate for the file's
1467 parent---that is useful for making log entries for functions that
1468 have been deleted in the current version.
1469
1470 @kbd{C-x 4 a} visits the change log file and creates a new entry
1471 unless the most recent entry is for today's date and your name. It
1472 also creates a new item for the current file. For many languages, it
1473 can even guess the name of the function or other object that was
1474 changed.
1475
1476 @vindex add-log-keep-changes-together
1477 When the variable @code{add-log-keep-changes-together} is
1478 non-@code{nil}, @kbd{C-x 4 a} adds to any existing item for the file
1479 rather than starting a new item.
1480
1481 You can combine multiple changes of the same nature. If you don't
1482 enter any text after the initial @kbd{C-x 4 a}, any subsequent
1483 @kbd{C-x 4 a} adds another symbol to the change.
1484
1485 @vindex add-log-always-start-new-record
1486 If @code{add-log-always-start-new-record} is non-@code{nil},
1487 @kbd{C-x 4 a} always makes a new entry, even if the last entry
1488 was made by you and on the same date.
1489
1490 @vindex change-log-version-info-enabled
1491 @vindex change-log-version-number-regexp-list
1492 @cindex file version in change log entries
1493 If the value of the variable @code{change-log-version-info-enabled}
1494 is non-@code{nil}, @kbd{C-x 4 a} adds the file's version number to the
1495 change log entry. It finds the version number by searching the first
1496 ten percent of the file, using regular expressions from the variable
1497 @code{change-log-version-number-regexp-list}.
1498
1499 @cindex Change Log mode
1500 @findex change-log-mode
1501 The change log file is visited in Change Log mode. In this major
1502 mode, each bunch of grouped items counts as one paragraph, and each
1503 entry is considered a page. This facilitates editing the entries.
1504 @kbd{C-j} and auto-fill indent each new line like the previous line;
1505 this is convenient for entering the contents of an entry.
1506
1507 You can use the @code{next-error} command (by default bound to
1508 @kbd{C-x `}) to move between entries in the Change Log, when Change
1509 Log mode is on. You will jump to the actual site in the file that was
1510 changed, not just to the next Change Log entry. You can also use
1511 @code{previous-error} to move back in the same list.
1512
1513 @findex change-log-merge
1514 You can use the command @kbd{M-x change-log-merge} to merge other
1515 log files into a buffer in Change Log Mode, preserving the date
1516 ordering of entries.
1517
1518 Version control systems are another way to keep track of changes in
1519 your program and keep a change log. In the VC log buffer, typing
1520 @kbd{C-c C-a} (@code{log-edit-insert-changelog}) inserts the relevant
1521 Change Log entry, if one exists (@pxref{Log Buffer}). You can also
1522 insert a VC log entry into a Change Log buffer by typing @kbd{C-x v a}
1523 (@code{vc-update-change-log}) in the Change Log buffer
1524 @iftex
1525 (@pxref{Change Logs and VC,,,emacs-xtra, Specialized Emacs Features}).
1526 @end iftex
1527 @ifnottex
1528 (@pxref{Change Logs and VC}).
1529 @end ifnottex
1530
1531 @node Format of ChangeLog
1532 @subsection Format of ChangeLog
1533
1534 A change log entry starts with a header line that contains the
1535 current date, your name (taken from the variable
1536 @code{add-log-full-name}), and your email address (taken from the
1537 variable @code{add-log-mailing-address}). Aside from these header
1538 lines, every line in the change log starts with a space or a tab. The
1539 bulk of the entry consists of @dfn{items}, each of which starts with a
1540 line starting with whitespace and a star. Here are two entries, both
1541 dated in May 1993, with two items and one item respectively.
1542
1543 @iftex
1544 @medbreak
1545 @end iftex
1546 @smallexample
1547 1993-05-25 Richard Stallman <rms@@gnu.org>
1548
1549 * man.el: Rename symbols `man-*' to `Man-*'.
1550 (manual-entry): Make prompt string clearer.
1551
1552 * simple.el (blink-matching-paren-distance):
1553 Change default to 12,000.
1554
1555 1993-05-24 Richard Stallman <rms@@gnu.org>
1556
1557 * vc.el (minor-mode-map-alist): Don't use it if it's void.
1558 (vc-cancel-version): Doc fix.
1559 @end smallexample
1560
1561 One entry can describe several changes; each change should have its
1562 own item, or its own line in an item. Normally there should be a
1563 blank line between items. When items are related (parts of the same
1564 change, in different places), group them by leaving no blank line
1565 between them.
1566
1567 You should put a copyright notice and permission notice at the
1568 end of the change log file. Here is an example:
1569
1570 @smallexample
1571 Copyright 1997, 1998 Free Software Foundation, Inc.
1572 Copying and distribution of this file, with or without modification, are
1573 permitted provided the copyright notice and this notice are preserved.
1574 @end smallexample
1575
1576 @noindent
1577 Of course, you should substitute the proper years and copyright holder.
1578
1579 @node Tags
1580 @section Tags Tables
1581 @cindex tags and tag tables
1582
1583 A @dfn{tag} is a reference to a subunit in a program or in a
1584 document. In program source code, tags reference syntactic elements
1585 of the program: functions, subroutines, data types, macros, etc. In a
1586 document, tags reference chapters, sections, appendices, etc. Each
1587 tag specifies the name of the file where the corresponding subunit is
1588 defined, and the position of the subunit's definition in that file.
1589
1590 A @dfn{tags table} records the tags extracted by scanning the source
1591 code of a certain program or a certain document. Tags extracted from
1592 generated files reference the original files, rather than the
1593 generated files that were scanned during tag extraction. Examples of
1594 generated files include C files generated from Cweb source files, from
1595 a Yacc parser, or from Lex scanner definitions; @file{.i} preprocessed
1596 C files; and Fortran files produced by preprocessing @file{.fpp}
1597 source files.
1598
1599 To produce a tags table, you use the @samp{etags} command,
1600 submitting it a document or the source code of a program.
1601 @samp{etags} writes the tags to a @dfn{tags table file}, or @dfn{tags
1602 file} in short. The conventional name for a tags file is @file{TAGS}.
1603
1604 Emacs uses the information recorded in tags tables in commands that
1605 search or replace through multiple source files: these commands use
1606 the names of the source files recorded in the tags table to know which
1607 files to search. Other commands, such as @kbd{M-.}, which finds the
1608 definition of a function, use the recorded information about the
1609 function names and positions to find the source file and the position
1610 within that file where the function is defined.
1611
1612 @cindex C++ class browser, tags
1613 @cindex tags, C++
1614 @cindex class browser, C++
1615 @cindex Ebrowse
1616 See also the Ebrowse facility, which is tailored for C++.
1617 @xref{Top,, Ebrowse, ebrowse, Ebrowse User's Manual}.
1618
1619 @menu
1620 * Tag Syntax:: Tag syntax for various types of code and text files.
1621 * Create Tags Table:: Creating a tags table with @code{etags}.
1622 * Etags Regexps:: Create arbitrary tags using regular expressions.
1623 * Select Tags Table:: How to visit a tags table.
1624 * Find Tag:: Commands to find the definition of a specific tag.
1625 * Tags Search:: Using a tags table for searching and replacing.
1626 * List Tags:: Listing and finding tags defined in a file.
1627 @end menu
1628
1629 @node Tag Syntax
1630 @subsection Source File Tag Syntax
1631
1632 Here is how tag syntax is defined for the most popular languages:
1633
1634 @itemize @bullet
1635 @item
1636 In C code, any C function or typedef is a tag, and so are definitions of
1637 @code{struct}, @code{union} and @code{enum}.
1638 @code{#define} macro definitions, @code{#undef} and @code{enum}
1639 constants are also
1640 tags, unless you specify @samp{--no-defines} when making the tags table.
1641 Similarly, global variables are tags, unless you specify
1642 @samp{--no-globals}, and so are struct members, unless you specify
1643 @samp{--no-members}. Use of @samp{--no-globals}, @samp{--no-defines}
1644 and @samp{--no-members} can make the tags table file much smaller.
1645
1646 You can tag function declarations and external variables in addition
1647 to function definitions by giving the @samp{--declarations} option to
1648 @code{etags}.
1649
1650 @item
1651 In C++ code, in addition to all the tag constructs of C code, member
1652 functions are also recognized; member variables are also recognized,
1653 unless you use the @samp{--no-members} option. Tags for variables and
1654 functions in classes are named @samp{@var{class}::@var{variable}} and
1655 @samp{@var{class}::@var{function}}. @code{operator} definitions have
1656 tag names like @samp{operator+}.
1657
1658 @item
1659 In Java code, tags include all the constructs recognized in C++, plus
1660 the @code{interface}, @code{extends} and @code{implements} constructs.
1661 Tags for variables and functions in classes are named
1662 @samp{@var{class}.@var{variable}} and @samp{@var{class}.@var{function}}.
1663
1664 @item
1665 In La@TeX{} text, the argument of any of the commands @code{\chapter},
1666 @code{\section}, @code{\subsection}, @code{\subsubsection},
1667 @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite},
1668 @code{\bibitem}, @code{\part}, @code{\appendix}, @code{\entry},
1669 @code{\index}, @code{\def}, @code{\newcommand}, @code{\renewcommand},
1670 @code{\newenvironment} or @code{\renewenvironment} is a tag.@refill
1671
1672 Other commands can make tags as well, if you specify them in the
1673 environment variable @env{TEXTAGS} before invoking @code{etags}. The
1674 value of this environment variable should be a colon-separated list of
1675 command names. For example,
1676
1677 @example
1678 TEXTAGS="mycommand:myothercommand"
1679 export TEXTAGS
1680 @end example
1681
1682 @noindent
1683 specifies (using Bourne shell syntax) that the commands
1684 @samp{\mycommand} and @samp{\myothercommand} also define tags.
1685
1686 @item
1687 In Lisp code, any function defined with @code{defun}, any variable
1688 defined with @code{defvar} or @code{defconst}, and in general the first
1689 argument of any expression that starts with @samp{(def} in column zero is
1690 a tag.
1691
1692 @item
1693 In Scheme code, tags include anything defined with @code{def} or with a
1694 construct whose name starts with @samp{def}. They also include variables
1695 set with @code{set!} at top level in the file.
1696 @end itemize
1697
1698 Several other languages are also supported:
1699
1700 @itemize @bullet
1701
1702 @item
1703 In Ada code, functions, procedures, packages, tasks and types are
1704 tags. Use the @samp{--packages-only} option to create tags for
1705 packages only.
1706
1707 In Ada, the same name can be used for different kinds of entity
1708 (e.g.@:, for a procedure and for a function). Also, for things like
1709 packages, procedures and functions, there is the spec (i.e.@: the
1710 interface) and the body (i.e.@: the implementation). To make it
1711 easier to pick the definition you want, Ada tag name have suffixes
1712 indicating the type of entity:
1713
1714 @table @samp
1715 @item /b
1716 package body.
1717 @item /f
1718 function.
1719 @item /k
1720 task.
1721 @item /p
1722 procedure.
1723 @item /s
1724 package spec.
1725 @item /t
1726 type.
1727 @end table
1728
1729 Thus, @kbd{M-x find-tag @key{RET} bidule/b @key{RET}} will go
1730 directly to the body of the package @code{bidule}, while @kbd{M-x
1731 find-tag @key{RET} bidule @key{RET}} will just search for any tag
1732 @code{bidule}.
1733
1734 @item
1735 In assembler code, labels appearing at the beginning of a line,
1736 followed by a colon, are tags.
1737
1738 @item
1739 In Bison or Yacc input files, each rule defines as a tag the nonterminal
1740 it constructs. The portions of the file that contain C code are parsed
1741 as C code.
1742
1743 @item
1744 In Cobol code, tags are paragraph names; that is, any word starting in
1745 column 8 and followed by a period.
1746
1747 @item
1748 In Erlang code, the tags are the functions, records and macros defined
1749 in the file.
1750
1751 @item
1752 In Fortran code, functions, subroutines and block data are tags.
1753
1754 @item
1755 In HTML input files, the tags are the @code{title} and the @code{h1},
1756 @code{h2}, @code{h3} headers. Also, tags are @code{name=} in anchors
1757 and all occurrences of @code{id=}.
1758
1759 @item
1760 In Lua input files, all functions are tags.
1761
1762 @item
1763 In makefiles, targets are tags; additionally, variables are tags
1764 unless you specify @samp{--no-globals}.
1765
1766 @item
1767 In Objective C code, tags include Objective C definitions for classes,
1768 class categories, methods and protocols. Tags for variables and
1769 functions in classes are named @samp{@var{class}::@var{variable}} and
1770 @samp{@var{class}::@var{function}}.
1771
1772 @item
1773 In Pascal code, the tags are the functions and procedures defined in
1774 the file.
1775
1776 @item
1777 In Perl code, the tags are the packages, subroutines and variables
1778 defined by the @code{package}, @code{sub}, @code{my} and @code{local}
1779 keywords. Use @samp{--globals} if you want to tag global variables.
1780 Tags for subroutines are named @samp{@var{package}::@var{sub}}. The
1781 name for subroutines defined in the default package is
1782 @samp{main::@var{sub}}.
1783
1784 @item
1785 In PHP code, tags are functions, classes and defines. Vars are tags
1786 too, unless you use the @samp{--no-members} option.
1787
1788 @item
1789 In PostScript code, the tags are the functions.
1790
1791 @item
1792 In Prolog code, tags are predicates and rules at the beginning of
1793 line.
1794
1795 @item
1796 In Python code, @code{def} or @code{class} at the beginning of a line
1797 generate a tag.
1798 @end itemize
1799
1800 You can also generate tags based on regexp matching (@pxref{Etags
1801 Regexps}) to handle other formats and languages.
1802
1803 @node Create Tags Table
1804 @subsection Creating Tags Tables
1805 @cindex @code{etags} program
1806
1807 The @code{etags} program is used to create a tags table file. It knows
1808 the syntax of several languages, as described in
1809 @iftex
1810 the previous section.
1811 @end iftex
1812 @ifnottex
1813 @ref{Tag Syntax}.
1814 @end ifnottex
1815 Here is how to run @code{etags}:
1816
1817 @example
1818 etags @var{inputfiles}@dots{}
1819 @end example
1820
1821 @noindent
1822 The @code{etags} program reads the specified files, and writes a tags
1823 table named @file{TAGS} in the current working directory. You can
1824 optionally specify a different file name for the tags table by using the
1825 @samp{--output=@var{file}} option; specifying @file{-} as a file name
1826 prints the tags table to standard output.
1827
1828 If the specified files don't exist, @code{etags} looks for
1829 compressed versions of them and uncompresses them to read them. Under
1830 MS-DOS, @code{etags} also looks for file names like @file{mycode.cgz}
1831 if it is given @samp{mycode.c} on the command line and @file{mycode.c}
1832 does not exist.
1833
1834 @code{etags} recognizes the language used in an input file based on
1835 its file name and contents. You can specify the language with the
1836 @samp{--language=@var{name}} option, described below.
1837
1838 If the tags table data become outdated due to changes in the files
1839 described in the table, the way to update the tags table is the same
1840 way it was made in the first place. If the tags table fails to record
1841 a tag, or records it for the wrong file, then Emacs cannot possibly
1842 find its definition until you update the tags table. However, if the
1843 position recorded in the tags table becomes a little bit wrong (due to
1844 other editing), the worst consequence is a slight delay in finding the
1845 tag. Even if the stored position is very far wrong, Emacs will still
1846 find the tag, after searching most of the file for it. That delay is
1847 hardly noticeable with today's computers.
1848
1849 Thus, there is no need to update the tags table after each edit.
1850 You should update a tags table when you define new tags that you want
1851 to have listed, or when you move tag definitions from one file to
1852 another, or when changes become substantial.
1853
1854 One tags table can virtually include another. Specify the included
1855 tags file name with the @samp{--include=@var{file}} option when
1856 creating the file that is to include it. The latter file then acts as
1857 if it covered all the source files specified in the included file, as
1858 well as the files it directly contains.
1859
1860 If you specify the source files with relative file names when you run
1861 @code{etags}, the tags file will contain file names relative to the
1862 directory where the tags file was initially written. This way, you can
1863 move an entire directory tree containing both the tags file and the
1864 source files, and the tags file will still refer correctly to the source
1865 files. If the tags file is @file{-} or is in the @file{/dev} directory,
1866 however, the file names are
1867 made relative to the current working directory. This is useful, for
1868 example, when writing the tags to @file{/dev/stdout}.
1869
1870 When using a relative file name, it should not be a symbolic link
1871 pointing to a tags file in a different directory, because this would
1872 generally render the file names invalid.
1873
1874 If you specify absolute file names as arguments to @code{etags}, then
1875 the tags file will contain absolute file names. This way, the tags file
1876 will still refer to the same files even if you move it, as long as the
1877 source files remain in the same place. Absolute file names start with
1878 @samp{/}, or with @samp{@var{device}:/} on MS-DOS and MS-Windows.
1879
1880 When you want to make a tags table from a great number of files, you
1881 may have problems listing them on the command line, because some systems
1882 have a limit on its length. The simplest way to circumvent this limit
1883 is to tell @code{etags} to read the file names from its standard input,
1884 by typing a dash in place of the file names, like this:
1885
1886 @smallexample
1887 find . -name "*.[chCH]" -print | etags -
1888 @end smallexample
1889
1890 Use the option @samp{--language=@var{name}} to specify the language
1891 explicitly. You can intermix these options with file names; each one
1892 applies to the file names that follow it. Specify
1893 @samp{--language=auto} to tell @code{etags} to resume guessing the
1894 language from the file names and file contents. Specify
1895 @samp{--language=none} to turn off language-specific processing
1896 entirely; then @code{etags} recognizes tags by regexp matching alone
1897 (@pxref{Etags Regexps}).
1898
1899 The option @samp{--parse-stdin=@var{file}} is mostly useful when
1900 calling @code{etags} from programs. It can be used (only once) in
1901 place of a file name on the command line. @code{Etags} will read from
1902 standard input and mark the produced tags as belonging to the file
1903 @var{file}.
1904
1905 @samp{etags --help} outputs the list of the languages @code{etags}
1906 knows, and the file name rules for guessing the language. It also prints
1907 a list of all the available @code{etags} options, together with a short
1908 explanation. If followed by one or more @samp{--language=@var{lang}}
1909 options, it outputs detailed information about how tags are generated for
1910 @var{lang}.
1911
1912 @node Etags Regexps
1913 @subsection Etags Regexps
1914
1915 The @samp{--regex} option provides a general way of recognizing tags
1916 based on regexp matching. You can freely intermix this option with
1917 file names, and each one applies to the source files that follow it.
1918 If you specify multiple @samp{--regex} options, all of them are used
1919 in parallel. The syntax is:
1920
1921 @smallexample
1922 --regex=[@var{@{language@}}]/@var{tagregexp}/[@var{nameregexp}/]@var{modifiers}
1923 @end smallexample
1924
1925 The essential part of the option value is @var{tagregexp}, the
1926 regexp for matching tags. It is always used anchored, that is, it
1927 only matches at the beginning of a line. If you want to allow
1928 indented tags, use a regexp that matches initial whitespace; start it
1929 with @samp{[ \t]*}.
1930
1931 In these regular expressions, @samp{\} quotes the next character, and
1932 all the GCC character escape sequences are supported (@samp{\a} for
1933 bell, @samp{\b} for back space, @samp{\d} for delete, @samp{\e} for
1934 escape, @samp{\f} for formfeed, @samp{\n} for newline, @samp{\r} for
1935 carriage return, @samp{\t} for tab, and @samp{\v} for vertical tab).
1936
1937 Ideally, @var{tagregexp} should not match more characters than are
1938 needed to recognize what you want to tag. If the syntax requires you
1939 to write @var{tagregexp} so it matches more characters beyond the tag
1940 itself, you should add a @var{nameregexp}, to pick out just the tag.
1941 This will enable Emacs to find tags more accurately and to do
1942 completion on tag names more reliably. You can find some examples
1943 below.
1944
1945 The @var{modifiers} are a sequence of zero or more characters that
1946 modify the way @code{etags} does the matching. A regexp with no
1947 modifiers is applied sequentially to each line of the input file, in a
1948 case-sensitive way. The modifiers and their meanings are:
1949
1950 @table @samp
1951 @item i
1952 Ignore case when matching this regexp.
1953 @item m
1954 Match this regular expression against the whole file, so that
1955 multi-line matches are possible.
1956 @item s
1957 Match this regular expression against the whole file, and allow
1958 @samp{.} in @var{tagregexp} to match newlines.
1959 @end table
1960
1961 The @samp{-R} option cancels all the regexps defined by preceding
1962 @samp{--regex} options. It too applies to the file names following
1963 it. Here's an example:
1964
1965 @smallexample
1966 etags --regex=/@var{reg1}/i voo.doo --regex=/@var{reg2}/m \
1967 bar.ber -R --lang=lisp los.er
1968 @end smallexample
1969
1970 @noindent
1971 Here @code{etags} chooses the parsing language for @file{voo.doo} and
1972 @file{bar.ber} according to their contents. @code{etags} also uses
1973 @var{reg1} to recognize additional tags in @file{voo.doo}, and both
1974 @var{reg1} and @var{reg2} to recognize additional tags in
1975 @file{bar.ber}. @var{reg1} is checked against each line of
1976 @file{voo.doo} and @file{bar.ber}, in a case-insensitive way, while
1977 @var{reg2} is checked against the whole @file{bar.ber} file,
1978 permitting multi-line matches, in a case-sensitive way. @code{etags}
1979 uses only the Lisp tags rules, with no user-specified regexp matching,
1980 to recognize tags in @file{los.er}.
1981
1982 You can restrict a @samp{--regex} option to match only files of a
1983 given language by using the optional prefix @var{@{language@}}.
1984 (@samp{etags --help} prints the list of languages recognized by
1985 @code{etags}.) This is particularly useful when storing many
1986 predefined regular expressions for @code{etags} in a file. The
1987 following example tags the @code{DEFVAR} macros in the Emacs source
1988 files, for the C language only:
1989
1990 @smallexample
1991 --regex='@{c@}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
1992 @end smallexample
1993
1994 @noindent
1995 When you have complex regular expressions, you can store the list of
1996 them in a file. The following option syntax instructs @code{etags} to
1997 read two files of regular expressions. The regular expressions
1998 contained in the second file are matched without regard to case.
1999
2000 @smallexample
2001 --regex=@@@var{case-sensitive-file} --ignore-case-regex=@@@var{ignore-case-file}
2002 @end smallexample
2003
2004 @noindent
2005 A regex file for @code{etags} contains one regular expression per
2006 line. Empty lines, and lines beginning with space or tab are ignored.
2007 When the first character in a line is @samp{@@}, @code{etags} assumes
2008 that the rest of the line is the name of another file of regular
2009 expressions; thus, one such file can include another file. All the
2010 other lines are taken to be regular expressions. If the first
2011 non-whitespace text on the line is @samp{--}, that line is a comment.
2012
2013 For example, we can create a file called @samp{emacs.tags} with the
2014 following contents:
2015
2016 @smallexample
2017 -- This is for GNU Emacs C source files
2018 @{c@}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/
2019 @end smallexample
2020
2021 @noindent
2022 and then use it like this:
2023
2024 @smallexample
2025 etags --regex=@@emacs.tags *.[ch] */*.[ch]
2026 @end smallexample
2027
2028 Here are some more examples. The regexps are quoted to protect them
2029 from shell interpretation.
2030
2031 @itemize @bullet
2032
2033 @item
2034 Tag Octave files:
2035
2036 @smallexample
2037 etags --language=none \
2038 --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \
2039 --regex='/###key \(.*\)/\1/' \
2040 --regex='/[ \t]*global[ \t].*/' \
2041 *.m
2042 @end smallexample
2043
2044 @noindent
2045 Note that tags are not generated for scripts, so that you have to add
2046 a line by yourself of the form @samp{###key @var{scriptname}} if you
2047 want to jump to it.
2048
2049 @item
2050 Tag Tcl files:
2051
2052 @smallexample
2053 etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl
2054 @end smallexample
2055
2056 @item
2057 Tag VHDL files:
2058
2059 @smallexample
2060 etags --language=none \
2061 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \
2062 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
2063 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
2064 @end smallexample
2065 @end itemize
2066
2067 @node Select Tags Table
2068 @subsection Selecting a Tags Table
2069
2070 @vindex tags-file-name
2071 @findex visit-tags-table
2072 Emacs has at any time one @dfn{selected} tags table, and all the
2073 commands for working with tags tables use the selected one. To select
2074 a tags table, type @kbd{M-x visit-tags-table}, which reads the tags
2075 table file name as an argument, with @file{TAGS} in the default
2076 directory as the default.
2077
2078 Emacs does not actually read in the tags table contents until you
2079 try to use them; all @code{visit-tags-table} does is store the file
2080 name in the variable @code{tags-file-name}, and setting the variable
2081 yourself is just as good. The variable's initial value is @code{nil};
2082 that value tells all the commands for working with tags tables that
2083 they must ask for a tags table file name to use.
2084
2085 Using @code{visit-tags-table} when a tags table is already loaded
2086 gives you a choice: you can add the new tags table to the current list
2087 of tags tables, or start a new list. The tags commands use all the tags
2088 tables in the current list. If you start a new list, the new tags table
2089 is used @emph{instead} of others. If you add the new table to the
2090 current list, it is used @emph{as well as} the others.
2091
2092 @vindex tags-table-list
2093 You can specify a precise list of tags tables by setting the variable
2094 @code{tags-table-list} to a list of strings, like this:
2095
2096 @c keep this on two lines for formatting in smallbook
2097 @example
2098 @group
2099 (setq tags-table-list
2100 '("~/emacs" "/usr/local/lib/emacs/src"))
2101 @end group
2102 @end example
2103
2104 @noindent
2105 This tells the tags commands to look at the @file{TAGS} files in your
2106 @file{~/emacs} directory and in the @file{/usr/local/lib/emacs/src}
2107 directory. The order depends on which file you are in and which tags
2108 table mentions that file, as explained above.
2109
2110 Do not set both @code{tags-file-name} and @code{tags-table-list}.
2111
2112 @node Find Tag
2113 @subsection Finding a Tag
2114
2115 The most important thing that a tags table enables you to do is to find
2116 the definition of a specific tag.
2117
2118 @table @kbd
2119 @item M-.@: @var{tag} @key{RET}
2120 Find first definition of @var{tag} (@code{find-tag}).
2121 @item C-u M-.
2122 Find next alternate definition of last tag specified.
2123 @item C-u - M-.
2124 Go back to previous tag found.
2125 @item C-M-. @var{pattern} @key{RET}
2126 Find a tag whose name matches @var{pattern} (@code{find-tag-regexp}).
2127 @item C-u C-M-.
2128 Find the next tag whose name matches the last pattern used.
2129 @item C-x 4 .@: @var{tag} @key{RET}
2130 Find first definition of @var{tag}, but display it in another window
2131 (@code{find-tag-other-window}).
2132 @item C-x 5 .@: @var{tag} @key{RET}
2133 Find first definition of @var{tag}, and create a new frame to select the
2134 buffer (@code{find-tag-other-frame}).
2135 @item M-*
2136 Pop back to where you previously invoked @kbd{M-.} and friends.
2137 @end table
2138
2139 @kindex M-.
2140 @findex find-tag
2141 @kbd{M-.}@: (@code{find-tag}) is the command to find the definition of
2142 a specified tag. It searches through the tags table for that tag, as a
2143 string, and then uses the tags table info to determine the file that the
2144 definition is in and the approximate character position in the file of
2145 the definition. Then @code{find-tag} visits that file, moves point to
2146 the approximate character position, and searches ever-increasing
2147 distances away to find the tag definition.
2148
2149 If an empty argument is given (just type @key{RET}), the balanced
2150 expression in the buffer before or around point is used as the
2151 @var{tag} argument. @xref{Expressions}.
2152
2153 You don't need to give @kbd{M-.} the full name of the tag; a part
2154 will do. This is because @kbd{M-.} finds tags in the table which
2155 contain @var{tag} as a substring. However, it prefers an exact match
2156 to a substring match. To find other tags that match the same
2157 substring, give @code{find-tag} a numeric argument, as in @kbd{C-u
2158 M-.}; this does not read a tag name, but continues searching the tags
2159 table's text for another tag containing the same substring last used.
2160 If you have a real @key{META} key, @kbd{M-0 M-.}@: is an easier
2161 alternative to @kbd{C-u M-.}.
2162
2163 @kindex C-x 4 .
2164 @findex find-tag-other-window
2165 @kindex C-x 5 .
2166 @findex find-tag-other-frame
2167 Like most commands that can switch buffers, @code{find-tag} has a
2168 variant that displays the new buffer in another window, and one that
2169 makes a new frame for it. The former is @w{@kbd{C-x 4 .}}, which invokes
2170 the command @code{find-tag-other-window}. The latter is @w{@kbd{C-x 5 .}},
2171 which invokes @code{find-tag-other-frame}.
2172
2173 To move back to places you've found tags recently, use @kbd{C-u -
2174 M-.}; more generally, @kbd{M-.} with a negative numeric argument. This
2175 command can take you to another buffer. @w{@kbd{C-x 4 .}} with a negative
2176 argument finds the previous tag location in another window.
2177
2178 @kindex M-*
2179 @findex pop-tag-mark
2180 @vindex find-tag-marker-ring-length
2181 As well as going back to places you've found tags recently, you can go
2182 back to places @emph{from where} you found them. Use @kbd{M-*}, which
2183 invokes the command @code{pop-tag-mark}, for this. Typically you would
2184 find and study the definition of something with @kbd{M-.} and then
2185 return to where you were with @kbd{M-*}.
2186
2187 Both @kbd{C-u - M-.} and @kbd{M-*} allow you to retrace your steps to
2188 a depth determined by the variable @code{find-tag-marker-ring-length}.
2189
2190 @findex find-tag-regexp
2191 @kindex C-M-.
2192 The command @kbd{C-M-.} (@code{find-tag-regexp}) visits the tags that
2193 match a specified regular expression. It is just like @kbd{M-.} except
2194 that it does regexp matching instead of substring matching.
2195
2196 @node Tags Search
2197 @subsection Searching and Replacing with Tags Tables
2198 @cindex search and replace in multiple files
2199 @cindex multiple-file search and replace
2200
2201 The commands in this section visit and search all the files listed
2202 in the selected tags table, one by one. For these commands, the tags
2203 table serves only to specify a sequence of files to search. These
2204 commands scan the list of tags tables starting with the first tags
2205 table (if any) that describes the current file, proceed from there to
2206 the end of the list, and then scan from the beginning of the list
2207 until they have covered all the tables in the list.
2208
2209 @table @kbd
2210 @item M-x tags-search @key{RET} @var{regexp} @key{RET}
2211 Search for @var{regexp} through the files in the selected tags
2212 table.
2213 @item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
2214 Perform a @code{query-replace-regexp} on each file in the selected tags table.
2215 @item M-,
2216 Restart one of the commands above, from the current location of point
2217 (@code{tags-loop-continue}).
2218 @end table
2219
2220 @findex tags-search
2221 @kbd{M-x tags-search} reads a regexp using the minibuffer, then
2222 searches for matches in all the files in the selected tags table, one
2223 file at a time. It displays the name of the file being searched so you
2224 can follow its progress. As soon as it finds an occurrence,
2225 @code{tags-search} returns.
2226
2227 @kindex M-,
2228 @findex tags-loop-continue
2229 Having found one match, you probably want to find all the rest. To find
2230 one more match, type @kbd{M-,} (@code{tags-loop-continue}) to resume the
2231 @code{tags-search}. This searches the rest of the current buffer, followed
2232 by the remaining files of the tags table.@refill
2233
2234 @findex tags-query-replace
2235 @kbd{M-x tags-query-replace} performs a single
2236 @code{query-replace-regexp} through all the files in the tags table. It
2237 reads a regexp to search for and a string to replace with, just like
2238 ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x
2239 tags-search}, but repeatedly, processing matches according to your
2240 input. @xref{Replace}, for more information on query replace.
2241
2242 @vindex tags-case-fold-search
2243 @cindex case-sensitivity and tags search
2244 You can control the case-sensitivity of tags search commands by
2245 customizing the value of the variable @code{tags-case-fold-search}. The
2246 default is to use the same setting as the value of
2247 @code{case-fold-search} (@pxref{Search Case}).
2248
2249 It is possible to get through all the files in the tags table with a
2250 single invocation of @kbd{M-x tags-query-replace}. But often it is
2251 useful to exit temporarily, which you can do with any input event that
2252 has no special query replace meaning. You can resume the query
2253 replace subsequently by typing @kbd{M-,}; this command resumes the
2254 last tags search or replace command that you did. For instance, to
2255 skip the rest of the current file, you can type @kbd{M-> M-,}.
2256
2257 The commands in this section carry out much broader searches than the
2258 @code{find-tag} family. The @code{find-tag} commands search only for
2259 definitions of tags that match your substring or regexp. The commands
2260 @code{tags-search} and @code{tags-query-replace} find every occurrence
2261 of the regexp, as ordinary search commands and replace commands do in
2262 the current buffer.
2263
2264 These commands create buffers only temporarily for the files that they
2265 have to search (those which are not already visited in Emacs buffers).
2266 Buffers in which no match is found are quickly killed; the others
2267 continue to exist.
2268
2269 It may have struck you that @code{tags-search} is a lot like
2270 @code{grep}. You can also run @code{grep} itself as an inferior of
2271 Emacs and have Emacs show you the matching lines one by one.
2272 @xref{Grep Searching}.
2273
2274 @node List Tags
2275 @subsection Tags Table Inquiries
2276
2277 @table @kbd
2278 @item M-x list-tags @key{RET} @var{file} @key{RET}
2279 Display a list of the tags defined in the program file @var{file}.
2280 @item M-x tags-apropos @key{RET} @var{regexp} @key{RET}
2281 Display a list of all tags matching @var{regexp}.
2282 @end table
2283
2284 @findex list-tags
2285 @kbd{M-x list-tags} reads the name of one of the files described by
2286 the selected tags table, and displays a list of all the tags defined in
2287 that file. The ``file name'' argument is really just a string to
2288 compare against the file names recorded in the tags table; it is read as
2289 a string rather than as a file name. Therefore, completion and
2290 defaulting are not available, and you must enter the file name the same
2291 way it appears in the tags table. Do not include a directory as part of
2292 the file name unless the file name recorded in the tags table includes a
2293 directory.
2294
2295 @findex tags-apropos
2296 @vindex tags-apropos-verbose
2297 @kbd{M-x tags-apropos} is like @code{apropos} for tags
2298 (@pxref{Apropos}). It finds all the tags in the selected tags table
2299 whose entries match @var{regexp}, and displays them. If the variable
2300 @code{tags-apropos-verbose} is non-@code{nil}, it displays the names
2301 of the tags files together with the tag names.
2302
2303 @vindex tags-tag-face
2304 @vindex tags-apropos-additional-actions
2305 You can customize the appearance of the output by setting the
2306 variable @code{tags-tag-face} to a face. You can display additional
2307 output with @kbd{M-x tags-apropos} by customizing the variable
2308 @code{tags-apropos-additional-actions}---see its documentation for
2309 details.
2310
2311 You can also use the collection of tag names to complete a symbol
2312 name in the buffer. @xref{Symbol Completion}.
2313
2314 You can use @kbd{M-x next-file} to visit the files in the selected
2315 tags table. The first time this command is called, it visits the
2316 first file in the tags table. Each subsequent call visits the next
2317 file in the table, unless a prefix argument is supplied, in which case
2318 it returns to the first file.
2319
2320 @node EDE
2321 @section Emacs Development Environment
2322 @cindex EDE (Emacs Development Environment)
2323 @cindex Emacs Development Environment
2324 @cindex Integrated development environment
2325
2326 EDE (@dfn{Emacs Development Environment}) is a package that simplifies
2327 the task of creating, building, and debugging large programs with
2328 Emacs. It provides some of the features of an IDE, or @dfn{Integrated
2329 Development Environment}, in Emacs.
2330
2331 This section provides a brief description of EDE usage.
2332 @ifnottex
2333 For full details, see @ref{Top, EDE,, ede, Emacs Development Environment}.
2334 @end ifnottex
2335 @iftex
2336 For full details on Ede, type @kbd{C-h i} and then select the EDE
2337 manual.
2338 @end iftex
2339
2340 EDE is implemented as a global minor mode (@pxref{Minor Modes}). To
2341 enable it, type @kbd{M-x global-ede-mode} or click on the
2342 @samp{Project Support (EDE)} item in the @samp{Tools} menu. You can
2343 also enable EDE each time you start Emacs, by adding the following
2344 line to your initialization file:
2345
2346 @smallexample
2347 (global-ede-mode t)
2348 @end smallexample
2349
2350 @noindent
2351 Activating EDE adds a menu named @samp{Development} to the menu bar.
2352 Many EDE commands, including the ones described below, can be invoked
2353 from this menu.
2354
2355 EDE organizes files into @dfn{projects}, which correspond to
2356 directory trees. The @dfn{project root} is the topmost directory of a
2357 project. To define a new project, visit a file in the desired project
2358 root and type @kbd{M-x ede-new}. This command prompts for a
2359 @dfn{project type}, which refers to the underlying method that EDE
2360 will use to manage the project (@pxref{Creating a Project, EDE,, ede,
2361 Emacs Development Environment}). The most common project types are
2362 @samp{Make}, which uses Makefiles, and @samp{Automake}, which uses GNU
2363 Automake (@pxref{Top, Automake,, automake, Automake}). In both cases,
2364 EDE also creates a file named @file{Project.ede}, which stores
2365 information about the project.
2366
2367 A project may contain one or more @dfn{targets}. A target can be an
2368 object file, executable program, or some other type of file, which is
2369 ``built'' from one or more of the files in the project.
2370
2371 To add a new @dfn{target} to a project, type @kbd{C-c . t}
2372 (@code{M-x ede-new-target}). This command also asks if you wish to
2373 ``add'' the current file to that target, which means that the target
2374 is to be built from that file. After you have defined a target, you
2375 can add more files to it by typing @kbd{C-c . a}
2376 (@code{ede-add-file}).
2377
2378 To build a target, type @kbd{C-c . c} (@code{ede-compile-target}).
2379 To build all the targets in the project, type @kbd{C-c . C}
2380 (@code{ede-compile-project}). EDE uses the file types to guess how
2381 the target should be built.
2382
2383 @ifnottex
2384 @include emerge-xtra.texi
2385 @end ifnottex