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