aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2006-05-06 13:01:14 +0000
committerEli Zaretskii2006-05-06 13:01:14 +0000
commit240ce8099f86abdfcbaefc8387e8a43218652866 (patch)
treee427698cb7469839cafd93fe5f20e4627fca880c
parent030409091898c6e5a6c05b4706ab827d0636a0e7 (diff)
downloademacs-240ce8099f86abdfcbaefc8387e8a43218652866.tar.gz
emacs-240ce8099f86abdfcbaefc8387e8a43218652866.zip
(Introduction): Reword to make consistent with printed version only.
(MS-DOS): Renamed from "MS-DOG". All references updated. (Daylight Savings): Remove this node: it is an exact duplicate of its name-sake in calendar.texi. <Top level>: Remove the body of all chapters and move them to the new *-xtra.texi files. Use @raisesections and @lowersections to convert sections to chapters etc.
-rw-r--r--man/emacs-xtra.texi3774
1 files changed, 24 insertions, 3750 deletions
diff --git a/man/emacs-xtra.texi b/man/emacs-xtra.texi
index 600748b7c88..65625522298 100644
--- a/man/emacs-xtra.texi
+++ b/man/emacs-xtra.texi
@@ -56,16 +56,18 @@ license to the document, as described in section 6 of the license.
56 56
57@menu 57@menu
58* Introduction:: What documentation belongs here? 58* Introduction:: What documentation belongs here?
59@iftex
60* Picture Mode:: Editing pictures made up of characters using
61 the quarter-plane screen model.
62
59* Autorevert:: Auto Reverting non-file buffers. 63* Autorevert:: Auto Reverting non-file buffers.
60* Subdir Switches:: Subdirectory switches in Dired. 64* Subdir Switches:: Subdirectory switches in Dired.
61* Advanced Calendar/Diary Usage:: Advanced Calendar/Diary customization. 65* Advanced Calendar/Diary Usage:: Advanced Calendar/Diary customization.
62* Emerge:: A convenient way of merging two versions of a program. 66* Emerge:: A convenient way of merging two versions of a program.
63* Picture Mode:: Editing pictures made up of characters using
64 the quarter-plane screen model.
65
66* Advanced VC Usage:: Advanced VC (version control) features. 67* Advanced VC Usage:: Advanced VC (version control) features.
67* Fortran:: Fortran mode and its special features. 68* Fortran:: Fortran mode and its special features.
68* MS-DOS:: Using Emacs on MS-DOS (otherwise known as "MS-DOG"). 69* MS-DOS:: Using Emacs on MS-DOS (otherwise known as @dfn{MS-DOG}).
70@end iftex
69* Index:: 71* Index::
70@end menu 72@end menu
71 73
@@ -73,3773 +75,45 @@ license to the document, as described in section 6 of the license.
73@unnumbered Introduction 75@unnumbered Introduction
74 76
75This manual contains detailed information about various features that 77This manual contains detailed information about various features that
76are too specialized to be included in the Emacs manual. It is 78are too specialized to be included in the printed Emacs manual. It is
77intended to be readable by anyone having a basic knowledge of Emacs. 79intended to be readable by anyone having a basic knowledge of Emacs.
78However, certain sections may be intended for a more specialized 80However, certain sections may be intended for a more specialized
79audience, such as Elisp authors. This should be clearly pointed out 81audience, such as Elisp authors. This should be clearly pointed out
80at the beginning of these sections. 82at the beginning of these sections.
81 83
82This manual is intended as a complement, rather than an alternative, 84Certain packages, or collections of related features, have their own
83to other ways to gain a more detailed knowledge of Emacs than the 85manuals, separate from the main Emacs User's manual. This manual is
84Emacs manual can provide, such as browsing packages using @kbd{C-h p}, 86intended as a complement, rather than an alternative, to reading those
85accessing mode documentation using @kbd{C-h m} and browsing user 87additional manuals; in a nutshell, it is a collection of smaller
86options using Custom. Also, certain packages, or collections of 88specialized features, too small or too obscure to justify their own
87related features, have their own manuals. The present manual is 89manual.
88mainly intended to be a collection of smaller specialized features,
89too small to get their own manual.
90 90
91Sections intended specifically for Elisp programmers can follow the 91Sections intended specifically for Elisp programmers can follow the
92style of the Elisp manual. Other sections should follow the style of 92style of the Elisp manual. Other sections should follow the style of
93the Emacs manual. 93the Emacs manual.
94 94
95@node Autorevert
96@chapter Auto Reverting non-file Buffers
97
98Normally Global Auto Revert Mode only reverts file buffers. There are
99two ways to auto-revert certain non-file buffers: enabling Auto Revert
100Mode in those buffers (using @kbd{M-x auto-revert-mode}) and setting
101@code{global-auto-revert-non-file-buffers} to @code{t}. The latter
102enables Auto Reverting for all types of buffers for which it is
103implemented, that is, for the types of buffers listed in the menu
104below.
105
106Like file buffers, non-file buffers should normally not revert while
107you are working on them, or while they contain information that might
108get lost after reverting. Therefore, they do not revert if they are
109``modified''. This can get tricky, because deciding when a non-file
110buffer should be marked modified is usually more difficult than for
111file buffers.
112
113Another tricky detail is that, for efficiency reasons, Auto Revert
114often does not try to detect all possible changes in the buffer, only
115changes that are ``major'' or easy to detect. Hence, enabling
116auto-reverting for a non-file buffer does not always guarantee that
117all information in the buffer is up to date and does not necessarily
118make manual reverts useless.
119
120At the other extreme, certain buffers automatically auto-revert every
121@code{auto-revert-interval} seconds. (This currently only applies to
122the Buffer Menu.) In this case, Auto Revert does not print any
123messages while reverting, even when @code{auto-revert-verbose} is
124non-@code{nil}.
125
126The details depend on the particular types of buffers and are
127explained in the corresponding sections.
128
129@menu
130* Auto Reverting the Buffer Menu::
131* Auto Reverting Dired::
132* Supporting additional buffers::
133@end menu
134
135@node Auto Reverting the Buffer Menu
136@section Auto Reverting the Buffer Menu
137
138If auto-reverting of non-file buffers is enabled, the Buffer Menu
139automatically reverts every @code{auto-revert-interval} seconds,
140whether there is a need for it or not. (It would probably take longer
141to check whether there is a need than to actually revert.)
142
143If the Buffer Menu inappropriately gets marked modified, just revert
144it manually using @kbd{g} and auto-reverting will resume. However, if
145you marked certain buffers to get deleted or to be displayed, you have
146to be careful, because reverting erases all marks. The fact that
147adding marks sets the buffer's modified flag prevents Auto Revert from
148automatically erasing the marks.
149
150@node Auto Reverting Dired
151@section Auto Reverting Dired buffers
152
153Auto-reverting Dired buffers currently works on GNU or Unix style
154operating systems. It may not work satisfactorily on some other
155systems.
156
157Dired buffers only auto-revert when the file list of the buffer's main
158directory changes. They do not auto-revert when information about a
159particular file changes or when inserted subdirectories change. To be
160sure that @emph{all} listed information is up to date, you have to
161manually revert using @kbd{g}, @emph{even} if auto-reverting is
162enabled in the Dired buffer. Sometimes, you might get the impression
163that modifying or saving files listed in the main directory actually
164does cause auto-reverting. This is because making changes to a file,
165or saving it, very often causes changes in the directory itself, for
166instance, through backup files or auto-save files. However, this is
167not guaranteed.
168
169If the Dired buffer is marked modified and there are no changes you
170want to protect, then most of the time you can make auto-reverting
171resume by manually reverting the buffer using @kbd{g}. There is one
172exception. If you flag or mark files, you can safely revert the
173buffer. This will not erase the flags or marks (unless the marked
174file has been deleted, of course). However, the buffer will stay
175modified, even after reverting, and auto-reverting will not resume.
176This is because, if you flag or mark files, you may be working on the
177buffer and you might not want the buffer to change without warning.
178If you want auto-reverting to resume in the presence of marks and
179flags, mark the buffer non-modified using @kbd{M-~}. However, adding,
180deleting or changing marks or flags will mark it modified again.
181
182Remote Dired buffers are not auto-reverted. Neither are Dired buffers
183for which you used shell wildcards or file arguments to list only some
184of the files. @samp{*Find*} and @samp{*Locate*} buffers do not
185auto-revert either.
186
187@node Supporting additional buffers
188@section Adding Support for Auto-Reverting additional Buffers.
189
190This section is intended for Elisp programmers who would like to add
191support for auto-reverting new types of buffers.
192
193To support auto-reverting the buffer must first of all have a
194@code{revert-buffer-function}. @xref{Definition of
195revert-buffer-function,, Reverting, elisp, the Emacs Lisp Reference Manual}.
196
197In addition, it @emph{must} have a @code{buffer-stale-function}.
198
199@defvar buffer-stale-function
200The value of this variable is a function to check whether a non-file
201buffer needs reverting. This should be a function with one optional
202argument @var{noconfirm}. The function should return non-@code{nil}
203if the buffer should be reverted. The buffer is current when this
204function is called.
205
206While this function is mainly intended for use in auto-reverting, it
207could be used for other purposes as well. For instance, if
208auto-reverting is not enabled, it could be used to warn the user that
209the buffer needs reverting. The idea behind the @var{noconfirm}
210argument is that it should be @code{t} if the buffer is going to be
211reverted without asking the user and @code{nil} if the function is
212just going to be used to warn the user that the buffer is out of date.
213In particular, for use in auto-reverting, @var{noconfirm} is @code{t}.
214If the function is only going to be used for auto-reverting, you can
215ignore the @var{noconfirm} argument.
216
217If you just want to automatically auto-revert every
218@code{auto-revert-interval} seconds, use:
219
220@example
221(set (make-local-variable 'buffer-stale-function)
222 #'(lambda (&optional noconfirm) 'fast))
223@end example
224
225@noindent
226in the buffer's mode function.
227
228The special return value @samp{fast} tells the caller that the need
229for reverting was not checked, but that reverting the buffer is fast.
230It also tells Auto Revert not to print any revert messages, even if
231@code{auto-revert-verbose} is non-@code{nil}. This is important, as
232getting revert messages every @code{auto-revert-interval} seconds can
233be very annoying. The information provided by this return value could
234also be useful if the function is consulted for purposes other than
235auto-reverting.
236@end defvar
237
238Once the buffer has a @code{revert-buffer-function} and a
239@code{buffer-stale-function}, several problems usually remain.
240
241The buffer will only auto-revert if it is marked unmodified. Hence,
242you will have to make sure that various functions mark the buffer
243modified if and only if either the buffer contains information that
244might be lost by reverting or there is reason to believe that the user
245might be inconvenienced by auto-reverting, because he is actively
246working on the buffer. The user can always override this by manually
247adjusting the modified status of the buffer. To support this, calling
248the @code{revert-buffer-function} on a buffer that is marked
249unmodified should always keep the buffer marked unmodified.
250
251It is important to assure that point does not continuously jump around
252as a consequence of auto-reverting. Of course, moving point might be
253inevitable if the buffer radically changes.
254
255You should make sure that the @code{revert-buffer-function} does not
256print messages that unnecessarily duplicate Auto Revert's own messages
257if @code{auto-revert-verbose} is @code{t} and effectively override a
258@code{nil} value for @code{auto-revert-verbose}. Hence, adapting a
259mode for auto-reverting often involves getting rid of such messages.
260This is especially important for buffers that automatically
261auto-revert every @code{auto-revert-interval} seconds.
262
263Also, you may want to update the documentation string of
264@code{global-auto-revert-non-file-buffers}.
265
266@ifinfo
267Finally, you should add a node to this chapter's menu. This node
268@end ifinfo
269@ifnotinfo
270Finally, you should add a section to this chapter. This section
271@end ifnotinfo
272should at the very least make clear whether enabling auto-reverting
273for the buffer reliably assures that all information in the buffer is
274completely up to date (or will be after @code{auto-revert-interval}
275seconds).
276
277@node Subdir Switches
278@chapter Subdirectory Switches in Dired
279
280You can insert subdirectories with specified @code{ls} switches in
281Dired buffers, using @kbd{C-u i}. You can change the @code{ls}
282switches of an already inserted subdirectory using @kbd{C-u l}.
283
284In Emacs versions 22.1 and later, Dired remembers the switches, so
285that reverting the buffer will not change them back to the main
286directory's switches. Deleting a subdirectory forgets about its
287switches.
288
289Using @code{dired-undo} (usually bound to @kbd{C-_} and @kbd{C-x u})
290to reinsert or delete subdirectories, that were inserted with explicit
291switches, can bypass Dired's machinery for remembering (or forgetting)
292switches. Deleting a subdirectory using @code{dired-undo} does not
293forget its switches. When later reinserted using @kbd{i}, it will be
294reinserted using its old switches. Using @code{dired-undo} to
295reinsert a subdirectory that was deleted using the regular
296Dired commands (not @code{dired-undo}) will originally insert it with
297its old switches. However, reverting the buffer will relist it using
298the buffer's default switches. If any of this yields problems, you
299can easily correct the situation using @kbd{C-u i} or @kbd{C-u l}.
300
301Dired does not remember the @code{R} switch. Inserting a subdirectory
302with switches that include the @code{R} switch is equivalent with
303inserting each of its subdirectories using all remaining switches.
304For instance, updating or killing a subdirectory that was inserted
305with the @code{R} switch will not update or kill its subdirectories.
306
307The buffer's default switches do not affect subdirectories that were
308inserted using explicitly specified switches. In particular,
309commands such as @kbd{s}, that change the buffer's switches do not
310affect such subdirectories. (They do affect subdirectories without
311explicitly assigned switches, however.)
312
313You can make Dired forget about all subdirectory switches and relist
314all subdirectories with the buffer's default switches using
315@kbd{M-x dired-reset-subdir-switches}. This also reverts the Dired buffer.
316
317
318@c Moved here from the Emacs Lisp Reference Manual, 2005-03-26.
319@node Advanced Calendar/Diary Usage
320@chapter Customizing the Calendar and Diary
321
322 There are many customizations that you can use to make the calendar and
323diary suit your personal tastes.
324
325@menu
326* Calendar Customizing:: Defaults you can set.
327* Holiday Customizing:: Defining your own holidays.
328* Date Display Format:: Changing the format.
329* Time Display Format:: Changing the format.
330* Daylight Savings:: Changing the default.
331* Diary Customizing:: Defaults you can set.
332* Hebrew/Islamic Entries:: How to obtain them.
333* Fancy Diary Display:: Enhancing the diary display, sorting entries,
334 using included diary files.
335* Sexp Diary Entries:: Fancy things you can do.
336@end menu
337
338@node Calendar Customizing
339@section Customizing the Calendar
340@vindex calendar-holiday-marker
341@vindex diary-entry-marker
342 The variable @code{calendar-holiday-marker} specifies how to mark a
343date as being a holiday. Its value may be a single-character string
344to insert next to the date, or a face name to use for displaying the
345date. Likewise, the variable @code{diary-entry-marker} specifies how
346to mark a date that has diary entries. The calendar creates faces
347named @code{holiday-face} and @code{diary-face} for these purposes;
348those symbols are the default values of these variables.
349
350@vindex calendar-load-hook
351 The variable @code{calendar-load-hook} is a normal hook run when the
352calendar package is first loaded (before actually starting to display
353the calendar).
354
355@vindex initial-calendar-window-hook
356 Starting the calendar runs the normal hook
357@code{initial-calendar-window-hook}. Recomputation of the calendar
358display does not run this hook. But if you leave the calendar with the
359@kbd{q} command and reenter it, the hook runs again.@refill
360
361@vindex today-visible-calendar-hook
362 The variable @code{today-visible-calendar-hook} is a normal hook run
363after the calendar buffer has been prepared with the calendar when the
364current date is visible in the window. One use of this hook is to
365replace today's date with asterisks; to do that, use the hook function
366@code{calendar-star-date}.
367
368@findex calendar-star-date
369@example
370(add-hook 'today-visible-calendar-hook 'calendar-star-date)
371@end example
372
373@noindent
374Another standard hook function marks the current date, either by
375changing its face or by adding an asterisk. Here's how to use it:
376
377@findex calendar-mark-today
378@example
379(add-hook 'today-visible-calendar-hook 'calendar-mark-today)
380@end example
381
382@noindent
383@vindex calendar-today-marker
384The variable @code{calendar-today-marker} specifies how to mark
385today's date. Its value should be a single-character string to insert
386next to the date or a face name to use for displaying the date. A
387face named @code{calendar-today-face} is provided for this purpose;
388that symbol is the default for this variable.
389
390@vindex today-invisible-calendar-hook
391@noindent
392 A similar normal hook, @code{today-invisible-calendar-hook} is run if
393the current date is @emph{not} visible in the window.
394
395@vindex calendar-move-hook
396 Each of the calendar cursor motion commands runs the hook
397@code{calendar-move-hook} after it moves the cursor.
398
399@node Holiday Customizing
400@section Customizing the Holidays
401
402@vindex calendar-holidays
403@vindex christian-holidays
404@vindex hebrew-holidays
405@vindex islamic-holidays
406 Emacs knows about holidays defined by entries on one of several lists.
407You can customize these lists of holidays to your own needs, adding or
408deleting holidays. The lists of holidays that Emacs uses are for
409general holidays (@code{general-holidays}), local holidays
410(@code{local-holidays}), Christian holidays (@code{christian-holidays}),
411Hebrew (Jewish) holidays (@code{hebrew-holidays}), Islamic (Muslim)
412holidays (@code{islamic-holidays}), and other holidays
413(@code{other-holidays}).
414
415@vindex general-holidays
416 The general holidays are, by default, holidays common throughout the
417United States. To eliminate these holidays, set @code{general-holidays}
418to @code{nil}.
419
420@vindex local-holidays
421 There are no default local holidays (but sites may supply some). You
422can set the variable @code{local-holidays} to any list of holidays, as
423described below.
424
425@vindex all-christian-calendar-holidays
426@vindex all-hebrew-calendar-holidays
427@vindex all-islamic-calendar-holidays
428 By default, Emacs does not include all the holidays of the religions
429that it knows, only those commonly found in secular calendars. For a
430more extensive collection of religious holidays, you can set any (or
431all) of the variables @code{all-christian-calendar-holidays},
432@code{all-hebrew-calendar-holidays}, or
433@code{all-islamic-calendar-holidays} to @code{t}. If you want to
434eliminate the religious holidays, set any or all of the corresponding
435variables @code{christian-holidays}, @code{hebrew-holidays}, and
436@code{islamic-holidays} to @code{nil}.@refill
437
438@vindex other-holidays
439 You can set the variable @code{other-holidays} to any list of
440holidays. This list, normally empty, is intended for individual use.
441
442@cindex holiday forms
443 Each of the lists (@code{general-holidays}, @code{local-holidays},
444@code{christian-holidays}, @code{hebrew-holidays},
445@code{islamic-holidays}, and @code{other-holidays}) is a list of
446@dfn{holiday forms}, each holiday form describing a holiday (or
447sometimes a list of holidays).
448
449 Here is a table of the possible kinds of holiday form. Day numbers
450and month numbers count starting from 1, but ``dayname'' numbers
451count Sunday as 0. The element @var{string} is always the
452name of the holiday, as a string.
453
454@table @code
455@item (holiday-fixed @var{month} @var{day} @var{string})
456A fixed date on the Gregorian calendar.
457
458@item (holiday-float @var{month} @var{dayname} @var{k} @var{string})
459The @var{k}th @var{dayname} in @var{month} on the Gregorian calendar
460(@var{dayname}=0 for Sunday, and so on); negative @var{k} means count back
461from the end of the month.
462
463@item (holiday-hebrew @var{month} @var{day} @var{string})
464A fixed date on the Hebrew calendar.
465
466@item (holiday-islamic @var{month} @var{day} @var{string})
467A fixed date on the Islamic calendar.
468
469@item (holiday-julian @var{month} @var{day} @var{string})
470A fixed date on the Julian calendar.
471
472@item (holiday-sexp @var{sexp} @var{string})
473A date calculated by the Lisp expression @var{sexp}. The expression
474should use the variable @code{year} to compute and return the date of a
475holiday, or @code{nil} if the holiday doesn't happen this year. The
476value of @var{sexp} must represent the date as a list of the form
477@code{(@var{month} @var{day} @var{year})}.
478
479@item (if @var{condition} @var{holiday-form})
480A holiday that happens only if @var{condition} is true.
481
482@item (@var{function} @r{[}@var{args}@r{]})
483A list of dates calculated by the function @var{function}, called with
484arguments @var{args}.
485@end table
486
487 For example, suppose you want to add Bastille Day, celebrated in
488France on July 14. You can do this as follows:
489
490@smallexample
491(setq other-holidays '((holiday-fixed 7 14 "Bastille Day")))
492@end smallexample
493
494@noindent
495The holiday form @code{(holiday-fixed 7 14 "Bastille Day")} specifies the
496fourteenth day of the seventh month (July).
497
498 Many holidays occur on a specific day of the week, at a specific time
499of month. Here is a holiday form describing Hurricane Supplication Day,
500celebrated in the Virgin Islands on the fourth Monday in August:
501
502@smallexample
503(holiday-float 8 1 4 "Hurricane Supplication Day")
504@end smallexample
505
506@noindent
507Here the 8 specifies August, the 1 specifies Monday (Sunday is 0,
508Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in
509the month (1 specifies the first occurrence, 2 the second occurrence,
510@minus{}1 the last occurrence, @minus{}2 the second-to-last occurrence, and
511so on).
512
513 You can specify holidays that occur on fixed days of the Hebrew,
514Islamic, and Julian calendars too. For example,
515
516@smallexample
517(setq other-holidays
518 '((holiday-hebrew 10 2 "Last day of Hanukkah")
519 (holiday-islamic 3 12 "Mohammed's Birthday")
520 (holiday-julian 4 2 "Jefferson's Birthday")))
521@end smallexample
522
523@noindent
524adds the last day of Hanukkah (since the Hebrew months are numbered with
5251 starting from Nisan), the Islamic feast celebrating Mohammed's
526birthday (since the Islamic months are numbered from 1 starting with
527Muharram), and Thomas Jefferson's birthday, which is 2 April 1743 on the
528Julian calendar.
529
530 To include a holiday conditionally, use either Emacs Lisp's @code{if} or the
531@code{holiday-sexp} form. For example, American presidential elections
532occur on the first Tuesday after the first Monday in November of years
533divisible by 4:
534
535@smallexample
536(holiday-sexp '(if (= 0 (% year 4))
537 (calendar-gregorian-from-absolute
538 (1+ (calendar-dayname-on-or-before
539 1 (+ 6 (calendar-absolute-from-gregorian
540 (list 11 1 year)))))))
541 "US Presidential Election")
542@end smallexample
543
544@noindent
545or
546
547@smallexample
548(if (= 0 (% displayed-year 4))
549 (fixed 11
550 (extract-calendar-day
551 (calendar-gregorian-from-absolute
552 (1+ (calendar-dayname-on-or-before
553 1 (+ 6 (calendar-absolute-from-gregorian
554 (list 11 1 displayed-year)))))))
555 "US Presidential Election"))
556@end smallexample
557
558 Some holidays just don't fit into any of these forms because special
559calculations are involved in their determination. In such cases you
560must write a Lisp function to do the calculation. To include eclipses,
561for example, add @code{(eclipses)} to @code{other-holidays}
562and write an Emacs Lisp function @code{eclipses} that returns a
563(possibly empty) list of the relevant Gregorian dates among the range
564visible in the calendar window, with descriptive strings, like this:
565
566@smallexample
567(((6 27 1991) "Lunar Eclipse") ((7 11 1991) "Solar Eclipse") ... )
568@end smallexample
569
570@node Date Display Format
571@section Date Display Format
572@vindex calendar-date-display-form
573
574 You can customize the manner of displaying dates in the diary, in mode
575lines, and in messages by setting @code{calendar-date-display-form}.
576This variable holds a list of expressions that can involve the variables
577@code{month}, @code{day}, and @code{year}, which are all numbers in
578string form, and @code{monthname} and @code{dayname}, which are both
579alphabetic strings. In the American style, the default value of this
580list is as follows:
581
582@smallexample
583((if dayname (concat dayname ", ")) monthname " " day ", " year)
584@end smallexample
585
586@noindent
587while in the European style this value is the default:
588
589@smallexample
590((if dayname (concat dayname ", ")) day " " monthname " " year)
591@end smallexample
592
593@noindent
594The ISO standard date representation is this:
595
596@smallexample
597(year "-" month "-" day)
598@end smallexample
599
600@noindent
601This specifies a typical American format:
602
603@smallexample
604(month "/" day "/" (substring year -2))
605@end smallexample
606
607@node Time Display Format
608@section Time Display Format
609@vindex calendar-time-display-form
610
611 The calendar and diary by default display times of day in the
612conventional American style with the hours from 1 through 12, minutes,
613and either @samp{am} or @samp{pm}. If you prefer the European style,
614also known in the US as military, in which the hours go from 00 to 23,
615you can alter the variable @code{calendar-time-display-form}. This
616variable is a list of expressions that can involve the variables
617@code{12-hours}, @code{24-hours}, and @code{minutes}, which are all
618numbers in string form, and @code{am-pm} and @code{time-zone}, which are
619both alphabetic strings. The default value of
620@code{calendar-time-display-form} is as follows:
621
622@smallexample
623(12-hours ":" minutes am-pm
624 (if time-zone " (") time-zone (if time-zone ")"))
625@end smallexample
626
627@noindent
628Here is a value that provides European style times:
629
630@smallexample
631(24-hours ":" minutes
632 (if time-zone " (") time-zone (if time-zone ")"))
633@end smallexample
634
635@node Daylight Savings
636@section Daylight Savings Time
637@cindex daylight savings time
638
639 Emacs understands the difference between standard time and daylight
640savings time---the times given for sunrise, sunset, solstices,
641equinoxes, and the phases of the moon take that into account. The rules
642for daylight savings time vary from place to place and have also varied
643historically from year to year. To do the job properly, Emacs needs to
644know which rules to use.
645
646 Some operating systems keep track of the rules that apply to the place
647where you are; on these systems, Emacs gets the information it needs
648from the system automatically. If some or all of this information is
649missing, Emacs fills in the gaps with the rules currently used in
650Cambridge, Massachusetts, which is the center of GNU's world.
651
652
653@vindex calendar-daylight-savings-starts
654@vindex calendar-daylight-savings-ends
655 If the default choice of rules is not appropriate for your location,
656you can tell Emacs the rules to use by setting the variables
657@code{calendar-daylight-savings-starts} and
658@code{calendar-daylight-savings-ends}. Their values should be Lisp
659expressions that refer to the variable @code{year}, and evaluate to the
660Gregorian date on which daylight savings time starts or (respectively)
661ends, in the form of a list @code{(@var{month} @var{day} @var{year})}.
662The values should be @code{nil} if your area does not use daylight
663savings time.
664
665 Emacs uses these expressions to determine the start and end dates of
666daylight savings time as holidays and for correcting times of day in the
667solar and lunar calculations.
668
669 The values for Cambridge, Massachusetts are as follows:
670
671@example
672@group
673(calendar-nth-named-day 1 0 4 year)
674(calendar-nth-named-day -1 0 10 year)
675@end group
676@end example
677
678@noindent
679i.e., the first 0th day (Sunday) of the fourth month (April) in
680the year specified by @code{year}, and the last Sunday of the tenth month
681(October) of that year. If daylight savings time were
682changed to start on October 1, you would set
683@code{calendar-daylight-savings-starts} to this:
684
685@example
686(list 10 1 year)
687@end example
688
689 For a more complex example, suppose daylight savings time begins on
690the first of Nisan on the Hebrew calendar. You should set
691@code{calendar-daylight-savings-starts} to this value:
692
693@example
694(calendar-gregorian-from-absolute
695 (calendar-absolute-from-hebrew
696 (list 1 1 (+ year 3760))))
697@end example
698
699@noindent
700because Nisan is the first month in the Hebrew calendar and the Hebrew
701year differs from the Gregorian year by 3760 at Nisan.
702
703 If there is no daylight savings time at your location, or if you want
704all times in standard time, set @code{calendar-daylight-savings-starts}
705and @code{calendar-daylight-savings-ends} to @code{nil}.
706
707@vindex calendar-daylight-time-offset
708 The variable @code{calendar-daylight-time-offset} specifies the
709difference between daylight savings time and standard time, measured in
710minutes. The value for Cambridge is 60.
711
712@vindex calendar-daylight-savings-starts-time
713@vindex calendar-daylight-savings-ends-time
714 The variable @code{calendar-daylight-savings-starts-time} and the
715variable @code{calendar-daylight-savings-ends-time} specify the number
716of minutes after midnight local time when the transition to and from
717daylight savings time should occur. For Cambridge, both variables'
718values are 120.
719
720@node Diary Customizing
721@section Customizing the Diary
722
723@vindex holidays-in-diary-buffer
724 Ordinarily, the mode line of the diary buffer window indicates any
725holidays that fall on the date of the diary entries. The process of
726checking for holidays can take several seconds, so including holiday
727information delays the display of the diary buffer noticeably. If you'd
728prefer to have a faster display of the diary buffer but without the
729holiday information, set the variable @code{holidays-in-diary-buffer} to
730@code{nil}.@refill
731
732@vindex number-of-diary-entries
733 The variable @code{number-of-diary-entries} controls the number of
734days of diary entries to be displayed at one time. It affects the
735initial display when @code{view-diary-entries-initially} is @code{t}, as
736well as the command @kbd{M-x diary}. For example, the default value is
7371, which says to display only the current day's diary entries. If the
738value is 2, both the current day's and the next day's entries are
739displayed. The value can also be a vector of seven elements: for
740example, if the value is @code{[0 2 2 2 2 4 1]} then no diary entries
741appear on Sunday, the current date's and the next day's diary entries
742appear Monday through Thursday, Friday through Monday's entries appear
743on Friday, while on Saturday only that day's entries appear.
744
745@vindex print-diary-entries-hook
746@findex print-diary-entries
747 The variable @code{print-diary-entries-hook} is a normal hook run
748after preparation of a temporary buffer containing just the diary
749entries currently visible in the diary buffer. (The other, irrelevant
750diary entries are really absent from the temporary buffer; in the diary
751buffer, they are merely hidden.) The default value of this hook does
752the printing with the command @code{lpr-buffer}. If you want to use a
753different command to do the printing, just change the value of this
754hook. Other uses might include, for example, rearranging the lines into
755order by day and time.
756
757@vindex diary-date-forms
758 You can customize the form of dates in your diary file, if neither the
759standard American nor European styles suits your needs, by setting the
760variable @code{diary-date-forms}. This variable is a list of patterns
761for recognizing a date. Each date pattern is a list whose elements may
762be regular expressions (@pxref{Regular Expressions,,, elisp, the Emacs
763Lisp Reference Manual}) or the symbols @code{month}, @code{day},
764@code{year}, @code{monthname}, and @code{dayname}. All these elements
765serve as patterns that match certain kinds of text in the diary file.
766In order for the date pattern, as a whole, to match, all of its elements
767must match consecutively.
768
769 A regular expression in a date pattern matches in its usual fashion,
770using the standard syntax table altered so that @samp{*} is a word
771constituent.
772
773 The symbols @code{month}, @code{day}, @code{year}, @code{monthname},
774and @code{dayname} match the month number, day number, year number,
775month name, and day name of the date being considered. The symbols that
776match numbers allow leading zeros; those that match names allow
777three-letter abbreviations and capitalization. All the symbols can
778match @samp{*}; since @samp{*} in a diary entry means ``any day'', ``any
779month'', and so on, it should match regardless of the date being
780considered.
781
782 The default value of @code{diary-date-forms} in the American style is
783this:
784
785@example
786((month "/" day "[^/0-9]")
787 (month "/" day "/" year "[^0-9]")
788 (monthname " *" day "[^,0-9]")
789 (monthname " *" day ", *" year "[^0-9]")
790 (dayname "\\W"))
791@end example
792
793 The date patterns in the list must be @emph{mutually exclusive} and
794must not match any portion of the diary entry itself, just the date and
795one character of whitespace. If, to be mutually exclusive, the pattern
796must match a portion of the diary entry text---beyond the whitespace
797that ends the date---then the first element of the date pattern
798@emph{must} be @code{backup}. This causes the date recognizer to back
799up to the beginning of the current word of the diary entry, after
800finishing the match. Even if you use @code{backup}, the date pattern
801must absolutely not match more than a portion of the first word of the
802diary entry. The default value of @code{diary-date-forms} in the
803European style is this list:
804
805@example
806((day "/" month "[^/0-9]")
807 (day "/" month "/" year "[^0-9]")
808 (backup day " *" monthname "\\W+\\<[^*0-9]")
809 (day " *" monthname " *" year "[^0-9]")
810 (dayname "\\W"))
811@end example
812
813@noindent
814Notice the use of @code{backup} in the third pattern, because it needs
815to match part of a word beyond the date itself to distinguish it from
816the fourth pattern.
817
818@node Hebrew/Islamic Entries
819@section Hebrew- and Islamic-Date Diary Entries
820
821 Your diary file can have entries based on Hebrew or Islamic dates, as
822well as entries based on the world-standard Gregorian calendar.
823However, because recognition of such entries is time-consuming and most
824people don't use them, you must explicitly enable their use. If you
825want the diary to recognize Hebrew-date diary entries, for example,
826you must do this:
827
828@vindex nongregorian-diary-listing-hook
829@vindex nongregorian-diary-marking-hook
830@findex list-hebrew-diary-entries
831@findex mark-hebrew-diary-entries
832@smallexample
833(add-hook 'nongregorian-diary-listing-hook 'list-hebrew-diary-entries)
834(add-hook 'nongregorian-diary-marking-hook 'mark-hebrew-diary-entries)
835@end smallexample
836
837@noindent
838If you want Islamic-date entries, do this:
839
840@findex list-islamic-diary-entries
841@findex mark-islamic-diary-entries
842@smallexample
843(add-hook 'nongregorian-diary-listing-hook 'list-islamic-diary-entries)
844(add-hook 'nongregorian-diary-marking-hook 'mark-islamic-diary-entries)
845@end smallexample
846
847 Hebrew- and Islamic-date diary entries have the same formats as
848Gregorian-date diary entries, except that @samp{H} precedes a Hebrew
849date and @samp{I} precedes an Islamic date. Moreover, because the
850Hebrew and Islamic month names are not uniquely specified by the first
851three letters, you may not abbreviate them. For example, a diary entry
852for the Hebrew date Heshvan 25 could look like this:
853
854@smallexample
855HHeshvan 25 Happy Hebrew birthday!
856@end smallexample
857
858@noindent
859and would appear in the diary for any date that corresponds to Heshvan 25
860on the Hebrew calendar. And here is an Islamic-date diary entry that matches
861Dhu al-Qada 25:
862
863@smallexample
864IDhu al-Qada 25 Happy Islamic birthday!
865@end smallexample
866
867 As with Gregorian-date diary entries, Hebrew- and Islamic-date entries
868are nonmarking if they are preceded with an ampersand (@samp{&}).
869
870 Here is a table of commands used in the calendar to create diary entries
871that match the selected date and other dates that are similar in the Hebrew
872or Islamic calendar:
873
874@table @kbd
875@item i h d
876Add a diary entry for the Hebrew date corresponding to the selected date
877(@code{insert-hebrew-diary-entry}).
878@item i h m
879Add a diary entry for the day of the Hebrew month corresponding to the
880selected date (@code{insert-monthly-hebrew-diary-entry}). This diary
881entry matches any date that has the same Hebrew day-within-month as the
882selected date.
883@item i h y
884Add a diary entry for the day of the Hebrew year corresponding to the
885selected date (@code{insert-yearly-hebrew-diary-entry}). This diary
886entry matches any date which has the same Hebrew month and day-within-month
887as the selected date.
888@item i i d
889Add a diary entry for the Islamic date corresponding to the selected date
890(@code{insert-islamic-diary-entry}).
891@item i i m
892Add a diary entry for the day of the Islamic month corresponding to the
893selected date (@code{insert-monthly-islamic-diary-entry}).
894@item i i y
895Add a diary entry for the day of the Islamic year corresponding to the
896selected date (@code{insert-yearly-islamic-diary-entry}).
897@end table
898
899@findex insert-hebrew-diary-entry
900@findex insert-monthly-hebrew-diary-entry
901@findex insert-yearly-hebrew-diary-entry
902@findex insert-islamic-diary-entry
903@findex insert-monthly-islamic-diary-entry
904@findex insert-yearly-islamic-diary-entry
905 These commands work much like the corresponding commands for ordinary
906diary entries: they apply to the date that point is on in the calendar
907window, and what they do is insert just the date portion of a diary entry
908at the end of your diary file. You must then insert the rest of the
909diary entry.
910
911@node Fancy Diary Display
912@section Fancy Diary Display
913@vindex diary-display-hook
914@findex simple-diary-display
915
916 Diary display works by preparing the diary buffer and then running the
917hook @code{diary-display-hook}. The default value of this hook
918(@code{simple-diary-display}) hides the irrelevant diary entries and
919then displays the buffer. However, if you specify the hook as follows,
920
921@cindex diary buffer
922@findex fancy-diary-display
923@example
924(add-hook 'diary-display-hook 'fancy-diary-display)
925@end example
926
927@noindent
928this enables fancy diary display. It displays diary entries and
929holidays by copying them into a special buffer that exists only for the
930sake of display. Copying to a separate buffer provides an opportunity
931to change the displayed text to make it prettier---for example, to sort
932the entries by the dates they apply to.
933
934 As with simple diary display, you can print a hard copy of the buffer
935with @code{print-diary-entries}. To print a hard copy of a day-by-day
936diary for a week, position point on Sunday of that week, type
937@kbd{7 d}, and then do @kbd{M-x print-diary-entries}. As usual, the
938inclusion of the holidays slows down the display slightly; you can speed
939things up by setting the variable @code{holidays-in-diary-buffer} to
940@code{nil}.
941
942@vindex diary-list-include-blanks
943 Ordinarily, the fancy diary buffer does not show days for which there are
944no diary entries, even if that day is a holiday. If you want such days to be
945shown in the fancy diary buffer, set the variable
946@code{diary-list-include-blanks} to @code{t}.@refill
947
948@cindex sorting diary entries
949 If you use the fancy diary display, you can use the normal hook
950@code{list-diary-entries-hook} to sort each day's diary entries by their
951time of day. Here's how:
952
953@findex sort-diary-entries
954@example
955(add-hook 'list-diary-entries-hook 'sort-diary-entries t)
956@end example
957
958@noindent
959For each day, this sorts diary entries that begin with a recognizable
960time of day according to their times. Diary entries without times come
961first within each day.
962
963 Fancy diary display also has the ability to process included diary
964files. This permits a group of people to share a diary file for events
965that apply to all of them. Lines in the diary file of this form:
966
967@smallexample
968#include "@var{filename}"
969@end smallexample
970
971@noindent
972includes the diary entries from the file @var{filename} in the fancy
973diary buffer. The include mechanism is recursive, so that included files
974can include other files, and so on; you must be careful not to have a
975cycle of inclusions, of course. Here is how to enable the include
976facility:
977
978@vindex list-diary-entries-hook
979@vindex mark-diary-entries-hook
980@findex include-other-diary-files
981@findex mark-included-diary-files
982@smallexample
983(add-hook 'list-diary-entries-hook 'include-other-diary-files)
984(add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
985@end smallexample
986
987The include mechanism works only with the fancy diary display, because
988ordinary diary display shows the entries directly from your diary file.
989
990@node Sexp Diary Entries
991@section Sexp Entries and the Fancy Diary Display
992@cindex sexp diary entries
993
994 Sexp diary entries allow you to do more than just have complicated
995conditions under which a diary entry applies. If you use the fancy
996diary display, sexp entries can generate the text of the entry depending
997on the date itself. For example, an anniversary diary entry can insert
998the number of years since the anniversary date into the text of the
999diary entry. Thus the @samp{%d} in this dairy entry:
1000
1001@findex diary-anniversary
1002@smallexample
1003%%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)
1004@end smallexample
1005
1006@noindent
1007gets replaced by the age, so on October 31, 1990 the entry appears in
1008the fancy diary buffer like this:
1009
1010@smallexample
1011Arthur's birthday (42 years old)
1012@end smallexample
1013
1014@noindent
1015If the diary file instead contains this entry:
1016
1017@smallexample
1018%%(diary-anniversary 10 31 1948) Arthur's %d%s birthday
1019@end smallexample
1020
1021@noindent
1022the entry in the fancy diary buffer for October 31, 1990 appears like this:
1023
1024@smallexample
1025Arthur's 42nd birthday
1026@end smallexample
1027
1028 Similarly, cyclic diary entries can interpolate the number of repetitions
1029that have occurred:
1030
1031@findex diary-cyclic
1032@smallexample
1033%%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time)
1034@end smallexample
1035
1036@noindent
1037looks like this:
1038
1039@smallexample
1040Renew medication (5th time)
1041@end smallexample
1042
1043@noindent
1044in the fancy diary display on September 8, 1990.
1045
1046 There is an early reminder diary sexp that includes its entry in the
1047diary not only on the date of occurrence, but also on earlier dates.
1048For example, if you want a reminder a week before your anniversary, you
1049can use
1050
1051@findex diary-remind
1052@smallexample
1053%%(diary-remind '(diary-anniversary 12 22 1968) 7) Ed's anniversary
1054@end smallexample
1055
1056@noindent
1057and the fancy diary will show
1058@smallexample
1059Ed's anniversary
1060@end smallexample
1061@noindent
1062both on December 15 and on December 22.
1063
1064@findex diary-date
1065 The function @code{diary-date} applies to dates described by a month,
1066day, year combination, each of which can be an integer, a list of
1067integers, or @code{t}. The value @code{t} means all values. For
1068example,
1069
1070@smallexample
1071%%(diary-date '(10 11 12) 22 t) Rake leaves
1072@end smallexample
1073
1074@noindent
1075causes the fancy diary to show
1076
1077@smallexample
1078Rake leaves
1079@end smallexample
1080
1081@noindent
1082on October 22, November 22, and December 22 of every year.
1083
1084@findex diary-float
1085 The function @code{diary-float} allows you to describe diary entries
1086that apply to dates like the third Friday of November, or the last
1087Tuesday in April. The parameters are the @var{month}, @var{dayname},
1088and an index @var{n}. The entry appears on the @var{n}th @var{dayname}
1089of @var{month}, where @var{dayname}=0 means Sunday, 1 means Monday, and
1090so on. If @var{n} is negative it counts backward from the end of
1091@var{month}. The value of @var{month} can be a list of months, a single
1092month, or @code{t} to specify all months. You can also use an optional
1093parameter @var{day} to specify the @var{n}th @var{dayname} of
1094@var{month} on or after/before @var{day}; the value of @var{day} defaults
1095to 1 if @var{n} is positive and to the last day of @var{month} if
1096@var{n} is negative. For example,
1097
1098@smallexample
1099%%(diary-float t 1 -1) Pay rent
1100@end smallexample
1101
1102@noindent
1103causes the fancy diary to show
1104
1105@smallexample
1106Pay rent
1107@end smallexample
1108
1109@noindent
1110on the last Monday of every month.
1111
1112 The generality of sexp diary entries lets you specify any diary
1113entry that you can describe algorithmically. A sexp diary entry
1114contains an expression that computes whether the entry applies to any
1115given date. If its value is non-@code{nil}, the entry applies to that
1116date; otherwise, it does not. The expression can use the variable
1117@code{date} to find the date being considered; its value is a list
1118(@var{month} @var{day} @var{year}) that refers to the Gregorian
1119calendar.
1120
1121 The sexp diary entry applies to a date when the expression's value
1122is non-@code{nil}, but some values have more specific meanings. If
1123the value is a string, that string is a description of the event which
1124occurs on that date. The value can also have the form
1125@code{(@var{mark} . @var{string})}; then @var{mark} specifies how to
1126mark the date in the calendar, and @var{string} is the description of
1127the event. If @var{mark} is a single-character string, that character
1128appears next to the date in the calendar. If @var{mark} is a face
1129name, the date is displayed in that face. If @var{mark} is
1130@code{nil}, that specifies no particular highlighting for the date.
1131
1132 Suppose you get paid on the 21st of the month if it is a weekday, and
1133on the Friday before if the 21st is on a weekend. Here is how to write
1134a sexp diary entry that matches those dates:
1135
1136@smallexample
1137&%%(let ((dayname (calendar-day-of-week date))
1138 (day (car (cdr date))))
1139 (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
1140 (and (memq day '(19 20)) (= dayname 5)))
1141 ) Pay check deposited
1142@end smallexample
1143
1144 The following sexp diary entries take advantage of the ability (in the fancy
1145diary display) to concoct diary entries whose text varies based on the date:
1146
1147@findex diary-sunrise-sunset
1148@findex diary-phases-of-moon
1149@findex diary-day-of-year
1150@findex diary-iso-date
1151@findex diary-julian-date
1152@findex diary-astro-day-number
1153@findex diary-hebrew-date
1154@findex diary-islamic-date
1155@findex diary-french-date
1156@findex diary-mayan-date
1157@table @code
1158@item %%(diary-sunrise-sunset)
1159Make a diary entry for the local times of today's sunrise and sunset.
1160@item %%(diary-phases-of-moon)
1161Make a diary entry for the phases (quarters) of the moon.
1162@item %%(diary-day-of-year)
1163Make a diary entry with today's day number in the current year and the number
1164of days remaining in the current year.
1165@item %%(diary-iso-date)
1166Make a diary entry with today's equivalent ISO commercial date.
1167@item %%(diary-julian-date)
1168Make a diary entry with today's equivalent date on the Julian calendar.
1169@item %%(diary-astro-day-number)
1170Make a diary entry with today's equivalent astronomical (Julian) day number.
1171@item %%(diary-hebrew-date)
1172Make a diary entry with today's equivalent date on the Hebrew calendar.
1173@item %%(diary-islamic-date)
1174Make a diary entry with today's equivalent date on the Islamic calendar.
1175@item %%(diary-french-date)
1176Make a diary entry with today's equivalent date on the French Revolutionary
1177calendar.
1178@item %%(diary-mayan-date)
1179Make a diary entry with today's equivalent date on the Mayan calendar.
1180@end table
1181
1182@noindent
1183Thus including the diary entry
1184
1185@example
1186&%%(diary-hebrew-date)
1187@end example
1188
1189@noindent
1190causes every day's diary display to contain the equivalent date on the
1191Hebrew calendar, if you are using the fancy diary display. (With simple
1192diary display, the line @samp{&%%(diary-hebrew-date)} appears in the
1193diary for any date, but does nothing particularly useful.)
1194
1195 These functions can be used to construct sexp diary entries based on
1196the Hebrew calendar in certain standard ways:
1197
1198@cindex rosh hodesh
1199@findex diary-rosh-hodesh
1200@cindex parasha, weekly
1201@findex diary-parasha
1202@cindex candle lighting times
1203@findex diary-sabbath-candles
1204@cindex omer count
1205@findex diary-omer
1206@cindex yahrzeits
1207@findex diary-yahrzeit
1208@table @code
1209@item %%(diary-rosh-hodesh)
1210Make a diary entry that tells the occurrence and ritual announcement of each
1211new Hebrew month.
1212@item %%(diary-parasha)
1213Make a Saturday diary entry that tells the weekly synagogue scripture reading.
1214@item %%(diary-sabbath-candles)
1215Make a Friday diary entry that tells the @emph{local time} of Sabbath
1216candle lighting.
1217@item %%(diary-omer)
1218Make a diary entry that gives the omer count, when appropriate.
1219@item %%(diary-yahrzeit @var{month} @var{day} @var{year}) @var{name}
1220Make a diary entry marking the anniversary of a date of death. The date
1221is the @emph{Gregorian} (civil) date of death. The diary entry appears
1222on the proper Hebrew calendar anniversary and on the day before. (In
1223the European style, the order of the parameters is changed to @var{day},
1224@var{month}, @var{year}.)
1225@end table
1226
1227 All the functions documented above take an optional argument
1228@var{mark} which specifies how to mark the date in the calendar display.
1229If one of these functions decides that it applies to a certain date,
1230it returns a value that contains @var{mark}.
1231
1232@node Emerge
1233@chapter Merging Files with Emerge
1234@cindex Emerge
1235@cindex merging files
1236
1237 It's not unusual for programmers to get their signals crossed and
1238modify the same program in two different directions. To recover from
1239this confusion, you need to merge the two versions. Emerge makes this
1240easier. For other ways to compare files, see @ref{Comparing Files,,,
1241emacs, the Emacs Manual} and @ref{Top, Ediff,, ediff, The Ediff
1242Manual}.
1243
1244@menu
1245* Overview of Emerge:: How to start Emerge. Basic concepts.
1246* Submodes of Emerge:: Fast mode vs. Edit mode.
1247 Skip Prefers mode and Auto Advance mode.
1248* State of Difference:: You do the merge by specifying state A or B
1249 for each difference.
1250* Merge Commands:: Commands for selecting a difference,
1251 changing states of differences, etc.
1252* Exiting Emerge:: What to do when you've finished the merge.
1253* Combining in Emerge:: How to keep both alternatives for a difference.
1254* Fine Points of Emerge:: Misc.
1255@end menu
1256
1257@node Overview of Emerge
1258@section Overview of Emerge
1259
1260 To start Emerge, run one of these four commands:
1261
1262@table @kbd
1263@item M-x emerge-files
1264@findex emerge-files
1265Merge two specified files.
1266
1267@item M-x emerge-files-with-ancestor
1268@findex emerge-files-with-ancestor
1269Merge two specified files, with reference to a common ancestor.
1270
1271@item M-x emerge-buffers
1272@findex emerge-buffers
1273Merge two buffers.
1274
1275@item M-x emerge-buffers-with-ancestor
1276@findex emerge-buffers-with-ancestor
1277Merge two buffers with reference to a common ancestor in a third
1278buffer.
1279@end table
1280
1281@cindex merge buffer (Emerge)
1282@cindex A and B buffers (Emerge)
1283 The Emerge commands compare two files or buffers, and display the
1284comparison in three buffers: one for each input text (the @dfn{A buffer}
1285and the @dfn{B buffer}), and one (the @dfn{merge buffer}) where merging
1286takes place. The merge buffer shows the full merged text, not just the
1287differences. Wherever the two input texts differ, you can choose which
1288one of them to include in the merge buffer.
1289
1290 The Emerge commands that take input from existing buffers use only
1291the accessible portions of those buffers, if they are narrowed.
1292@xref{Narrowing,,, emacs, the Emacs Manual}.
1293
1294
1295 If a common ancestor version is available, from which the two texts to
1296be merged were both derived, Emerge can use it to guess which
1297alternative is right. Wherever one current version agrees with the
1298ancestor, Emerge presumes that the other current version is a deliberate
1299change which should be kept in the merged version. Use the
1300@samp{with-ancestor} commands if you want to specify a common ancestor
1301text. These commands read three file or buffer names---variant A,
1302variant B, and the common ancestor.
1303
1304 After the comparison is done and the buffers are prepared, the
1305interactive merging starts. You control the merging by typing special
1306@dfn{merge commands} in the merge buffer (@pxref{Merge Commands}).
1307For each run of differences between the input texts, you can choose
1308which one of them to keep, or edit them both together.
1309
1310 The merge buffer uses a special major mode, Emerge mode, with commands
1311for making these choices. But you can also edit the buffer with
1312ordinary Emacs commands.
1313
1314 At any given time, the attention of Emerge is focused on one
1315particular difference, called the @dfn{selected} difference. This
1316difference is marked off in the three buffers like this:
1317
1318@example
1319vvvvvvvvvvvvvvvvvvvv
1320@var{text that differs}
1321^^^^^^^^^^^^^^^^^^^^
1322@end example
1323
1324@noindent
1325Emerge numbers all the differences sequentially and the mode
1326line always shows the number of the selected difference.
1327
1328 Normally, the merge buffer starts out with the A version of the text.
1329But when the A version of a difference agrees with the common ancestor,
1330then the B version is initially preferred for that difference.
1331
1332 Emerge leaves the merged text in the merge buffer when you exit. At
1333that point, you can save it in a file with @kbd{C-x C-w}. If you give a
1334numeric argument to @code{emerge-files} or
1335@code{emerge-files-with-ancestor}, it reads the name of the output file
1336using the minibuffer. (This is the last file name those commands read.)
1337Then exiting from Emerge saves the merged text in the output file.
1338
1339 Normally, Emerge commands save the output buffer in its file when you
1340exit. If you abort Emerge with @kbd{C-]}, the Emerge command does not
1341save the output buffer, but you can save it yourself if you wish.
1342
1343@node Submodes of Emerge
1344@section Submodes of Emerge
1345
1346 You can choose between two modes for giving merge commands: Fast mode
1347and Edit mode. In Fast mode, basic merge commands are single
1348characters, but ordinary Emacs commands are disabled. This is
1349convenient if you use only merge commands. In Edit mode, all merge
1350commands start with the prefix key @kbd{C-c C-c}, and the normal Emacs
1351commands are also available. This allows editing the merge buffer, but
1352slows down Emerge operations.
1353
1354 Use @kbd{e} to switch to Edit mode, and @kbd{C-c C-c f} to switch to
1355Fast mode. The mode line indicates Edit and Fast modes with @samp{E}
1356and @samp{F}.
1357
1358 Emerge has two additional submodes that affect how particular merge
1359commands work: Auto Advance mode and Skip Prefers mode.
1360
1361 If Auto Advance mode is in effect, the @kbd{a} and @kbd{b} commands
1362advance to the next difference. This lets you go through the merge
1363faster as long as you simply choose one of the alternatives from the
1364input. The mode line indicates Auto Advance mode with @samp{A}.
1365
1366 If Skip Prefers mode is in effect, the @kbd{n} and @kbd{p} commands
1367skip over differences in states prefer-A and prefer-B (@pxref{State of
1368Difference}). Thus you see only differences for which neither version
1369is presumed ``correct.'' The mode line indicates Skip Prefers mode with
1370@samp{S}.
1371
1372@findex emerge-auto-advance-mode
1373@findex emerge-skip-prefers-mode
1374 Use the command @kbd{s a} (@code{emerge-auto-advance-mode}) to set or
1375clear Auto Advance mode. Use @kbd{s s}
1376(@code{emerge-skip-prefers-mode}) to set or clear Skip Prefers mode.
1377These commands turn on the mode with a positive argument, turns it off
1378with a negative or zero argument, and toggle the mode with no argument.
1379
1380@node State of Difference
1381@section State of a Difference
1382
1383 In the merge buffer, a difference is marked with lines of @samp{v} and
1384@samp{^} characters. Each difference has one of these seven states:
1385
1386@table @asis
1387@item A
1388The difference is showing the A version. The @kbd{a} command always
1389produces this state; the mode line indicates it with @samp{A}.
1390
1391@item B
1392The difference is showing the B version. The @kbd{b} command always
1393produces this state; the mode line indicates it with @samp{B}.
1394
1395@item default-A
1396@itemx default-B
1397The difference is showing the A or the B state by default, because you
1398haven't made a choice. All differences start in the default-A state
1399(and thus the merge buffer is a copy of the A buffer), except those for
1400which one alternative is ``preferred'' (see below).
1401
1402When you select a difference, its state changes from default-A or
1403default-B to plain A or B. Thus, the selected difference never has
1404state default-A or default-B, and these states are never displayed in
1405the mode line.
1406
1407The command @kbd{d a} chooses default-A as the default state, and @kbd{d
1408b} chooses default-B. This chosen default applies to all differences
1409which you haven't ever selected and for which no alternative is preferred.
1410If you are moving through the merge sequentially, the differences you
1411haven't selected are those following the selected one. Thus, while
1412moving sequentially, you can effectively make the A version the default
1413for some sections of the merge buffer and the B version the default for
1414others by using @kbd{d a} and @kbd{d b} between sections.
1415
1416@item prefer-A
1417@itemx prefer-B
1418The difference is showing the A or B state because it is
1419@dfn{preferred}. This means that you haven't made an explicit choice,
1420but one alternative seems likely to be right because the other
1421alternative agrees with the common ancestor. Thus, where the A buffer
1422agrees with the common ancestor, the B version is preferred, because
1423chances are it is the one that was actually changed.
1424
1425These two states are displayed in the mode line as @samp{A*} and @samp{B*}.
1426
1427@item combined
1428The difference is showing a combination of the A and B states, as a
1429result of the @kbd{x c} or @kbd{x C} commands.
1430
1431Once a difference is in this state, the @kbd{a} and @kbd{b} commands
1432don't do anything to it unless you give them a numeric argument.
1433
1434The mode line displays this state as @samp{comb}.
1435@end table
1436
1437@node Merge Commands
1438@section Merge Commands
1439
1440 Here are the Merge commands for Fast mode; in Edit mode, precede them
1441with @kbd{C-c C-c}:
1442
1443@table @kbd
1444@item p
1445Select the previous difference.
1446
1447@item n
1448Select the next difference.
1449
1450@item a
1451Choose the A version of this difference.
1452
1453@item b
1454Choose the B version of this difference.
1455
1456@item C-u @var{n} j
1457Select difference number @var{n}.
1458
1459@item .
1460Select the difference containing point. You can use this command in the
1461merge buffer or in the A or B buffer.
1462
1463@item q
1464Quit---finish the merge.
1465
1466@item C-]
1467Abort---exit merging and do not save the output.
1468
1469@item f
1470Go into Fast mode. (In Edit mode, this is actually @kbd{C-c C-c f}.)
1471
1472@item e
1473Go into Edit mode.
1474
1475@item l
1476Recenter (like @kbd{C-l}) all three windows.
1477
1478@item -
1479Specify part of a prefix numeric argument.
1480
1481@item @var{digit}
1482Also specify part of a prefix numeric argument.
1483
1484@item d a
1485Choose the A version as the default from here down in
1486the merge buffer.
1487
1488@item d b
1489Choose the B version as the default from here down in
1490the merge buffer.
1491
1492@item c a
1493Copy the A version of this difference into the kill ring.
1494
1495@item c b
1496Copy the B version of this difference into the kill ring.
1497
1498@item i a
1499Insert the A version of this difference at point.
1500
1501@item i b
1502Insert the B version of this difference at point.
1503
1504@item m
1505Put point and mark around the difference.
1506
1507@item ^
1508Scroll all three windows down (like @kbd{M-v}).
1509
1510@item v
1511Scroll all three windows up (like @kbd{C-v}).
1512
1513@item <
1514Scroll all three windows left (like @kbd{C-x <}).
1515
1516@item >
1517Scroll all three windows right (like @kbd{C-x >}).
1518
1519@item |
1520Reset horizontal scroll on all three windows.
1521
1522@item x 1
1523Shrink the merge window to one line. (Use @kbd{C-u l} to restore it
1524to full size.)
1525
1526@item x c
1527Combine the two versions of this difference (@pxref{Combining in
1528Emerge}).
1529
1530@item x f
1531Show the names of the files/buffers Emerge is operating on, in a Help
1532window. (Use @kbd{C-u l} to restore windows.)
1533
1534@item x j
1535Join this difference with the following one.
1536(@kbd{C-u x j} joins this difference with the previous one.)
1537
1538@item x s
1539Split this difference into two differences. Before you use this
1540command, position point in each of the three buffers at the place where
1541you want to split the difference.
1542
1543@item x t
1544Trim identical lines off the top and bottom of the difference.
1545Such lines occur when the A and B versions are
1546identical but differ from the ancestor version.
1547@end table
1548
1549@node Exiting Emerge
1550@section Exiting Emerge
1551
1552 The @kbd{q} command (@code{emerge-quit}) finishes the merge, storing
1553the results into the output file if you specified one. It restores the
1554A and B buffers to their proper contents, or kills them if they were
1555created by Emerge and you haven't changed them. It also disables the
1556Emerge commands in the merge buffer, since executing them later could
1557damage the contents of the various buffers.
1558
1559 @kbd{C-]} aborts the merge. This means exiting without writing the
1560output file. If you didn't specify an output file, then there is no
1561real difference between aborting and finishing the merge.
1562
1563 If the Emerge command was called from another Lisp program, then its
1564return value is @code{t} for successful completion, or @code{nil} if you
1565abort.
1566
1567@node Combining in Emerge
1568@section Combining the Two Versions
1569
1570 Sometimes you want to keep @emph{both} alternatives for a particular
1571difference. To do this, use @kbd{x c}, which edits the merge buffer
1572like this:
1573
1574@example
1575@group
1576#ifdef NEW
1577@var{version from A buffer}
1578#else /* not NEW */
1579@var{version from B buffer}
1580#endif /* not NEW */
1581@end group
1582@end example
1583
1584@noindent
1585@vindex emerge-combine-versions-template
1586While this example shows C preprocessor conditionals delimiting the two
1587alternative versions, you can specify the strings to use by setting
1588the variable @code{emerge-combine-versions-template} to a string of your
1589choice. In the string, @samp{%a} says where to put version A, and
1590@samp{%b} says where to put version B. The default setting, which
1591produces the results shown above, looks like this:
1592
1593@example
1594@group
1595"#ifdef NEW\n%a#else /* not NEW */\n%b#endif /* not NEW */\n"
1596@end group
1597@end example
1598
1599@node Fine Points of Emerge
1600@section Fine Points of Emerge
1601
1602 During the merge, you mustn't try to edit the A and B buffers yourself.
1603Emerge modifies them temporarily, but ultimately puts them back the way
1604they were.
1605
1606 You can have any number of merges going at once---just don't use any one
1607buffer as input to more than one merge at once, since the temporary
1608changes made in these buffers would get in each other's way.
1609
1610 Starting Emerge can take a long time because it needs to compare the
1611files fully. Emacs can't do anything else until @code{diff} finishes.
1612Perhaps in the future someone will change Emerge to do the comparison in
1613the background when the input files are large---then you could keep on
1614doing other things with Emacs until Emerge is ready to accept
1615commands.
1616
1617@vindex emerge-startup-hook
1618 After setting up the merge, Emerge runs the hook
1619@code{emerge-startup-hook}. @xref{Hooks,,, emacs, the Emacs Manual}.
1620
1621@node Picture Mode
1622@chapter Editing Pictures
1623@cindex pictures
1624@cindex making pictures out of text characters
1625@findex edit-picture
1626
1627 To edit a picture made out of text characters (for example, a picture
1628of the division of a register into fields, as a comment in a program),
1629use the command @kbd{M-x edit-picture} to enter Picture mode.
1630
1631 In Picture mode, editing is based on the @dfn{quarter-plane} model of
1632text, according to which the text characters lie studded on an area that
1633stretches infinitely far to the right and downward. The concept of the end
1634of a line does not exist in this model; the most you can say is where the
1635last nonblank character on the line is found.
1636
1637 Of course, Emacs really always considers text as a sequence of
1638characters, and lines really do have ends. But Picture mode replaces
1639the most frequently-used commands with variants that simulate the
1640quarter-plane model of text. They do this by inserting spaces or by
1641converting tabs to spaces.
1642
1643 Most of the basic editing commands of Emacs are redefined by Picture mode
1644to do essentially the same thing but in a quarter-plane way. In addition,
1645Picture mode defines various keys starting with the @kbd{C-c} prefix to
1646run special picture editing commands.
1647
1648 One of these keys, @kbd{C-c C-c}, is particularly important. Often a
1649picture is part of a larger file that is usually edited in some other
1650major mode. @kbd{M-x edit-picture} records the name of the previous
1651major mode so you can use the @kbd{C-c C-c} command
1652(@code{picture-mode-exit}) later to go back to that mode. @kbd{C-c C-c}
1653also deletes spaces from the ends of lines, unless given a numeric
1654argument.
1655
1656 The special commands of Picture mode all work in other modes (provided
1657the @file{picture} library is loaded), but are not bound to keys except
1658in Picture mode. The descriptions below talk of moving ``one column''
1659and so on, but all the picture mode commands handle numeric arguments as
1660their normal equivalents do.
1661
1662@vindex picture-mode-hook
1663 Turning on Picture mode runs the hook @code{picture-mode-hook}.
1664Additional extensions to Picture mode can be found in
1665@file{artist.el}.
1666
1667@menu
1668* Basic Picture:: Basic concepts and simple commands of Picture Mode.
1669* Insert in Picture:: Controlling direction of cursor motion
1670 after "self-inserting" characters.
1671* Tabs in Picture:: Various features for tab stops and indentation.
1672* Rectangles in Picture:: Clearing and superimposing rectangles.
1673@end menu
1674
1675@node Basic Picture
1676@section Basic Editing in Picture Mode
1677
1678@findex picture-forward-column
1679@findex picture-backward-column
1680@findex picture-move-down
1681@findex picture-move-up
1682@cindex editing in Picture mode
1683
1684 Most keys do the same thing in Picture mode that they usually do, but
1685do it in a quarter-plane style. For example, @kbd{C-f} is rebound to
1686run @code{picture-forward-column}, a command which moves point one
1687column to the right, inserting a space if necessary so that the actual
1688end of the line makes no difference. @kbd{C-b} is rebound to run
1689@code{picture-backward-column}, which always moves point left one
1690column, converting a tab to multiple spaces if necessary. @kbd{C-n} and
1691@kbd{C-p} are rebound to run @code{picture-move-down} and
1692@code{picture-move-up}, which can either insert spaces or convert tabs
1693as necessary to make sure that point stays in exactly the same column.
1694@kbd{C-e} runs @code{picture-end-of-line}, which moves to after the last
1695nonblank character on the line. There is no need to change @kbd{C-a},
1696as the choice of screen model does not affect beginnings of
1697lines.
1698
1699@findex picture-newline
1700 Insertion of text is adapted to the quarter-plane screen model
1701through the use of Overwrite mode (@pxref{Minor Modes,,, emacs, the
1702Emacs Manual}.) Self-inserting characters replace existing text,
1703column by column, rather than pushing existing text to the right.
1704@key{RET} runs @code{picture-newline}, which just moves to the
1705beginning of the following line so that new text will replace that
1706line.
1707
1708@findex picture-backward-clear-column
1709@findex picture-clear-column
1710@findex picture-clear-line
1711 In Picture mode, the commands that normally delete or kill text,
1712instead erase text (replacing it with spaces). @key{DEL}
1713(@code{picture-backward-clear-column}) replaces the preceding
1714character with a space rather than removing it; this moves point
1715backwards. @kbd{C-d} (@code{picture-clear-column}) replaces the next
1716character or characters with spaces, but does not move point. (If you
1717want to clear characters to spaces and move forward over them, use
1718@key{SPC}.) @kbd{C-k} (@code{picture-clear-line}) really kills the
1719contents of lines, but does not delete the newlines from the buffer.
1720
1721@findex picture-open-line
1722 To do actual insertion, you must use special commands. @kbd{C-o}
1723(@code{picture-open-line}) creates a blank line after the current
1724line; it never splits a line. @kbd{C-M-o} (@code{split-line}) makes
1725sense in Picture mode, so it is not changed. @kbd{C-j}
1726(@code{picture-duplicate-line}) inserts another line with the same
1727contents below the current line.
1728
1729@kindex C-c C-d @r{(Picture mode)}
1730 To do actual deletion in Picture mode, use @kbd{C-w}, @kbd{C-c C-d}
1731(which is defined as @code{delete-char}, as @kbd{C-d} is in other
1732modes), or one of the picture rectangle commands (@pxref{Rectangles in
1733Picture}).
1734
1735@node Insert in Picture
1736@section Controlling Motion after Insert
1737
1738@findex picture-movement-up
1739@findex picture-movement-down
1740@findex picture-movement-left
1741@findex picture-movement-right
1742@findex picture-movement-nw
1743@findex picture-movement-ne
1744@findex picture-movement-sw
1745@findex picture-movement-se
1746@kindex C-c < @r{(Picture mode)}
1747@kindex C-c > @r{(Picture mode)}
1748@kindex C-c ^ @r{(Picture mode)}
1749@kindex C-c . @r{(Picture mode)}
1750@kindex C-c ` @r{(Picture mode)}
1751@kindex C-c ' @r{(Picture mode)}
1752@kindex C-c / @r{(Picture mode)}
1753@kindex C-c \ @r{(Picture mode)}
1754 Since ``self-inserting'' characters in Picture mode overwrite and move
1755point, there is no essential restriction on how point should be moved.
1756Normally point moves right, but you can specify any of the eight
1757orthogonal or diagonal directions for motion after a ``self-inserting''
1758character. This is useful for drawing lines in the buffer.
1759
1760@table @kbd
1761@item C-c <
1762@itemx C-c @key{LEFT}
1763Move left after insertion (@code{picture-movement-left}).
1764@item C-c >
1765@itemx C-c @key{RIGHT}
1766Move right after insertion (@code{picture-movement-right}).
1767@item C-c ^
1768@itemx C-c @key{UP}
1769Move up after insertion (@code{picture-movement-up}).
1770@item C-c .
1771@itemx C-c @key{DOWN}
1772Move down after insertion (@code{picture-movement-down}).
1773@item C-c `
1774@itemx C-c @key{HOME}
1775Move up and left (``northwest'') after insertion (@code{picture-movement-nw}).
1776@item C-c '
1777@itemx C-c @key{PAGEUP}
1778Move up and right (``northeast'') after insertion
1779(@code{picture-movement-ne}).
1780@item C-c /
1781@itemx C-c @key{END}
1782Move down and left (``southwest'') after insertion
1783@*(@code{picture-movement-sw}).
1784@item C-c \
1785@itemx C-c @key{PAGEDOWN}
1786Move down and right (``southeast'') after insertion
1787@*(@code{picture-movement-se}).
1788@end table
1789
1790@kindex C-c C-f @r{(Picture mode)}
1791@kindex C-c C-b @r{(Picture mode)}
1792@findex picture-motion
1793@findex picture-motion-reverse
1794 Two motion commands move based on the current Picture insertion
1795direction. The command @kbd{C-c C-f} (@code{picture-motion}) moves in the
1796same direction as motion after ``insertion'' currently does, while @kbd{C-c
1797C-b} (@code{picture-motion-reverse}) moves in the opposite direction.
1798
1799@node Tabs in Picture
1800@section Picture Mode Tabs
1801
1802@kindex M-TAB @r{(Picture mode)}
1803@findex picture-tab-search
1804@vindex picture-tab-chars
1805 Two kinds of tab-like action are provided in Picture mode. Use
1806@kbd{M-@key{TAB}} (@code{picture-tab-search}) for context-based tabbing.
1807With no argument, it moves to a point underneath the next
1808``interesting'' character that follows whitespace in the previous
1809nonblank line. ``Next'' here means ``appearing at a horizontal position
1810greater than the one point starts out at.'' With an argument, as in
1811@kbd{C-u M-@key{TAB}}, this command moves to the next such interesting
1812character in the current line. @kbd{M-@key{TAB}} does not change the
1813text; it only moves point. ``Interesting'' characters are defined by
1814the variable @code{picture-tab-chars}, which should define a set of
1815characters. The syntax for this variable is like the syntax used inside
1816of @samp{[@dots{}]} in a regular expression---but without the @samp{[}
1817and the @samp{]}. Its default value is @code{"!-~"}.
1818
1819@findex picture-tab
1820 @key{TAB} itself runs @code{picture-tab}, which operates based on the
1821current tab stop settings; it is the Picture mode equivalent of
1822@code{tab-to-tab-stop}. Normally it just moves point, but with a numeric
1823argument it clears the text that it moves over.
1824
1825@kindex C-c TAB @r{(Picture mode)}
1826@findex picture-set-tab-stops
1827 The context-based and tab-stop-based forms of tabbing are brought
1828together by the command @kbd{C-c @key{TAB}} (@code{picture-set-tab-stops}).
1829This command sets the tab stops to the positions which @kbd{M-@key{TAB}}
1830would consider significant in the current line. The use of this command,
1831together with @key{TAB}, can get the effect of context-based tabbing. But
1832@kbd{M-@key{TAB}} is more convenient in the cases where it is sufficient.
1833
1834 It may be convenient to prevent use of actual tab characters in
1835pictures. For example, this prevents @kbd{C-x @key{TAB}} from messing
1836up the picture. You can do this by setting the variable
1837@code{indent-tabs-mode} to @code{nil}.
1838
1839@node Rectangles in Picture
1840@section Picture Mode Rectangle Commands
1841@cindex rectangles and Picture mode
1842@cindex Picture mode and rectangles
1843
1844 Picture mode defines commands for working on rectangular pieces of
1845the text in ways that fit with the quarter-plane model. The standard
1846rectangle commands may also be useful. @xref{Rectangles,,, emacs, the
1847Emacs Manual}.
1848
1849@table @kbd
1850@item C-c C-k
1851Clear out the region-rectangle with spaces
1852(@code{picture-clear-rectangle}). With argument, delete the text.
1853@item C-c C-w @var{r}
1854Similar, but save rectangle contents in register @var{r} first
1855(@code{picture-clear-rectangle-to-register}).
1856@item C-c C-y
1857Copy last killed rectangle into the buffer by overwriting, with upper
1858left corner at point (@code{picture-yank-rectangle}). With argument,
1859insert instead.
1860@item C-c C-x @var{r}
1861Similar, but use the rectangle in register @var{r}
1862(@code{picture-yank-rectangle-from-register}).
1863@end table
1864
1865@kindex C-c C-k @r{(Picture mode)}
1866@kindex C-c C-w @r{(Picture mode)}
1867@findex picture-clear-rectangle
1868@findex picture-clear-rectangle-to-register
1869 The picture rectangle commands @kbd{C-c C-k}
1870(@code{picture-clear-rectangle}) and @kbd{C-c C-w}
1871(@code{picture-clear-rectangle-to-register}) differ from the standard
1872rectangle commands in that they normally clear the rectangle instead of
1873deleting it; this is analogous with the way @kbd{C-d} is changed in Picture
1874mode.
1875
1876 However, deletion of rectangles can be useful in Picture mode, so
1877these commands delete the rectangle if given a numeric argument.
1878@kbd{C-c C-k} either with or without a numeric argument saves the
1879rectangle for @kbd{C-c C-y}.
1880
1881@kindex C-c C-y @r{(Picture mode)}
1882@kindex C-c C-x @r{(Picture mode)}
1883@findex picture-yank-rectangle
1884@findex picture-yank-rectangle-from-register
1885 The Picture mode commands for yanking rectangles differ from the
1886standard ones in that they overwrite instead of inserting. This is
1887the same way that Picture mode insertion of other text differs from
1888other modes. @kbd{C-c C-y} (@code{picture-yank-rectangle}) inserts
1889(by overwriting) the rectangle that was most recently killed, while
1890@kbd{C-c C-x} (@code{picture-yank-rectangle-from-register}) does
1891likewise for the rectangle found in a specified register.
1892
1893@node Advanced VC Usage
1894@chapter Advanced VC Usage
1895
1896 Commonly used features of Emacs' version control (VC) support are
1897described in the main Emacs manual (@pxref{Version Control,,,emacs,
1898the Emacs Manual}). This chapter describes more advanced VC usage.
1899
1900@menu
1901* VC Dired Mode:: Listing files managed by version control.
1902* VC Dired Commands:: Commands to use in a VC Dired buffer.
1903* Remote Repositories:: Efficient access to remote CVS servers.
1904* Snapshots:: Sets of file versions treated as a unit.
1905* Miscellaneous VC:: Various other commands and features of VC.
1906* Customizing VC:: Variables that change VC's behavior.
1907@end menu
1908
1909@node VC Dired Mode
1910@section Dired under VC
1911
1912@cindex PCL-CVS
1913@pindex cvs
1914@cindex CVS Dired Mode
1915 The VC Dired Mode described here works with all the version control
1916systems that VC supports. Another more powerful facility, designed
1917specifically for CVS, is called PCL-CVS. @xref{Top, , About PCL-CVS,
1918pcl-cvs, PCL-CVS --- The Emacs Front-End to CVS}.
1919
1920@kindex C-x v d
1921@findex vc-directory
1922 When you are working on a large program, it is often useful to find
1923out which files have changed within an entire directory tree, or to view
1924the status of all files under version control at once, and to perform
1925version control operations on collections of files. You can use the
1926command @kbd{C-x v d} (@code{vc-directory}) to make a directory listing
1927that includes only files relevant for version control.
1928
1929@vindex vc-dired-terse-display
1930 @kbd{C-x v d} creates a buffer which uses VC Dired Mode. This looks
1931much like an ordinary Dired buffer (@pxref{Dired,,,emacs, the
1932Emacs Manual}); however, normally it shows only the noteworthy files
1933(those locked or not up-to-date). This is called @dfn{terse display}.
1934If you set the variable @code{vc-dired-terse-display} to @code{nil},
1935then VC Dired shows all relevant files---those managed under version
1936control, plus all subdirectories (@dfn{full display}). The command
1937@kbd{v t} in a VC Dired buffer toggles between terse display and full
1938display (@pxref{VC Dired Commands}).
1939
1940@vindex vc-dired-recurse
1941 By default, VC Dired produces a recursive listing of noteworthy or
1942relevant files at or below the given directory. You can change this by
1943setting the variable @code{vc-dired-recurse} to @code{nil}; then VC
1944Dired shows only the files in the given directory.
1945
1946 The line for an individual file shows the version control state in the
1947place of the hard link count, owner, group, and size of the file. If
1948the file is unmodified, in sync with the master file, the version
1949control state shown is blank. Otherwise it consists of text in
1950parentheses. Under RCS and SCCS, the name of the user locking the file
1951is shown; under CVS, an abbreviated version of the @samp{cvs status}
1952output is used. Here is an example using RCS:
1953
1954@smallexample
1955@group
1956 /home/jim/project:
1957
1958 -rw-r--r-- (jim) Apr 2 23:39 file1
1959 -r--r--r-- Apr 5 20:21 file2
1960@end group
1961@end smallexample
1962
1963@noindent
1964The files @samp{file1} and @samp{file2} are under version control,
1965@samp{file1} is locked by user jim, and @samp{file2} is unlocked.
1966
1967 Here is an example using CVS:
1968
1969@smallexample
1970@group
1971 /home/joe/develop:
1972
1973 -rw-r--r-- (modified) Aug 2 1997 file1.c
1974 -rw-r--r-- Apr 4 20:09 file2.c
1975 -rw-r--r-- (merge) Sep 13 1996 file3.c
1976@end group
1977@end smallexample
1978
1979 Here @samp{file1.c} is modified with respect to the repository, and
1980@samp{file2.c} is not. @samp{file3.c} is modified, but other changes
1981have also been checked in to the repository---you need to merge them
1982with the work file before you can check it in.
1983
1984@vindex vc-stay-local
1985@vindex vc-cvs-stay-local
1986 In the above, if the repository were on a remote machine, VC would
1987only contact it when the variable @code{vc-stay-local} (or
1988@code{vc-cvs-stay-local}) is nil (@pxref{CVS Options}). This is
1989because access to the repository may be slow, or you may be working
1990offline and not have access to the repository at all. As a
1991consequence, VC would not be able to tell you that @samp{file3.c} is
1992in the ``merge'' state; you would learn that only when you try to
1993check-in your modified copy of the file, or use a command such as
1994@kbd{C-x v m}.
1995
1996 In practice, this is not a problem because CVS handles this case
1997consistently whenever it arises. In VC, you'll simply get prompted to
1998merge the remote changes into your work file first. The benefits of
1999less network communication usually outweigh the disadvantage of not
2000seeing remote changes immediately.
2001
2002@vindex vc-directory-exclusion-list
2003 When VC Dired displays subdirectories (in the ``full'' display mode),
2004it omits some that should never contain any files under version control.
2005By default, this includes Version Control subdirectories such as
2006@samp{RCS} and @samp{CVS}; you can customize this by setting the
2007variable @code{vc-directory-exclusion-list}.
2008
2009 You can fine-tune VC Dired's format by typing @kbd{C-u C-x v d}---as in
2010ordinary Dired, that allows you to specify additional switches for the
2011@samp{ls} command.
2012
2013@node VC Dired Commands
2014@section VC Dired Commands
2015
2016 All the usual Dired commands work normally in VC Dired mode, except
2017for @kbd{v}, which is redefined as the version control prefix. You can
2018invoke VC commands such as @code{vc-diff} and @code{vc-print-log} by
2019typing @kbd{v =}, or @kbd{v l}, and so on. Most of these commands apply
2020to the file name on the current line.
2021
2022 The command @kbd{v v} (@code{vc-next-action}) operates on all the
2023marked files, so that you can lock or check in several files at once.
2024If it operates on more than one file, it handles each file according to
2025its current state; thus, it might lock one file, but check in another
2026file. This could be confusing; it is up to you to avoid confusing
2027behavior by marking a set of files that are in a similar state. If no
2028files are marked, @kbd{v v} operates on the file in the current line.
2029
2030 If any files call for check-in, @kbd{v v} reads a single log entry,
2031then uses it for all the files being checked in. This is convenient for
2032registering or checking in several files at once, as part of the same
2033change.
2034
2035@findex vc-dired-toggle-terse-mode
2036@findex vc-dired-mark-locked
2037 You can toggle between terse display (only locked files, or files not
2038up-to-date) and full display at any time by typing @kbd{v t}
2039(@code{vc-dired-toggle-terse-mode}). There is also a special command
2040@kbd{* l} (@code{vc-dired-mark-locked}), which marks all files currently
2041locked (or, with CVS, all files not up-to-date). Thus, typing @kbd{* l
2042t k} is another way to delete from the buffer all files except those
2043currently locked.
2044
2045@node Remote Repositories
2046@section Remote Repositories
2047@cindex remote repositories (CVS)
2048
2049 A common way of using CVS is to set up a central CVS repository on
2050some Internet host, then have each developer check out a personal
2051working copy of the files on his local machine. Committing changes to
2052the repository, and picking up changes from other users into one's own
2053working area, then works by direct interactions with the CVS server.
2054
2055 One difficulty is that access to the CVS server is often slow, and
2056that developers might need to work off-line as well. VC is designed
2057to reduce the amount of network interaction necessary.
2058
2059@menu
2060* Version Backups:: Keeping local copies of repository versions.
2061* Local Version Control:: Using another version system for local editing.
2062@end menu
2063
2064@node Version Backups
2065@subsection Version Backups
2066@cindex version backups
2067
2068@cindex automatic version backups
2069 When VC sees that the CVS repository for a file is on a remote
2070machine, it automatically makes local backups of unmodified versions
2071of the file---@dfn{automatic version backups}. This means that you
2072can compare the file to the repository version (@kbd{C-x v =}), or
2073revert to that version (@kbd{C-x v u}), without any network
2074interactions.
2075
2076 The local copy of the unmodified file is called a @dfn{version
2077backup} to indicate that it corresponds exactly to a version that is
2078stored in the repository. Note that version backups are not the same
2079as ordinary Emacs backup files (@pxref{Backup,,,emacs, the Emacs
2080Manual}). But they follow a similar naming convention.
2081
2082 For a file that comes from a remote CVS repository, VC makes a
2083version backup whenever you save the first changes to the file, and
2084removes it after you have committed your modified version to the
2085repository. You can disable the making of automatic version backups by
2086setting @code{vc-cvs-stay-local} to @code{nil} (@pxref{CVS Options}).
2087
2088@cindex manual version backups
2089 The name of the automatic version backup for version @var{version}
2090of file @var{file} is @code{@var{file}.~@var{version}.~}. This is
2091almost the same as the name used by @kbd{C-x v ~} (@pxref{Old
2092Versions,,,emacs, the Emacs Manual}), the only difference being
2093the additional dot (@samp{.}) after the version number. This
2094similarity is intentional, because both kinds of files store the same
2095kind of information. The file made by @kbd{C-x v ~} acts as a
2096@dfn{manual version backup}.
2097
2098 All the VC commands that operate on old versions of a file can use
2099both kinds of version backups. For instance, @kbd{C-x v ~} uses
2100either an automatic or a manual version backup, if possible, to get
2101the contents of the version you request. Likewise, @kbd{C-x v =} and
2102@kbd{C-x v u} use either an automatic or a manual version backup, if
2103one of them exists, to get the contents of a version to compare or
2104revert to. If you changed a file outside of Emacs, so that no
2105automatic version backup was created for the previous text, you can
2106create a manual backup of that version using @kbd{C-x v ~}, and thus
2107obtain the benefit of the local copy for Emacs commands.
2108
2109 The only difference in Emacs's handling of manual and automatic
2110version backups, once they exist, is that Emacs deletes automatic
2111version backups when you commit to the repository. By contrast,
2112manual version backups remain until you delete them.
2113
2114@node Local Version Control
2115@subsection Local Version Control
2116@cindex local version control
2117@cindex local back end (version control)
2118
2119When you make many changes to a file that comes from a remote
2120repository, it can be convenient to have version control on your local
2121machine as well. You can then record intermediate versions, revert to
2122a previous state, etc., before you actually commit your changes to the
2123remote server.
2124
2125VC lets you do this by putting a file under a second, local version
2126control system, so that the file is effectively registered in two
2127systems at the same time. For the description here, we will assume
2128that the remote system is CVS, and you use RCS locally, although the
2129mechanism works with any combination of version control systems
2130(@dfn{back ends}).
2131
2132To make it work with other back ends, you must make sure that the
2133``more local'' back end comes before the ``more remote'' back end in
2134the setting of @code{vc-handled-backends} (@pxref{Customizing VC}). By
2135default, this variable is set up so that you can use remote CVS and
2136local RCS as described here.
2137
2138To start using local RCS for a file that comes from a remote CVS
2139server, you must @emph{register the file in RCS}, by typing @kbd{C-u
2140C-x v v rcs @key{RET}}. (In other words, use @code{vc-next-action} with a
2141prefix argument, and specify RCS as the back end.)
2142
2143You can do this at any time; it does not matter whether you have
2144already modified the file with respect to the version in the CVS
2145repository. If possible, VC tries to make the RCS master start with
2146the unmodified repository version, then checks in any local changes
2147as a new version. This works if you have not made any changes yet, or
2148if the unmodified repository version exists locally as a version
2149backup (@pxref{Version Backups}). If the unmodified version is not
2150available locally, the RCS master starts with the modified version;
2151the only drawback to this is that you cannot compare your changes
2152locally to what is stored in the repository.
2153
2154The version number of the RCS master is derived from the current CVS
2155version, starting a branch from it. For example, if the current CVS
2156version is 1.23, the local RCS branch will be 1.23.1. Version 1.23 in
2157the RCS master will be identical to version 1.23 under CVS; your first
2158changes are checked in as 1.23.1.1. (If the unmodified file is not
2159available locally, VC will check in the modified file twice, both as
21601.23 and 1.23.1.1, to make the revision numbers consistent.)
2161
2162If you do not use locking under CVS (the default), locking is also
2163disabled for RCS, so that editing under RCS works exactly as under
2164CVS.
2165
2166When you are done with local editing, you can commit the final version
2167back to the CVS repository by typing @kbd{C-u C-x v v cvs @key{RET}}.
2168This initializes the log entry buffer (@pxref{Log Buffer,,,emacs, the
2169Emacs Manual}) to contain all the log entries you have recorded in the
2170RCS master; you can edit them as you wish, and then commit in CVS by
2171typing @kbd{C-c C-c}. If the commit is successful, VC removes the RCS
2172master, so that the file is once again registered under CVS only.
2173(The RCS master is not actually deleted, just renamed by appending
2174@samp{~} to the name, so that you can refer to it later if you wish.)
2175
2176While using local RCS, you can pick up recent changes from the CVS
2177repository into your local file, or commit some of your changes back
2178to CVS, without terminating local RCS version control. To do this,
2179switch to the CVS back end temporarily, with the @kbd{C-x v b} command:
2180
2181@table @kbd
2182@item C-x v b
2183Switch to another back end that the current file is registered
2184under (@code{vc-switch-backend}).
2185
2186@item C-u C-x v b @var{backend} @key{RET}
2187Switch to @var{backend} for the current file.
2188@end table
2189
2190@kindex C-x v b
2191@findex vc-switch-backend
2192@kbd{C-x v b} does not change the buffer contents, or any files; it
2193only changes VC's perspective on how to handle the file. Any
2194subsequent VC commands for that file will operate on the back end that
2195is currently selected.
2196
2197If the current file is registered in more than one back end, typing
2198@kbd{C-x v b} ``cycles'' through all of these back ends. With a
2199prefix argument, it asks for the back end to use in the minibuffer.
2200
2201Thus, if you are using local RCS, and you want to pick up some recent
2202changes in the file from remote CVS, first visit the file, then type
2203@kbd{C-x v b} to switch to CVS, and finally use @kbd{C-x v m
2204@key{RET}} to merge the news (@pxref{Merging,,,emacs, the Emacs
2205Manual}). You can then switch back to RCS by typing @kbd{C-x v b}
2206again, and continue to edit locally.
2207
2208But if you do this, the revision numbers in the RCS master no longer
2209correspond to those of CVS. Technically, this is not a problem, but
2210it can become difficult to keep track of what is in the CVS repository
2211and what is not. So we suggest that you return from time to time to
2212CVS-only operation, by committing your local changes back to the
2213repository using @kbd{C-u C-x v v cvs @key{RET}}.
2214
2215@node Snapshots
2216@section Snapshots
2217@cindex snapshots and version control
2218
2219 A @dfn{snapshot} is a named set of file versions (one for each
2220registered file) that you can treat as a unit. One important kind of
2221snapshot is a @dfn{release}, a (theoretically) stable version of the
2222system that is ready for distribution to users.
2223
2224@menu
2225* Making Snapshots:: The snapshot facilities.
2226* Snapshot Caveats:: Things to be careful of when using snapshots.
2227@end menu
2228
2229@node Making Snapshots
2230@subsection Making and Using Snapshots
2231
2232 There are two basic commands for snapshots; one makes a
2233snapshot with a given name, the other retrieves a named snapshot.
2234
2235@table @code
2236@kindex C-x v s
2237@findex vc-create-snapshot
2238@item C-x v s @var{name} @key{RET}
2239Define the last saved versions of every registered file in or under the
2240current directory as a snapshot named @var{name}
2241(@code{vc-create-snapshot}).
2242
2243@kindex C-x v r
2244@findex vc-retrieve-snapshot
2245@item C-x v r @var{name} @key{RET}
2246For all registered files at or below the current directory level, select
2247whatever versions correspond to the snapshot @var{name}
2248(@code{vc-retrieve-snapshot}).
2249
2250This command reports an error if any files are locked at or below the
2251current directory, without changing anything; this is to avoid
2252overwriting work in progress.
2253@end table
2254
2255 A snapshot uses a very small amount of resources---just enough to record
2256the list of file names and which version belongs to the snapshot. Thus,
2257you need not hesitate to create snapshots whenever they are useful.
2258
2259 You can give a snapshot name as an argument to @kbd{C-x v =} or
2260@kbd{C-x v ~} (@pxref{Old Versions,,,emacs, the Emacs Manual}).
2261Thus, you can use it to compare a snapshot against the current files,
2262or two snapshots against each other, or a snapshot against a named
2263version.
2264
2265@node Snapshot Caveats
2266@subsection Snapshot Caveats
2267
2268@cindex named configurations (RCS)
2269 VC's snapshot facilities are modeled on RCS's named-configuration
2270support. They use RCS's native facilities for this, so
2271snapshots made using RCS through VC are visible even when you bypass VC.
2272
2273 With CVS, Meta-CVS, and Subversion, VC also uses the native
2274mechanism provided by that back end to make snapshots and retrieve them
2275(@dfn{tags} for CVS and Meta-CVS, @dfn{copies} for Subversion).
2276
2277@c worded verbosely to avoid overfull hbox.
2278 For SCCS, VC implements snapshots itself. The files it uses contain
2279name/file/version-number triples. These snapshots are visible only
2280through VC.
2281
2282 There is no support for VC snapshots using GNU Arch yet.
2283
2284 A snapshot is a set of checked-in versions. So make sure that all the
2285files are checked in and not locked when you make a snapshot.
2286
2287 File renaming and deletion can create some difficulties with snapshots.
2288This is not a VC-specific problem, but a general design issue in version
2289control systems that no one has solved very well yet.
2290
2291 If you rename a registered file, you need to rename its master along
2292with it (the command @code{vc-rename-file} does this automatically). If
2293you are using SCCS, you must also update the records of the snapshot, to
2294mention the file by its new name (@code{vc-rename-file} does this,
2295too). An old snapshot that refers to a master file that no longer
2296exists under the recorded name is invalid; VC can no longer retrieve
2297it. It would be beyond the scope of this manual to explain enough about
2298RCS and SCCS to explain how to update the snapshots by hand.
2299
2300 Using @code{vc-rename-file} makes the snapshot remain valid for
2301retrieval, but it does not solve all problems. For example, some of the
2302files in your program probably refer to others by name. At the very
2303least, the makefile probably mentions the file that you renamed. If you
2304retrieve an old snapshot, the renamed file is retrieved under its new
2305name, which is not the name that the makefile expects. So the program
2306won't really work as retrieved.
2307
2308@node Miscellaneous VC
2309@section Miscellaneous Commands and Features of VC
2310
2311 This section explains the less-frequently-used features of VC.
2312
2313@menu
2314* Change Logs and VC:: Generating a change log file from log entries.
2315* Renaming and VC:: A command to rename both the source and master
2316 file correctly.
2317* Version Headers:: Inserting version control headers into working files.
2318@end menu
2319
2320@node Change Logs and VC
2321@subsection Change Logs and VC
2322
2323 If you use RCS or CVS for a program and also maintain a change log
2324file for it (@pxref{Change Log,,,emacs, the Emacs Manual}), you
2325can generate change log entries automatically from the version control
2326log entries:
2327
2328@table @kbd
2329@item C-x v a
2330@kindex C-x v a
2331@findex vc-update-change-log
2332Visit the current directory's change log file and, for registered files
2333in that directory, create new entries for versions checked in since the
2334most recent entry in the change log file.
2335(@code{vc-update-change-log}).
2336
2337This command works with RCS or CVS only, not with any of the other
2338back ends.
2339
2340@item C-u C-x v a
2341As above, but only find entries for the current buffer's file.
2342
2343@item M-1 C-x v a
2344As above, but find entries for all the currently visited files that are
2345maintained with version control. This works only with RCS, and it puts
2346all entries in the log for the default directory, which may not be
2347appropriate.
2348@end table
2349
2350 For example, suppose the first line of @file{ChangeLog} is dated
23511999-04-10, and that the only check-in since then was by Nathaniel
2352Bowditch to @file{rcs2log} on 1999-05-22 with log text @samp{Ignore log
2353messages that start with `#'.}. Then @kbd{C-x v a} visits
2354@file{ChangeLog} and inserts text like this:
2355
2356@iftex
2357@medbreak
2358@end iftex
2359@smallexample
2360@group
23611999-05-22 Nathaniel Bowditch <nat@@apn.org>
2362
2363 * rcs2log: Ignore log messages that start with `#'.
2364@end group
2365@end smallexample
2366@iftex 95@iftex
2367@medbreak 96@c ``Picture Mode'' is a chapter, not a section, so it's outside @raisesections.
2368@end iftex 97@include picture-xtra.texi
2369 98
2370@noindent 99@raisesections
2371You can then edit the new change log entry further as you wish. 100@include arevert-xtra.texi
2372 101
2373 Some of the new change log entries may duplicate what's already in 102@include dired-xtra.texi
2374ChangeLog. You will have to remove these duplicates by hand.
2375 103
2376 Normally, the log entry for file @file{foo} is displayed as @samp{* 104@include cal-xtra.texi
2377foo: @var{text of log entry}}. The @samp{:} after @file{foo} is omitted
2378if the text of the log entry starts with @w{@samp{(@var{functionname}):
2379}}. For example, if the log entry for @file{vc.el} is
2380@samp{(vc-do-command): Check call-process status.}, then the text in
2381@file{ChangeLog} looks like this:
2382 105
2383@iftex 106@include emerge-xtra.texi
2384@medbreak
2385@end iftex
2386@smallexample
2387@group
23881999-05-06 Nathaniel Bowditch <nat@@apn.org>
2389
2390 * vc.el (vc-do-command): Check call-process status.
2391@end group
2392@end smallexample
2393@iftex
2394@medbreak
2395@end iftex
2396 107
2397 When @kbd{C-x v a} adds several change log entries at once, it groups 108@include vc-xtra.texi
2398related log entries together if they all are checked in by the same
2399author at nearly the same time. If the log entries for several such
2400files all have the same text, it coalesces them into a single entry.
2401For example, suppose the most recent check-ins have the following log
2402entries:
2403 109
2404@flushleft 110@include fortran-xtra.texi
2405@bullet{} For @file{vc.texinfo}: @samp{Fix expansion typos.}
2406@bullet{} For @file{vc.el}: @samp{Don't call expand-file-name.}
2407@bullet{} For @file{vc-hooks.el}: @samp{Don't call expand-file-name.}
2408@end flushleft
2409 111
2410@noindent 112@include msdog-xtra.texi
2411They appear like this in @file{ChangeLog}:
2412 113
2413@iftex 114@lowersections
2414@medbreak
2415@end iftex
2416@smallexample
2417@group
24181999-04-01 Nathaniel Bowditch <nat@@apn.org>
2419
2420 * vc.texinfo: Fix expansion typos.
2421
2422 * vc.el, vc-hooks.el: Don't call expand-file-name.
2423@end group
2424@end smallexample
2425@iftex
2426@medbreak
2427@end iftex 115@end iftex
2428 116
2429 Normally, @kbd{C-x v a} separates log entries by a blank line, but you
2430can mark several related log entries to be clumped together (without an
2431intervening blank line) by starting the text of each related log entry
2432with a label of the form @w{@samp{@{@var{clumpname}@} }}. The label
2433itself is not copied to @file{ChangeLog}. For example, suppose the log
2434entries are:
2435
2436@flushleft
2437@bullet{} For @file{vc.texinfo}: @samp{@{expand@} Fix expansion typos.}
2438@bullet{} For @file{vc.el}: @samp{@{expand@} Don't call expand-file-name.}
2439@bullet{} For @file{vc-hooks.el}: @samp{@{expand@} Don't call expand-file-name.}
2440@end flushleft
2441
2442@noindent
2443Then the text in @file{ChangeLog} looks like this:
2444
2445@iftex
2446@medbreak
2447@end iftex
2448@smallexample
2449@group
24501999-04-01 Nathaniel Bowditch <nat@@apn.org>
2451
2452 * vc.texinfo: Fix expansion typos.
2453 * vc.el, vc-hooks.el: Don't call expand-file-name.
2454@end group
2455@end smallexample
2456@iftex
2457@medbreak
2458@end iftex
2459
2460 A log entry whose text begins with @samp{#} is not copied to
2461@file{ChangeLog}. For example, if you merely fix some misspellings in
2462comments, you can log the change with an entry beginning with @samp{#}
2463to avoid putting such trivia into @file{ChangeLog}.
2464
2465@node Renaming and VC
2466@subsection Renaming VC Work Files and Master Files
2467
2468@findex vc-rename-file
2469 When you rename a registered file, you must also rename its master
2470file correspondingly to get proper results. Use @code{vc-rename-file}
2471to rename the source file as you specify, and rename its master file
2472accordingly. It also updates any snapshots (@pxref{Snapshots}) that
2473mention the file, so that they use the new name; despite this, the
2474snapshot thus modified may not completely work (@pxref{Snapshot
2475Caveats}).
2476
2477 Some back ends do not provide an explicit rename operation to their
2478repositories. After issuing @code{vc-rename-file}, use @kbd{C-x v v}
2479on the original and renamed buffers and provide the necessary edit
2480log.
2481
2482 You cannot use @code{vc-rename-file} on a file that is locked by
2483someone else.
2484
2485@node Version Headers
2486@subsection Inserting Version Control Headers
2487
2488 Sometimes it is convenient to put version identification strings
2489directly into working files. Certain special strings called
2490@dfn{version headers} are replaced in each successive version by the
2491number of that version, the name of the user who created it, and other
2492relevant information. All of the back ends that VC supports have such
2493a mechanism, except GNU Arch.
2494
2495 VC does not normally use the information contained in these headers.
2496The exception is RCS---with RCS, version headers are sometimes more
2497reliable than the master file to determine which version of the file
2498you are editing. Note that in a multi-branch environment, version
2499headers are necessary to make VC behave correctly (@pxref{Multi-User
2500Branching,,,emacs, the Emacs Manual}).
2501
2502 Searching for RCS version headers is controlled by the variable
2503@code{vc-consult-headers}. If it is non-@code{nil} (the default),
2504Emacs searches for headers to determine the version number you are
2505editing. Setting it to @code{nil} disables this feature.
2506
2507 Note that although CVS uses the same kind of version headers as RCS
2508does, VC never searches for these headers if you are using CVS,
2509regardless of the above setting.
2510
2511@kindex C-x v h
2512@findex vc-insert-headers
2513 You can use the @kbd{C-x v h} command (@code{vc-insert-headers}) to
2514insert a suitable header string.
2515
2516@table @kbd
2517@item C-x v h
2518Insert headers in a file for use with your version-control system.
2519@end table
2520
2521@vindex vc-@var{backend}-header
2522 The default header string is @samp{@w{$}Id$} for RCS and
2523@samp{@w{%}W%} for SCCS. You can specify other headers to insert by
2524setting the variables @code{vc-@var{backend}-header} where
2525@var{backend} is @code{rcs} or @code{sccs}.
2526
2527 Instead of a single string, you can specify a list of strings; then
2528each string in the list is inserted as a separate header on a line of
2529its own.
2530
2531 It may be necessary to use apparently-superfluous backslashes when
2532writing the strings that you put in this variable. For instance, you
2533might write @code{"$Id\$"} rather than @code{"$Id@w{$}"}. The extra
2534backslash prevents the string constant from being interpreted as a
2535header, if the Emacs Lisp file containing it is maintained with
2536version control.
2537
2538@vindex vc-comment-alist
2539 Each header is inserted surrounded by tabs, inside comment delimiters,
2540on a new line at point. Normally the ordinary comment
2541start and comment end strings of the current mode are used, but for
2542certain modes, there are special comment delimiters for this purpose;
2543the variable @code{vc-comment-alist} specifies them. Each element of
2544this list has the form @code{(@var{mode} @var{starter} @var{ender})}.
2545
2546@vindex vc-static-header-alist
2547 The variable @code{vc-static-header-alist} specifies further strings
2548to add based on the name of the buffer. Its value should be a list of
2549elements of the form @code{(@var{regexp} . @var{format})}. Whenever
2550@var{regexp} matches the buffer name, @var{format} is inserted as part
2551of the header. A header line is inserted for each element that matches
2552the buffer name, and for each string specified by
2553@code{vc-@var{backend}-header}. The header line is made by processing the
2554string from @code{vc-@var{backend}-header} with the format taken from the
2555element. The default value for @code{vc-static-header-alist} is as follows:
2556
2557@example
2558@group
2559(("\\.c$" .
2560 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n\
2561#endif /* lint */\n"))
2562@end group
2563@end example
2564
2565@noindent
2566It specifies insertion of text of this form:
2567
2568@example
2569@group
2570
2571#ifndef lint
2572static char vcid[] = "@var{string}";
2573#endif /* lint */
2574@end group
2575@end example
2576
2577@noindent
2578Note that the text above starts with a blank line.
2579
2580 If you use more than one version header in a file, put them close
2581together in the file. The mechanism in @code{revert-buffer} that
2582preserves markers may not handle markers positioned between two version
2583headers.
2584
2585@node Customizing VC
2586@section Customizing VC
2587
2588@vindex vc-handled-backends
2589The variable @code{vc-handled-backends} determines which version
2590control systems VC should handle. The default value is @code{(RCS CVS
2591SVN SCCS Arch MCVS)}, so it contains all six version systems that are
2592currently supported. If you want VC to ignore one or more of these
2593systems, exclude its name from the list. To disable VC entirely, set
2594this variable to @code{nil}.
2595
2596The order of systems in the list is significant: when you visit a file
2597registered in more than one system (@pxref{Local Version Control}), VC
2598uses the system that comes first in @code{vc-handled-backends} by
2599default. The order is also significant when you register a file for
2600the first time, @pxref{Registering,,,emacs, the Emacs Manual} for
2601details.
2602
2603@menu
2604* General VC Options:: Options that apply to multiple back ends.
2605* RCS and SCCS:: Options for RCS and SCCS.
2606* CVS Options:: Options for CVS.
2607@end menu
2608
2609@node General VC Options
2610@subsection General Options
2611
2612@vindex vc-make-backup-files
2613 Emacs normally does not save backup files for source files that are
2614maintained with version control. If you want to make backup files even
2615for files that use version control, set the variable
2616@code{vc-make-backup-files} to a non-@code{nil} value.
2617
2618@vindex vc-keep-workfiles
2619 Normally the work file exists all the time, whether it is locked or
2620not. If you set @code{vc-keep-workfiles} to @code{nil}, then checking
2621in a new version with @kbd{C-x v v} deletes the work file; but any
2622attempt to visit the file with Emacs creates it again. (With CVS, work
2623files are always kept.)
2624
2625@vindex vc-follow-symlinks
2626 Editing a version-controlled file through a symbolic link can be
2627dangerous. It bypasses the version control system---you can edit the
2628file without locking it, and fail to check your changes in. Also,
2629your changes might overwrite those of another user. To protect against
2630this, VC checks each symbolic link that you visit, to see if it points
2631to a file under version control.
2632
2633 The variable @code{vc-follow-symlinks} controls what to do when a
2634symbolic link points to a version-controlled file. If it is @code{nil},
2635VC only displays a warning message. If it is @code{t}, VC automatically
2636follows the link, and visits the real file instead, telling you about
2637this in the echo area. If the value is @code{ask} (the default), VC
2638asks you each time whether to follow the link.
2639
2640@vindex vc-suppress-confirm
2641 If @code{vc-suppress-confirm} is non-@code{nil}, then @kbd{C-x v v}
2642and @kbd{C-x v i} can save the current buffer without asking, and
2643@kbd{C-x v u} also operates without asking for confirmation. (This
2644variable does not affect @kbd{C-x v c}; that operation is so drastic
2645that it should always ask for confirmation.)
2646
2647@vindex vc-command-messages
2648 VC mode does much of its work by running the shell commands for RCS,
2649CVS and SCCS. If @code{vc-command-messages} is non-@code{nil}, VC
2650displays messages to indicate which shell commands it runs, and
2651additional messages when the commands finish.
2652
2653@vindex vc-path
2654 You can specify additional directories to search for version control
2655programs by setting the variable @code{vc-path}. These directories
2656are searched before the usual search path. It is rarely necessary to
2657set this variable, because VC normally finds the proper files
2658automatically.
2659
2660@node RCS and SCCS
2661@subsection Options for RCS and SCCS
2662
2663@cindex non-strict locking (RCS)
2664@cindex locking, non-strict (RCS)
2665 By default, RCS uses locking to coordinate the activities of several
2666users, but there is a mode called @dfn{non-strict locking} in which
2667you can check-in changes without locking the file first. Use
2668@samp{rcs -U} to switch to non-strict locking for a particular file,
2669see the @code{rcs} manual page for details.
2670
2671 When deducing the version control state of an RCS file, VC first
2672looks for an RCS version header string in the file (@pxref{Version
2673Headers}). If there is no header string, VC normally looks at the
2674file permissions of the work file; this is fast. But there might be
2675situations when the file permissions cannot be trusted. In this case
2676the master file has to be consulted, which is rather expensive. Also
2677the master file can only tell you @emph{if} there's any lock on the
2678file, but not whether your work file really contains that locked
2679version.
2680
2681@vindex vc-consult-headers
2682 You can tell VC not to use version headers to determine the file
2683status by setting @code{vc-consult-headers} to @code{nil}. VC then
2684always uses the file permissions (if it is supposed to trust them), or
2685else checks the master file.
2686
2687@vindex vc-mistrust-permissions
2688 You can specify the criterion for whether to trust the file
2689permissions by setting the variable @code{vc-mistrust-permissions}.
2690Its value can be @code{t} (always mistrust the file permissions and
2691check the master file), @code{nil} (always trust the file
2692permissions), or a function of one argument which makes the decision.
2693The argument is the directory name of the @file{RCS} subdirectory. A
2694non-@code{nil} value from the function says to mistrust the file
2695permissions. If you find that the file permissions of work files are
2696changed erroneously, set @code{vc-mistrust-permissions} to @code{t}.
2697Then VC always checks the master file to determine the file's status.
2698
2699 VC determines the version control state of files under SCCS much as
2700with RCS. It does not consider SCCS version headers, though. Thus,
2701the variable @code{vc-mistrust-permissions} affects SCCS use, but
2702@code{vc-consult-headers} does not.
2703
2704@node CVS Options
2705@subsection Options specific for CVS
2706
2707@cindex locking (CVS)
2708 By default, CVS does not use locking to coordinate the activities of
2709several users; anyone can change a work file at any time. However,
2710there are ways to restrict this, resulting in behavior that resembles
2711locking.
2712
2713@cindex CVSREAD environment variable (CVS)
2714 For one thing, you can set the @env{CVSREAD} environment variable
2715(the value you use makes no difference). If this variable is defined,
2716CVS makes your work files read-only by default. In Emacs, you must
2717type @kbd{C-x v v} to make the file writable, so that editing works
2718in fact similar as if locking was used. Note however, that no actual
2719locking is performed, so several users can make their files writable
2720at the same time. When setting @env{CVSREAD} for the first time, make
2721sure to check out all your modules anew, so that the file protections
2722are set correctly.
2723
2724@cindex cvs watch feature
2725@cindex watching files (CVS)
2726 Another way to achieve something similar to locking is to use the
2727@dfn{watch} feature of CVS. If a file is being watched, CVS makes it
2728read-only by default, and you must also use @kbd{C-x v v} in Emacs to
2729make it writable. VC calls @code{cvs edit} to make the file writable,
2730and CVS takes care to notify other developers of the fact that you
2731intend to change the file. See the CVS documentation for details on
2732using the watch feature.
2733
2734@vindex vc-stay-local
2735@vindex vc-cvs-stay-local
2736@cindex remote repositories (CVS)
2737 When a file's repository is on a remote machine, VC tries to keep
2738network interactions to a minimum. This is controlled by the variable
2739@code{vc-cvs-stay-local}. There is another variable,
2740@code{vc-stay-local}, which enables the feature also for other back
2741ends that support it, including CVS. In the following, we will talk
2742only about @code{vc-cvs-stay-local}, but everything applies to
2743@code{vc-stay-local} as well.
2744
2745If @code{vc-cvs-stay-local} is @code{t} (the default), then VC uses
2746only the entry in the local CVS subdirectory to determine the file's
2747state (and possibly information returned by previous CVS commands).
2748One consequence of this is that when you have modified a file, and
2749somebody else has already checked in other changes to the file, you
2750are not notified of it until you actually try to commit. (But you can
2751try to pick up any recent changes from the repository first, using
2752@kbd{C-x v m @key{RET}}, @pxref{Merging,,,emacs, the Emacs Manual}).
2753
2754 When @code{vc-cvs-stay-local} is @code{t}, VC also makes local
2755version backups, so that simple diff and revert operations are
2756completely local (@pxref{Version Backups}).
2757
2758 On the other hand, if you set @code{vc-cvs-stay-local} to @code{nil},
2759then VC queries the remote repository @emph{before} it decides what to
2760do in @code{vc-next-action} (@kbd{C-x v v}), just as it does for local
2761repositories. It also does not make any version backups.
2762
2763 You can also set @code{vc-cvs-stay-local} to a regular expression
2764that is matched against the repository host name; VC then stays local
2765only for repositories from hosts that match the pattern.
2766
2767@vindex vc-cvs-global-switches
2768 You can specify additional command line options to pass to all CVS
2769operations in the variable @code{vc-cvs-global-switches}. These
2770switches are inserted immediately after the @code{cvs} command, before
2771the name of the operation to invoke.
2772
2773
2774@node Fortran
2775@chapter Fortran Mode
2776@cindex Fortran mode
2777@cindex mode, Fortran
2778
2779 Fortran mode provides special motion commands for Fortran statements
2780and subprograms, and indentation commands that understand Fortran
2781conventions of nesting, line numbers and continuation statements.
2782Fortran mode has support for Auto Fill mode that breaks long lines into
2783proper Fortran continuation lines.
2784
2785 Special commands for comments are provided because Fortran comments
2786are unlike those of other languages. Built-in abbrevs optionally save
2787typing when you insert Fortran keywords.
2788
2789 Use @kbd{M-x fortran-mode} to switch to this major mode. This
2790command runs the hook @code{fortran-mode-hook}. @xref{Hooks,,, emacs,
2791the Emacs Manual}.
2792
2793@cindex Fortran77 and Fortran90
2794@findex f90-mode
2795@findex fortran-mode
2796 Fortran mode is meant for editing Fortran77 ``fixed format'' (and also
2797``tab format'') source code. For editing the modern Fortran90 or
2798Fortran95 ``free format'' source code, use F90 mode (@code{f90-mode}).
2799Emacs normally uses Fortran mode for files with extension @samp{.f},
2800@samp{.F} or @samp{.for}, and F90 mode for the extension @samp{.f90} and
2801@samp{.f95}. GNU Fortran supports both kinds of format.
2802
2803@menu
2804* Motion: Fortran Motion. Moving point by statements or subprograms.
2805* Indent: Fortran Indent. Indentation commands for Fortran.
2806* Comments: Fortran Comments. Inserting and aligning comments.
2807* Autofill: Fortran Autofill. Auto fill support for Fortran.
2808* Columns: Fortran Columns. Measuring columns for valid Fortran.
2809* Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
2810@end menu
2811
2812@node Fortran Motion
2813@section Motion Commands
2814
2815 In addition to the normal commands for moving by and operating on
2816``defuns'' (Fortran subprograms---functions and subroutines, as well as
2817modules for F90 mode), Fortran mode provides special commands to move by
2818statements and other program units.
2819
2820@table @kbd
2821@kindex C-c C-n @r{(Fortran mode)}
2822@findex fortran-next-statement
2823@findex f90-next-statement
2824@item C-c C-n
2825Move to the beginning of the next statement
2826(@code{fortran-next-statement}/@code{f90-next-statement}).
2827
2828@kindex C-c C-p @r{(Fortran mode)}
2829@findex fortran-previous-statement
2830@findex f90-previous-statement
2831@item C-c C-p
2832Move to the beginning of the previous statement
2833(@code{fortran-previous-statement}/@code{f90-previous-statement}).
2834If there is no previous statement (i.e. if called from the first
2835statement in the buffer), move to the start of the buffer.
2836
2837@kindex C-c C-e @r{(F90 mode)}
2838@findex f90-next-block
2839@item C-c C-e
2840Move point forward to the start of the next code block
2841(@code{f90-next-block}). A code block is a subroutine,
2842@code{if}--@code{endif} statement, and so forth. This command exists
2843for F90 mode only, not Fortran mode. With a numeric argument, this
2844moves forward that many blocks.
2845
2846@kindex C-c C-a @r{(F90 mode)}
2847@findex f90-previous-block
2848@item C-c C-a
2849Move point backward to the previous code block
2850(@code{f90-previous-block}). This is like @code{f90-next-block}, but
2851moves backwards.
2852
2853@kindex C-M-n @r{(Fortran mode)}
2854@findex fortran-end-of-block
2855@findex f90-end-of-block
2856@item C-M-n
2857Move to the end of the current code block
2858(@code{fortran-end-of-block}/@code{f90-end-of-block}). With a numeric
2859agument, move forward that number of blocks. The mark is set before
2860moving point. The F90 mode version of this command checks for
2861consistency of block types and labels (if present), but it does not
2862check the outermost block since that may be incomplete.
2863
2864@kindex C-M-p @r{(Fortran mode)}
2865@findex fortran-beginning-of-block
2866@findex f90-beginning-of-block
2867@item C-M-p
2868Move to the start of the current code block
2869(@code{fortran-beginning-of-block}/@code{f90-beginning-of-block}). This
2870is like @code{fortran-end-of-block}, but moves backwards.
2871@end table
2872
2873@node Fortran Indent
2874@section Fortran Indentation
2875
2876 Special commands and features are needed for indenting Fortran code in
2877order to make sure various syntactic entities (line numbers, comment line
2878indicators and continuation line flags) appear in the columns that are
2879required for standard, fixed (or tab) format Fortran.
2880
2881@menu
2882* Commands: ForIndent Commands. Commands for indenting and filling Fortran.
2883* Contline: ForIndent Cont. How continuation lines indent.
2884* Numbers: ForIndent Num. How line numbers auto-indent.
2885* Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
2886* Vars: ForIndent Vars. Variables controlling Fortran indent style.
2887@end menu
2888
2889@node ForIndent Commands
2890@subsection Fortran Indentation and Filling Commands
2891
2892@table @kbd
2893@item C-M-j
2894Break the current line at point and set up a continuation line
2895(@code{fortran-split-line}).
2896@item M-^
2897Join this line to the previous line (@code{fortran-join-line}).
2898@item C-M-q
2899Indent all the lines of the subprogram point is in
2900(@code{fortran-indent-subprogram}).
2901@item M-q
2902Fill a comment block or statement.
2903@end table
2904
2905@kindex C-M-q @r{(Fortran mode)}
2906@findex fortran-indent-subprogram
2907 The key @kbd{C-M-q} runs @code{fortran-indent-subprogram}, a command
2908to reindent all the lines of the Fortran subprogram (function or
2909subroutine) containing point.
2910
2911@kindex C-M-j @r{(Fortran mode)}
2912@findex fortran-split-line
2913 The key @kbd{C-M-j} runs @code{fortran-split-line}, which splits
2914a line in the appropriate fashion for Fortran. In a non-comment line,
2915the second half becomes a continuation line and is indented
2916accordingly. In a comment line, both halves become separate comment
2917lines.
2918
2919@kindex M-^ @r{(Fortran mode)}
2920@kindex C-c C-d @r{(Fortran mode)}
2921@findex fortran-join-line
2922 @kbd{M-^} or @kbd{C-c C-d} runs the command @code{fortran-join-line},
2923which joins a continuation line back to the previous line, roughly as
2924the inverse of @code{fortran-split-line}. The point must be on a
2925continuation line when this command is invoked.
2926
2927@kindex M-q @r{(Fortran mode)}
2928@kbd{M-q} in Fortran mode fills the comment block or statement that
2929point is in. This removes any excess statement continuations.
2930
2931@node ForIndent Cont
2932@subsection Continuation Lines
2933@cindex Fortran continuation lines
2934
2935@vindex fortran-continuation-string
2936 Most Fortran77 compilers allow two ways of writing continuation lines.
2937If the first non-space character on a line is in column 5, then that
2938line is a continuation of the previous line. We call this @dfn{fixed
2939format}. (In GNU Emacs we always count columns from 0; but note that
2940the Fortran standard counts from 1.) The variable
2941@code{fortran-continuation-string} specifies what character to put in
2942column 5. A line that starts with a tab character followed by any digit
2943except @samp{0} is also a continuation line. We call this style of
2944continuation @dfn{tab format}. (Fortran90 introduced ``free format'',
2945with another style of continuation lines).
2946
2947@vindex indent-tabs-mode @r{(Fortran mode)}
2948@vindex fortran-analyze-depth
2949@vindex fortran-tab-mode-default
2950 Fortran mode can use either style of continuation line. When you
2951enter Fortran mode, it tries to deduce the proper continuation style
2952automatically from the buffer contents. It does this by scanning up to
2953@code{fortran-analyze-depth} (default 100) lines from the start of the
2954buffer. The first line that begins with either a tab character or six
2955spaces determines the choice. If the scan fails (for example, if the
2956buffer is new and therefore empty), the value of
2957@code{fortran-tab-mode-default} (@code{nil} for fixed format, and
2958non-@code{nil} for tab format) is used. @samp{/t} in the mode line
2959indicates tab format is selected. Fortran mode sets the value of
2960@code{indent-tabs-mode} accordingly.
2961
2962 If the text on a line starts with the Fortran continuation marker
2963@samp{$}, or if it begins with any non-whitespace character in column
29645, Fortran mode treats it as a continuation line. When you indent a
2965continuation line with @key{TAB}, it converts the line to the current
2966continuation style. When you split a Fortran statement with
2967@kbd{C-M-j}, the continuation marker on the newline is created according
2968to the continuation style.
2969
2970 The setting of continuation style affects several other aspects of
2971editing in Fortran mode. In fixed format mode, the minimum column
2972number for the body of a statement is 6. Lines inside of Fortran
2973blocks that are indented to larger column numbers always use only the
2974space character for whitespace. In tab format mode, the minimum
2975column number for the statement body is 8, and the whitespace before
2976column 8 must always consist of one tab character.
2977
2978@node ForIndent Num
2979@subsection Line Numbers
2980
2981 If a number is the first non-whitespace in the line, Fortran
2982indentation assumes it is a line number and moves it to columns 0
2983through 4. (Columns always count from 0 in GNU Emacs.)
2984
2985@vindex fortran-line-number-indent
2986 Line numbers of four digits or less are normally indented one space.
2987The variable @code{fortran-line-number-indent} controls this; it
2988specifies the maximum indentation a line number can have. The default
2989value of the variable is 1. Fortran mode tries to prevent line number
2990digits passing column 4, reducing the indentation below the specified
2991maximum if necessary. If @code{fortran-line-number-indent} has the
2992value 5, line numbers are right-justified to end in column 4.
2993
2994@vindex fortran-electric-line-number
2995 Simply inserting a line number is enough to indent it according to
2996these rules. As each digit is inserted, the indentation is recomputed.
2997To turn off this feature, set the variable
2998@code{fortran-electric-line-number} to @code{nil}.
2999
3000
3001@node ForIndent Conv
3002@subsection Syntactic Conventions
3003
3004 Fortran mode assumes that you follow certain conventions that simplify
3005the task of understanding a Fortran program well enough to indent it
3006properly:
3007
3008@itemize @bullet
3009@item
3010Two nested @samp{do} loops never share a @samp{continue} statement.
3011
3012@item
3013Fortran keywords such as @samp{if}, @samp{else}, @samp{then}, @samp{do}
3014and others are written without embedded whitespace or line breaks.
3015
3016Fortran compilers generally ignore whitespace outside of string
3017constants, but Fortran mode does not recognize these keywords if they
3018are not contiguous. Constructs such as @samp{else if} or @samp{end do}
3019are acceptable, but the second word should be on the same line as the
3020first and not on a continuation line.
3021@end itemize
3022
3023@noindent
3024If you fail to follow these conventions, the indentation commands may
3025indent some lines unaesthetically. However, a correct Fortran program
3026retains its meaning when reindented even if the conventions are not
3027followed.
3028
3029@node ForIndent Vars
3030@subsection Variables for Fortran Indentation
3031
3032@vindex fortran-do-indent
3033@vindex fortran-if-indent
3034@vindex fortran-structure-indent
3035@vindex fortran-continuation-indent
3036@vindex fortran-check-all-num@dots{}
3037@vindex fortran-minimum-statement-indent@dots{}
3038 Several additional variables control how Fortran indentation works:
3039
3040@table @code
3041@item fortran-do-indent
3042Extra indentation within each level of @samp{do} statement (default 3).
3043
3044@item fortran-if-indent
3045Extra indentation within each level of @samp{if}, @samp{select case}, or
3046@samp{where} statements (default 3).
3047
3048@item fortran-structure-indent
3049Extra indentation within each level of @samp{structure}, @samp{union},
3050@samp{map}, or @samp{interface} statements (default 3).
3051
3052@item fortran-continuation-indent
3053Extra indentation for bodies of continuation lines (default 5).
3054
3055@item fortran-check-all-num-for-matching-do
3056In Fortran77, a numbered @samp{do} statement is ended by any statement
3057with a matching line number. It is common (but not compulsory) to use a
3058@samp{continue} statement for this purpose. If this variable has a
3059non-@code{nil} value, indenting any numbered statement must check for a
3060@samp{do} that ends there. If you always end @samp{do} statements with
3061a @samp{continue} line (or if you use the more modern @samp{enddo}),
3062then you can speed up indentation by setting this variable to
3063@code{nil}. The default is @code{nil}.
3064
3065@item fortran-blink-matching-if
3066If this is @code{t}, indenting an @samp{endif} (or @samp{enddo}
3067statement moves the cursor momentarily to the matching @samp{if} (or
3068@samp{do}) statement to show where it is. The default is @code{nil}.
3069
3070@item fortran-minimum-statement-indent-fixed
3071Minimum indentation for Fortran statements when using fixed format
3072continuation line style. Statement bodies are never indented less than
3073this much. The default is 6.
3074
3075@item fortran-minimum-statement-indent-tab
3076Minimum indentation for Fortran statements for tab format continuation line
3077style. Statement bodies are never indented less than this much. The
3078default is 8.
3079@end table
3080
3081The variables controlling the indentation of comments are described in
3082the following section.
3083
3084@node Fortran Comments
3085@section Fortran Comments
3086
3087 The usual Emacs comment commands assume that a comment can follow a
3088line of code. In Fortran77, the standard comment syntax requires an
3089entire line to be just a comment. Therefore, Fortran mode replaces the
3090standard Emacs comment commands and defines some new variables.
3091
3092@vindex fortran-comment-line-start
3093 Fortran mode can also handle the Fortran90 comment syntax where comments
3094start with @samp{!} and can follow other text. Because only some Fortran77
3095compilers accept this syntax, Fortran mode will not insert such comments
3096unless you have said in advance to do so. To do this, set the variable
3097@code{fortran-comment-line-start} to @samp{"!"}.
3098
3099@table @kbd
3100@item M-;
3101Align comment or insert new comment (@code{fortran-indent-comment}).
3102
3103@item C-x ;
3104Applies to nonstandard @samp{!} comments only.
3105
3106@item C-c ;
3107Turn all lines of the region into comments, or (with argument) turn them back
3108into real code (@code{fortran-comment-region}).
3109@end table
3110
3111@findex fortran-indent-comment
3112 @kbd{M-;} in Fortran mode is redefined as the command
3113@code{fortran-indent-comment}. Like the usual @kbd{M-;} command, this
3114recognizes any kind of existing comment and aligns its text appropriately;
3115if there is no existing comment, a comment is inserted and aligned. But
3116inserting and aligning comments are not the same in Fortran mode as in
3117other modes.
3118
3119 When a new comment must be inserted, if the current line is blank, a
3120full-line comment is inserted. On a non-blank line, a nonstandard @samp{!}
3121comment is inserted if you have said you want to use them. Otherwise a
3122full-line comment is inserted on a new line before the current line.
3123
3124 Nonstandard @samp{!} comments are aligned like comments in other
3125languages, but full-line comments are different. In a standard full-line
3126comment, the comment delimiter itself must always appear in column zero.
3127What can be aligned is the text within the comment. You can choose from
3128three styles of alignment by setting the variable
3129@code{fortran-comment-indent-style} to one of these values:
3130
3131@vindex fortran-comment-indent-style
3132@vindex fortran-comment-line-extra-indent
3133@table @code
3134@item fixed
3135Align the text at a fixed column, which is the sum of
3136@code{fortran-comment-line-extra-indent} and the minimum statement
3137indentation. This is the default.
3138
3139The minimum statement indentation is
3140@code{fortran-minimum-statement-indent-fixed} for fixed format
3141continuation line style and @code{fortran-minimum-statement-indent-tab}
3142for tab format style.
3143
3144@item relative
3145Align the text as if it were a line of code, but with an additional
3146@code{fortran-comment-line-extra-indent} columns of indentation.
3147
3148@item nil
3149Don't move text in full-line comments automatically.
3150@end table
3151
3152@vindex fortran-comment-indent-char
3153 In addition, you can specify the character to be used to indent within
3154full-line comments by setting the variable
3155@code{fortran-comment-indent-char} to the single-character string you want
3156to use.
3157
3158@vindex fortran-directive-re
3159 Compiler directive lines, or preprocessor lines, have much the same
3160appearance as comment lines. It is important, though, that such lines
3161never be indented at all, no matter what the value of
3162@code{fortran-comment-indent-style}. The variable
3163@code{fortran-directive-re} is a regular expression that specifies which
3164lines are directives. Matching lines are never indented, and receive
3165distinctive font-locking.
3166
3167 The normal Emacs comment command @kbd{C-x ;} has not been redefined. If
3168you use @samp{!} comments, this command can be used with them. Otherwise
3169it is useless in Fortran mode.
3170
3171@kindex C-c ; @r{(Fortran mode)}
3172@findex fortran-comment-region
3173@vindex fortran-comment-region
3174 The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the
3175lines of the region into comments by inserting the string @samp{C$$$} at
3176the front of each one. With a numeric argument, it turns the region
3177back into live code by deleting @samp{C$$$} from the front of each line
3178in it. The string used for these comments can be controlled by setting
3179the variable @code{fortran-comment-region}. Note that here we have an
3180example of a command and a variable with the same name; these two uses
3181of the name never conflict because in Lisp and in Emacs it is always
3182clear from the context which one is meant.
3183
3184@node Fortran Autofill
3185@section Auto Fill in Fortran Mode
3186
3187 Fortran mode has specialized support for Auto Fill mode, which is a
3188minor mode that automatically splits statements as you insert them
3189when they become too wide. Splitting a statement involves making
3190continuation lines using @code{fortran-continuation-string}
3191(@pxref{ForIndent Cont}). This splitting happens when you type
3192@key{SPC}, @key{RET}, or @key{TAB}, and also in the Fortran
3193indentation commands. You activate Auto Fill in Fortran mode in the
3194normal way. @xref{Auto Fill,,, emacs, the Emacs Manual}.
3195
3196@vindex fortran-break-before-delimiters
3197 Auto Fill breaks lines at spaces or delimiters when the lines get
3198longer than the desired width (the value of @code{fill-column}). The
3199delimiters (besides whitespace) that Auto Fill can break at are
3200@samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, @samp{<}, @samp{>},
3201and @samp{,}. The line break comes after the delimiter if the
3202variable @code{fortran-break-before-delimiters} is @code{nil}.
3203Otherwise (and by default), the break comes before the delimiter.
3204
3205 To enable Auto Fill in all Fortran buffers, add
3206@code{turn-on-auto-fill} to @code{fortran-mode-hook}. @xref{Hooks,,,
3207emacs, the Emacs Manual}.
3208
3209@node Fortran Columns
3210@section Checking Columns in Fortran
3211
3212@table @kbd
3213@item C-c C-r
3214Display a ``column ruler'' momentarily above the current line
3215(@code{fortran-column-ruler}).
3216@item C-c C-w
3217Split the current window horizontally temporarily so that it is 72
3218columns wide (@code{fortran-window-create-momentarily}). This may
3219help you avoid making lines longer than the 72-character limit that
3220some Fortran compilers impose.
3221@item C-u C-c C-w
3222Split the current window horizontally so that it is 72 columns wide
3223(@code{fortran-window-create}). You can then continue editing.
3224@item M-x fortran-strip-sequence-nos
3225Delete all text in column 72 and beyond.
3226@end table
3227
3228@kindex C-c C-r @r{(Fortran mode)}
3229@findex fortran-column-ruler
3230 The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column
3231ruler momentarily above the current line. The comment ruler is two lines
3232of text that show you the locations of columns with special significance in
3233Fortran programs. Square brackets show the limits of the columns for line
3234numbers, and curly brackets show the limits of the columns for the
3235statement body. Column numbers appear above them.
3236
3237 Note that the column numbers count from zero, as always in GNU Emacs.
3238As a result, the numbers may be one less than those you are familiar
3239with; but the positions they indicate in the line are standard for
3240Fortran.
3241
3242@vindex fortran-column-ruler-fixed
3243@vindex fortran-column-ruler-tabs
3244 The text used to display the column ruler depends on the value of the
3245variable @code{indent-tabs-mode}. If @code{indent-tabs-mode} is
3246@code{nil}, then the value of the variable
3247@code{fortran-column-ruler-fixed} is used as the column ruler.
3248Otherwise, the value of the variable @code{fortran-column-ruler-tab} is
3249displayed. By changing these variables, you can change the column ruler
3250display.
3251
3252@kindex C-c C-w @r{(Fortran mode)}
3253@findex fortran-window-create-momentarily
3254 @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily
3255splits the current window horizontally, making a window 72 columns
3256wide, so you can see any lines that are too long. Type a space to
3257restore the normal width.
3258
3259@kindex C-u C-c C-w @r{(Fortran mode)}
3260@findex fortran-window-create
3261 You can also split the window horizontally and continue editing with
3262the split in place. To do this, use @kbd{C-u C-c C-w} (@code{M-x
3263fortran-window-create}). By editing in this window you can
3264immediately see when you make a line too wide to be correct Fortran.
3265
3266@findex fortran-strip-sequence-nos
3267 The command @kbd{M-x fortran-strip-sequence-nos} deletes all text in
3268column 72 and beyond, on all lines in the current buffer. This is the
3269easiest way to get rid of old sequence numbers.
3270
3271@node Fortran Abbrev
3272@section Fortran Keyword Abbrevs
3273
3274 Fortran mode provides many built-in abbrevs for common keywords and
3275declarations. These are the same sort of abbrev that you can define
3276yourself. To use them, you must turn on Abbrev mode.
3277@xref{Abbrevs,,, emacs, the Emacs Manual}.
3278
3279 The built-in abbrevs are unusual in one way: they all start with a
3280semicolon. You cannot normally use semicolon in an abbrev, but Fortran
3281mode makes this possible by changing the syntax of semicolon to ``word
3282constituent.''
3283
3284 For example, one built-in Fortran abbrev is @samp{;c} for
3285@samp{continue}. If you insert @samp{;c} and then insert a punctuation
3286character such as a space or a newline, the @samp{;c} expands automatically
3287to @samp{continue}, provided Abbrev mode is enabled.@refill
3288
3289 Type @samp{;?} or @samp{;C-h} to display a list of all the built-in
3290Fortran abbrevs and what they stand for.
3291
3292
3293@node MS-DOS
3294@chapter Emacs and MS-DOS
3295@cindex MS-DOG
3296@cindex MS-DOS peculiarities
3297
3298 This section briefly describes the peculiarities of using Emacs on
3299the MS-DOS ``operating system'' (also known as ``MS-DOG'').
3300Information about Emacs and Microsoft's current operating system
3301Windows (also known as ``Losedows) is in the main Emacs manual
3302(@pxref{Microsoft Systems,,, emacs, the Emacs Manual}).
3303
3304 If you build Emacs for MS-DOS, the binary will also run on Windows
33053.X, Windows NT, Windows 9X/ME, Windows 2000, or OS/2 as a DOS
3306application; all of this chapter applies for all of those systems, if
3307you use an Emacs that was built for MS-DOS.
3308
3309 @xref{Text and Binary,,,emacs, the Emacs Manual}, for information
3310about Emacs' special handling of text files under MS-DOS (and
3311Windows).
3312
3313@menu
3314* Keyboard: MS-DOS Keyboard. Keyboard conventions on MS-DOS.
3315* Mouse: MS-DOS Mouse. Mouse conventions on MS-DOS.
3316* Display: MS-DOS Display. Fonts, frames and display size on MS-DOS.
3317* Files: MS-DOS File Names. File name conventions on MS-DOS.
3318* Printing: MS-DOS Printing. Printing specifics on MS-DOS.
3319* I18N: MS-DOS and MULE. Support for internationalization on MS-DOS.
3320* Processes: MS-DOS Processes. Running subprocesses on MS-DOS.
3321@end menu
3322
3323@node MS-DOS Keyboard
3324@section Keyboard Usage on MS-DOS
3325
3326@kindex DEL @r{(MS-DOS)}
3327@kindex BS @r{(MS-DOS)}
3328 The key that is called @key{DEL} in Emacs (because that's how it is
3329designated on most workstations) is known as @key{BS} (backspace) on a
3330PC. That is why the PC-specific terminal initialization remaps the
3331@key{BS} key to act as @key{DEL}; the @key{DELETE} key is remapped to act
3332as @kbd{C-d} for the same reasons.
3333
3334@kindex C-g @r{(MS-DOS)}
3335@kindex C-BREAK @r{(MS-DOS)}
3336@cindex quitting on MS-DOS
3337 Emacs built for MS-DOS recognizes @kbd{C-@key{BREAK}} as a quit
3338character, just like @kbd{C-g}. This is because Emacs cannot detect
3339that you have typed @kbd{C-g} until it is ready for more input. As a
3340consequence, you cannot use @kbd{C-g} to stop a running command
3341(@pxref{Quitting,,,emacs, the Emacs Manual}). By contrast,
3342@kbd{C-@key{BREAK}} @emph{is} detected as soon as you type it (as
3343@kbd{C-g} is on other systems), so it can be used to stop a running
3344command and for emergency escape (@pxref{Emergency Escape,,,emacs, the
3345Emacs Manual}).
3346
3347@cindex Meta (under MS-DOS)
3348@cindex Hyper (under MS-DOS)
3349@cindex Super (under MS-DOS)
3350@vindex dos-super-key
3351@vindex dos-hyper-key
3352 The PC keyboard maps use the left @key{ALT} key as the @key{META} key.
3353You have two choices for emulating the @key{SUPER} and @key{HYPER} keys:
3354choose either the right @key{CTRL} key or the right @key{ALT} key by
3355setting the variables @code{dos-hyper-key} and @code{dos-super-key} to 1
3356or 2 respectively. If neither @code{dos-super-key} nor
3357@code{dos-hyper-key} is 1, then by default the right @key{ALT} key is
3358also mapped to the @key{META} key. However, if the MS-DOS international
3359keyboard support program @file{KEYB.COM} is installed, Emacs will
3360@emph{not} map the right @key{ALT} to @key{META}, since it is used for
3361accessing characters like @kbd{~} and @kbd{@@} on non-US keyboard
3362layouts; in this case, you may only use the left @key{ALT} as @key{META}
3363key.
3364
3365@kindex C-j @r{(MS-DOS)}
3366@vindex dos-keypad-mode
3367 The variable @code{dos-keypad-mode} is a flag variable that controls
3368what key codes are returned by keys in the numeric keypad. You can also
3369define the keypad @key{ENTER} key to act like @kbd{C-j}, by putting the
3370following line into your @file{_emacs} file:
3371
3372@smallexample
3373;; @r{Make the @key{ENTER} key from the numeric keypad act as @kbd{C-j}.}
3374(define-key function-key-map [kp-enter] [?\C-j])
3375@end smallexample
3376
3377@node MS-DOS Mouse
3378@section Mouse Usage on MS-DOS
3379
3380@cindex mouse support under MS-DOS
3381 Emacs on MS-DOS supports a mouse (on the default terminal only).
3382The mouse commands work as documented, including those that use menus
3383and the menu bar (@pxref{Menu Bar,,,emacs, the Emacs Manual}). Scroll
3384bars don't work in MS-DOS Emacs. PC mice usually have only two
3385buttons; these act as @kbd{Mouse-1} and @kbd{Mouse-2}, but if you
3386press both of them together, that has the effect of @kbd{Mouse-3}. If
3387the mouse does have 3 buttons, Emacs detects that at startup, and all
3388the 3 buttons function normally, as on X.
3389
3390 Help strings for menu-bar and pop-up menus are displayed in the echo
3391area when the mouse pointer moves across the menu items. Highlighting
3392of mouse-sensitive text (@pxref{Mouse References,,,emacs, the Emacs
3393Manual}) is also supported.
3394
3395@cindex mouse, set number of buttons
3396@findex msdos-set-mouse-buttons
3397 Some versions of mouse drivers don't report the number of mouse
3398buttons correctly. For example, mice with a wheel report that they
3399have 3 buttons, but only 2 of them are passed to Emacs; the clicks on
3400the wheel, which serves as the middle button, are not passed. In
3401these cases, you can use the @kbd{M-x msdos-set-mouse-buttons} command
3402to tell Emacs how many mouse buttons to expect. You could make such a
3403setting permanent by adding this fragment to your @file{_emacs} init
3404file:
3405
3406@example
3407;; @r{Treat the mouse like a 2-button mouse.}
3408(msdos-set-mouse-buttons 2)
3409@end example
3410
3411@cindex Windows clipboard support
3412 Emacs built for MS-DOS supports clipboard operations when it runs on
3413Windows. Commands that put text on the kill ring, or yank text from
3414the ring, check the Windows clipboard first, just as Emacs does on the
3415X Window System (@pxref{Mouse Commands,,,emacs, the Emacs Manual}).
3416Only the primary selection and the cut buffer are supported by MS-DOS
3417Emacs on Windows; the secondary selection always appears as empty.
3418
3419 Due to the way clipboard access is implemented by Windows, the
3420length of text you can put into the clipboard is limited by the amount
3421of free DOS memory that is available to Emacs. Usually, up to 620KB of
3422text can be put into the clipboard, but this limit depends on the system
3423configuration and is lower if you run Emacs as a subprocess of
3424another program. If the killed text does not fit, Emacs outputs a
3425message saying so, and does not put the text into the clipboard.
3426
3427 Null characters also cannot be put into the Windows clipboard. If the
3428killed text includes null characters, Emacs does not put such text into
3429the clipboard, and displays in the echo area a message to that effect.
3430
3431@vindex dos-display-scancodes
3432 The variable @code{dos-display-scancodes}, when non-@code{nil},
3433directs Emacs to display the @acronym{ASCII} value and the keyboard scan code of
3434each keystroke; this feature serves as a complement to the
3435@code{view-lossage} command, for debugging.
3436
3437@node MS-DOS Display
3438@section Display on MS-DOS
3439@cindex faces under MS-DOS
3440@cindex fonts, emulating under MS-DOS
3441
3442 Display on MS-DOS cannot use font variants, like bold or italic, but
3443it does support multiple faces, each of which can specify a foreground
3444and a background color. Therefore, you can get the full functionality
3445of Emacs packages that use fonts (such as @code{font-lock}, Enriched
3446Text mode, and others) by defining the relevant faces to use different
3447colors. Use the @code{list-colors-display} command (@pxref{Frame
3448Parameters,,,emacs, the Emacs Manual}) and the
3449@code{list-faces-display} command (@pxref{Faces,,,emacs, the Emacs
3450Manual}) to see what colors and faces are available and what they look
3451like.
3452
3453 @xref{MS-DOS and MULE}, later in this chapter, for information on
3454how Emacs displays glyphs and characters that aren't supported by the
3455native font built into the DOS display.
3456
3457@cindex cursor shape on MS-DOS
3458 When Emacs starts, it changes the cursor shape to a solid box. This
3459is for compatibility with other systems, where the box cursor is the
3460default in Emacs. This default shape can be changed to a bar by
3461specifying the @code{cursor-type} parameter in the variable
3462@code{default-frame-alist} (@pxref{Creating Frames,,,emacs, the Emacs
3463Manual}). The MS-DOS terminal doesn't support a vertical-bar cursor,
3464so the bar cursor is horizontal, and the @code{@var{width}} parameter,
3465if specified by the frame parameters, actually determines its height.
3466For this reason, the @code{bar} and @code{hbar} cursor types produce
3467the same effect on MS-DOS. As an extension, the bar cursor
3468specification can include the starting scan line of the cursor as well
3469as its width, like this:
3470
3471@example
3472 '(cursor-type bar @var{width} . @var{start})
3473@end example
3474
3475@noindent
3476In addition, if the @var{width} parameter is negative, the cursor bar
3477begins at the top of the character cell.
3478
3479@cindex frames on MS-DOS
3480 The MS-DOS terminal can only display a single frame at a time. The
3481Emacs frame facilities work on MS-DOS much as they do on text-only
3482terminals (@pxref{Frames,,,emacs, the Emacs Manual}). When you run
3483Emacs from a DOS window on MS-Windows, you can make the visible frame
3484smaller than the full screen, but Emacs still cannot display more than
3485a single frame at a time.
3486
3487@cindex frame size under MS-DOS
3488@findex mode4350
3489@findex mode25
3490 The @code{mode4350} command switches the display to 43 or 50
3491lines, depending on your hardware; the @code{mode25} command switches
3492to the default 80x25 screen size.
3493
3494 By default, Emacs only knows how to set screen sizes of 80 columns by
349525, 28, 35, 40, 43 or 50 rows. However, if your video adapter has
3496special video modes that will switch the display to other sizes, you can
3497have Emacs support those too. When you ask Emacs to switch the frame to
3498@var{n} rows by @var{m} columns dimensions, it checks if there is a
3499variable called @code{screen-dimensions-@var{n}x@var{m}}, and if so,
3500uses its value (which must be an integer) as the video mode to switch
3501to. (Emacs switches to that video mode by calling the BIOS @code{Set
3502Video Mode} function with the value of
3503@code{screen-dimensions-@var{n}x@var{m}} in the @code{AL} register.)
3504For example, suppose your adapter will switch to 66x80 dimensions when
3505put into video mode 85. Then you can make Emacs support this screen
3506size by putting the following into your @file{_emacs} file:
3507
3508@example
3509(setq screen-dimensions-66x80 85)
3510@end example
3511
3512 Since Emacs on MS-DOS can only set the frame size to specific
3513supported dimensions, it cannot honor every possible frame resizing
3514request. When an unsupported size is requested, Emacs chooses the next
3515larger supported size beyond the specified size. For example, if you
3516ask for 36x80 frame, you will get 40x80 instead.
3517
3518 The variables @code{screen-dimensions-@var{n}x@var{m}} are used only
3519when they exactly match the specified size; the search for the next
3520larger supported size ignores them. In the above example, even if your
3521VGA supports 38x80 dimensions and you define a variable
3522@code{screen-dimensions-38x80} with a suitable value, you will still get
352340x80 screen when you ask for a 36x80 frame. If you want to get the
352438x80 size in this case, you can do it by setting the variable named
3525@code{screen-dimensions-36x80} with the same video mode value as
3526@code{screen-dimensions-38x80}.
3527
3528 Changing frame dimensions on MS-DOS has the effect of changing all the
3529other frames to the new dimensions.
3530
3531@node MS-DOS File Names
3532@section File Names on MS-DOS
3533@cindex file names under MS-DOS
3534@cindex init file, default name under MS-DOS
3535
3536 On MS-DOS, file names are case-insensitive and limited to eight
3537characters, plus optionally a period and three more characters. Emacs
3538knows enough about these limitations to handle file names that were
3539meant for other operating systems. For instance, leading dots
3540@samp{.} in file names are invalid in MS-DOS, so Emacs transparently
3541converts them to underscores @samp{_}; thus your default init file
3542(@pxref{Init File,,,emacs, the Emacs Manual}) is called @file{_emacs}
3543on MS-DOS. Excess characters before or after the period are generally
3544ignored by MS-DOS itself; thus, if you visit the file
3545@file{LongFileName.EvenLongerExtension}, you will silently get
3546@file{longfile.eve}, but Emacs will still display the long file name
3547on the mode line. Other than that, it's up to you to specify file
3548names which are valid under MS-DOS; the transparent conversion as
3549described above only works on file names built into Emacs.
3550
3551@cindex backup file names on MS-DOS
3552 The above restrictions on the file names on MS-DOS make it almost
3553impossible to construct the name of a backup file (@pxref{Backup
3554Names,,,emacs, the Emacs Manual}) without losing some of the original
3555file name characters. For example, the name of a backup file for
3556@file{docs.txt} is @file{docs.tx~} even if single backup is used.
3557
3558@cindex file names under Windows 95/NT
3559@cindex long file names in DOS box under Windows 95/NT
3560 If you run Emacs as a DOS application under Windows 9X, Windows ME, or
3561Windows 2000, you can turn on support for long file names. If you do
3562that, Emacs doesn't truncate file names or convert them to lower case;
3563instead, it uses the file names that you specify, verbatim. To enable
3564long file name support, set the environment variable @env{LFN} to
3565@samp{y} before starting Emacs. Unfortunately, Windows NT doesn't allow
3566DOS programs to access long file names, so Emacs built for MS-DOS will
3567only see their short 8+3 aliases.
3568
3569@cindex @env{HOME} directory under MS-DOS
3570 MS-DOS has no notion of home directory, so Emacs on MS-DOS pretends
3571that the directory where it is installed is the value of the @env{HOME}
3572environment variable. That is, if your Emacs binary,
3573@file{emacs.exe}, is in the directory @file{c:/utils/emacs/bin}, then
3574Emacs acts as if @env{HOME} were set to @samp{c:/utils/emacs}. In
3575particular, that is where Emacs looks for the init file @file{_emacs}.
3576With this in mind, you can use @samp{~} in file names as an alias for
3577the home directory, as you would on GNU or Unix. You can also set
3578@env{HOME} variable in the environment before starting Emacs; its
3579value will then override the above default behavior.
3580
3581 Emacs on MS-DOS handles the directory name @file{/dev} specially,
3582because of a feature in the emulator libraries of DJGPP that pretends
3583I/O devices have names in that directory. We recommend that you avoid
3584using an actual directory named @file{/dev} on any disk.
3585
3586@node MS-DOS Printing
3587@section Printing and MS-DOS
3588
3589 Printing commands, such as @code{lpr-buffer}
3590(@pxref{Printing,,,emacs, the Emacs Manual}) and
3591@code{ps-print-buffer} (@pxref{PostScript,,,emacs, the Emacs Manual})
3592can work on MS-DOS by sending the output to one of the printer ports,
3593if a Posix-style @code{lpr} program is unavailable. The same Emacs
3594variables control printing on all systems, but in some cases they have
3595different default values on MS-DOS.
3596
3597@xref{MS-Windows Printing,,,emacs, the Emacs Manual}, for details.
3598
3599 Some printers expect DOS codepage encoding of non-@acronym{ASCII} text, even
3600though they are connected to a Windows machine which uses a different
3601encoding for the same locale. For example, in the Latin-1 locale, DOS
3602uses codepage 850 whereas Windows uses codepage 1252. @xref{MS-DOS and
3603MULE}. When you print to such printers from Windows, you can use the
3604@kbd{C-x RET c} (@code{universal-coding-system-argument}) command before
3605@kbd{M-x lpr-buffer}; Emacs will then convert the text to the DOS
3606codepage that you specify. For example, @kbd{C-x RET c cp850-dos RET
3607M-x lpr-region RET} will print the region while converting it to the
3608codepage 850 encoding. You may need to create the @code{cp@var{nnn}}
3609coding system with @kbd{M-x codepage-setup}.
3610
3611@vindex dos-printer
3612@vindex dos-ps-printer
3613 For backwards compatibility, the value of @code{dos-printer}
3614(@code{dos-ps-printer}), if it has a value, overrides the value of
3615@code{printer-name} (@code{ps-printer-name}), on MS-DOS.
3616
3617
3618@node MS-DOS and MULE
3619@section International Support on MS-DOS
3620@cindex international support @r{(MS-DOS)}
3621
3622 Emacs on MS-DOS supports the same international character sets as it
3623does on GNU, Unix and other platforms (@pxref{International,,,emacs,
3624the Emacs Manual}), including coding systems for converting between
3625the different character sets. However, due to incompatibilities
3626between MS-DOS/MS-Windows and other systems, there are several
3627DOS-specific aspects of this support that you should be aware of.
3628This section describes these aspects.
3629
3630 The description below is largely specific to the MS-DOS port of
3631Emacs, especially where it talks about practical implications for
3632Emacs users. For other operating systems, see the @file{code-pages.el}
3633package, which implements support for MS-DOS- and MS-Windows-specific
3634encodings for all platforms other than MS-DOS.
3635
3636@table @kbd
3637@item M-x dos-codepage-setup
3638Set up Emacs display and coding systems as appropriate for the current
3639DOS codepage.
3640
3641@item M-x codepage-setup
3642Create a coding system for a certain DOS codepage.
3643@end table
3644
3645@cindex codepage, MS-DOS
3646@cindex DOS codepages
3647 MS-DOS is designed to support one character set of 256 characters at
3648any given time, but gives you a variety of character sets to choose
3649from. The alternative character sets are known as @dfn{DOS codepages}.
3650Each codepage includes all 128 @acronym{ASCII} characters, but the other 128
3651characters (codes 128 through 255) vary from one codepage to another.
3652Each DOS codepage is identified by a 3-digit number, such as 850, 862,
3653etc.
3654
3655 In contrast to X, which lets you use several fonts at the same time,
3656MS-DOS normally doesn't allow use of several codepages in a single
3657session. MS-DOS was designed to load a single codepage at system
3658startup, and require you to reboot in order to change
3659it@footnote{Normally, one particular codepage is burnt into the
3660display memory, while other codepages can be installed by modifying
3661system configuration files, such as @file{CONFIG.SYS}, and rebooting.
3662While there is third-party software that allows changing the codepage
3663without rebooting, we describe here how a stock MS-DOS system
3664behaves.}. Much the same limitation applies when you run DOS
3665executables on other systems such as MS-Windows.
3666
3667@cindex unibyte operation @r{(MS-DOS)}
3668 If you invoke Emacs on MS-DOS with the @samp{--unibyte} option
3669(@pxref{Initial Options,,,emacs, the Emacs Manual}), Emacs does not
3670perform any conversion of non-@acronym{ASCII} characters. Instead, it
3671reads and writes any non-@acronym{ASCII} characters verbatim, and
3672sends their 8-bit codes to the display verbatim. Thus, unibyte Emacs
3673on MS-DOS supports the current codepage, whatever it may be, but
3674cannot even represent any other characters.
3675
3676@vindex dos-codepage
3677 For multibyte operation on MS-DOS, Emacs needs to know which
3678characters the chosen DOS codepage can display. So it queries the
3679system shortly after startup to get the chosen codepage number, and
3680stores the number in the variable @code{dos-codepage}. Some systems
3681return the default value 437 for the current codepage, even though the
3682actual codepage is different. (This typically happens when you use the
3683codepage built into the display hardware.) You can specify a different
3684codepage for Emacs to use by setting the variable @code{dos-codepage} in
3685your init file.
3686
3687@cindex language environment, automatic selection on @r{MS-DOS}
3688 Multibyte Emacs supports only certain DOS codepages: those which can
3689display Far-Eastern scripts, like the Japanese codepage 932, and those
3690that encode a single ISO 8859 character set.
3691
3692 The Far-Eastern codepages can directly display one of the MULE
3693character sets for these countries, so Emacs simply sets up to use the
3694appropriate terminal coding system that is supported by the codepage.
3695The special features described in the rest of this section mostly
3696pertain to codepages that encode ISO 8859 character sets.
3697
3698 For the codepages which correspond to one of the ISO character sets,
3699Emacs knows the character set name based on the codepage number. Emacs
3700automatically creates a coding system to support reading and writing
3701files that use the current codepage, and uses this coding system by
3702default. The name of this coding system is @code{cp@var{nnn}}, where
3703@var{nnn} is the codepage number.@footnote{The standard Emacs coding
3704systems for ISO 8859 are not quite right for the purpose, because
3705typically the DOS codepage does not match the standard ISO character
3706codes. For example, the letter @samp{@,{c}} (@samp{c} with cedilla) has
3707code 231 in the standard Latin-1 character set, but the corresponding
3708DOS codepage 850 uses code 135 for this glyph.}
3709
3710@cindex mode line @r{(MS-DOS)}
3711 All the @code{cp@var{nnn}} coding systems use the letter @samp{D}
3712(for ``DOS'') as their mode-line mnemonic. Since both the terminal
3713coding system and the default coding system for file I/O are set to
3714the proper @code{cp@var{nnn}} coding system at startup, it is normal
3715for the mode line on MS-DOS to begin with @samp{-DD\-}. @xref{Mode
3716Line,,,emacs, the Emacs Manual}. Far-Eastern DOS terminals do not use
3717the @code{cp@var{nnn}} coding systems, and thus their initial mode
3718line looks like the Emacs default.
3719
3720 Since the codepage number also indicates which script you are using,
3721Emacs automatically runs @code{set-language-environment} to select the
3722language environment for that script (@pxref{Language
3723Environments,,,emacs, the Emacs Manual}).
3724
3725 If a buffer contains a character belonging to some other ISO 8859
3726character set, not the one that the chosen DOS codepage supports, Emacs
3727displays it using a sequence of @acronym{ASCII} characters. For example, if the
3728current codepage doesn't have a glyph for the letter @samp{@`o} (small
3729@samp{o} with a grave accent), it is displayed as @samp{@{`o@}}, where
3730the braces serve as a visual indication that this is a single character.
3731(This may look awkward for some non-Latin characters, such as those from
3732Greek or Hebrew alphabets, but it is still readable by a person who
3733knows the language.) Even though the character may occupy several
3734columns on the screen, it is really still just a single character, and
3735all Emacs commands treat it as one.
3736
3737@cindex IBM graphics characters (MS-DOS)
3738@cindex box-drawing characters (MS-DOS)
3739@cindex line-drawing characters (MS-DOS)
3740 Not all characters in DOS codepages correspond to ISO 8859
3741characters---some are used for other purposes, such as box-drawing
3742characters and other graphics. Emacs maps these characters to two
3743special character sets called @code{eight-bit-control} and
3744@code{eight-bit-graphic}, and displays them as their IBM glyphs.
3745However, you should be aware that other systems might display these
3746characters differently, so you should avoid them in text that might be
3747copied to a different operating system, or even to another DOS machine
3748that uses a different codepage.
3749
3750@vindex dos-unsupported-character-glyph
3751 Emacs supports many other characters sets aside from ISO 8859, but it
3752cannot display them on MS-DOS. So if one of these multibyte characters
3753appears in a buffer, Emacs on MS-DOS displays them as specified by the
3754@code{dos-unsupported-character-glyph} variable; by default, this glyph
3755is an empty triangle. Use the @kbd{C-u C-x =} command to display the
3756actual code and character set of such characters. @xref{Position
3757Info,,,emacs, the Emacs Manual}.
3758
3759@findex codepage-setup
3760 By default, Emacs defines a coding system to support the current
3761codepage. To define a coding system for some other codepage (e.g., to
3762visit a file written on a DOS machine in another country), use the
3763@kbd{M-x codepage-setup} command. It prompts for the 3-digit code of
3764the codepage, with completion, then creates the coding system for the
3765specified codepage. You can then use the new coding system to read and
3766write files, but you must specify it explicitly for the file command
3767when you want to use it (@pxref{Text Coding,,,emacs, the Emacs Manual}).
3768
3769 These coding systems are also useful for visiting a file encoded using
3770a DOS codepage, using Emacs running on some other operating system.
3771
3772@cindex MS-Windows codepages
3773 MS-Windows provides its own codepages, which are different from the
3774DOS codepages for the same locale. For example, DOS codepage 850
3775supports the same character set as Windows codepage 1252; DOS codepage
3776855 supports the same character set as Windows codepage 1251, etc.
3777The MS-Windows version of Emacs uses the current codepage for display
3778when invoked with the @samp{-nw} option. Support for codepages in the
3779Windows port of Emacs is part of the @file{code-pages.el} package.
3780
3781@node MS-DOS Processes
3782@section Subprocesses on MS-DOS
3783
3784@cindex compilation under MS-DOS
3785@cindex inferior processes under MS-DOS
3786@findex compile @r{(MS-DOS)}
3787@findex grep @r{(MS-DOS)}
3788 Because MS-DOS is a single-process ``operating system,''
3789asynchronous subprocesses are not available. In particular, Shell
3790mode and its variants do not work. Most Emacs features that use
3791asynchronous subprocesses also don't work on MS-DOS, including
3792Shell mode and GUD. When in doubt, try and see; commands that
3793don't work output an error message saying that asynchronous processes
3794aren't supported.
3795
3796 Compilation under Emacs with @kbd{M-x compile}, searching files with
3797@kbd{M-x grep} and displaying differences between files with @kbd{M-x
3798diff} do work, by running the inferior processes synchronously. This
3799means you cannot do any more editing until the inferior process
3800finishes.
3801
3802 Spell checking also works, by means of special support for synchronous
3803invocation of the @code{ispell} program. This is slower than the
3804asynchronous invocation on other platforms
3805
3806 Instead of the Shell mode, which doesn't work on MS-DOS, you can use
3807the @kbd{M-x eshell} command. This invokes the Eshell package that
3808implements a Posix-like shell entirely in Emacs Lisp.
3809
3810 By contrast, Emacs compiled as a native Windows application
3811@strong{does} support asynchronous subprocesses. @xref{Windows
3812Processes,,,emacs, the Emacs Manual}.
3813
3814@cindex printing under MS-DOS
3815 Printing commands, such as @code{lpr-buffer}
3816(@pxref{Printing,,,emacs, the Emacs Manual}) and
3817@code{ps-print-buffer} (@pxref{PostScript,,,emacs, the Emacs Manual}),
3818work in MS-DOS by sending the output to one of the printer ports.
3819@xref{MS-DOS Printing,,,emacs, the Emacs Manual}.
3820
3821 When you run a subprocess synchronously on MS-DOS, make sure the
3822program terminates and does not try to read keyboard input. If the
3823program does not terminate on its own, you will be unable to terminate
3824it, because MS-DOS provides no general way to terminate a process.
3825Pressing @kbd{C-c} or @kbd{C-@key{BREAK}} might sometimes help in these
3826cases.
3827
3828 Accessing files on other machines is not supported on MS-DOS. Other
3829network-oriented commands such as sending mail, Web browsing, remote
3830login, etc., don't work either, unless network access is built into
3831MS-DOS with some network redirector.
3832
3833@cindex directory listing on MS-DOS
3834@vindex dired-listing-switches @r{(MS-DOS)}
3835 Dired on MS-DOS uses the @code{ls-lisp} package where other
3836platforms use the system @code{ls} command. Therefore, Dired on
3837MS-DOS supports only some of the possible options you can mention in
3838the @code{dired-listing-switches} variable. The options that work are
3839@samp{-A}, @samp{-a}, @samp{-c}, @samp{-i}, @samp{-r}, @samp{-S},
3840@samp{-s}, @samp{-t}, and @samp{-u}.
3841
3842
3843@node Index 117@node Index
3844@unnumbered Index 118@unnumbered Index
3845 119