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