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