]> code.delx.au - gnu-emacs/blob - man/emacs-xtra.texi
(Help Mode): Document "C-c C-c".
[gnu-emacs] / man / emacs-xtra.texi
1 \input texinfo @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename ../info/emacs-xtra
4 @settitle Specialized Emacs Features
5 @syncodeindex fn cp
6 @syncodeindex vr cp
7 @syncodeindex ky cp
8 @comment %**end of header
9
10 @copying
11 This manual describes specialized features of Emacs.
12
13 Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
14
15 @quotation
16 Permission is granted to copy, distribute and/or modify this document
17 under the terms of the GNU Free Documentation License, Version 1.2 or
18 any later version published by the Free Software Foundation; with no
19 Invariant Sections, with the Front-Cover texts being ``A GNU
20 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
21 license is included in the section entitled ``GNU Free Documentation
22 License'' in the Emacs manual.
23
24 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
25 this GNU Manual, like GNU software. Copies published by the Free
26 Software Foundation raise funds for GNU development.''
27
28 This document is part of a collection distributed under the GNU Free
29 Documentation License. If you want to distribute this document
30 separately from the collection, you can do so by adding a copy of the
31 license to the document, as described in section 6 of the license.
32 @end quotation
33 @end copying
34
35 @dircategory Emacs
36 @direntry
37 * Emacs-Xtra: (emacs-xtra). Specialized Emacs features.
38 @end direntry
39
40 @titlepage
41 @title Specialized Emacs Features
42 @page
43 @vskip 0pt plus 1filll
44 @insertcopying
45 @end titlepage
46
47 @contents
48
49 @ifnottex
50 @node Top
51 @top Specialized Emacs Features
52
53 @insertcopying
54
55 @end ifnottex
56
57 @menu
58 * Introduction:: What documentation belongs here?
59 * Autorevert:: Auto Reverting non-file buffers.
60 * Subdir switches:: Subdirectory switches in Dired.
61 * Advanced Calendar/Diary Usage:: Advanced Calendar/Diary customization.
62 * Emerge:: A convenient way of merging two versions
63 of a program.
64 * Picture Mode:: Editing pictures made up of characters
65 using the quarter-plane screen model.
66 * Fortran:: Fortran mode and its special features.
67 * Index::
68 @end menu
69
70 @node Introduction
71 @unnumbered Introduction
72
73 This manual contains detailed information about various features that
74 are too specialized to be included in the Emacs manual. It is
75 intended to be readable by anyone having a basic knowledge of Emacs.
76 However, certain sections may be intended for a more specialized
77 audience, such as Elisp authors. This should be clearly pointed out
78 at the beginning of these sections.
79
80 This manual is intended as a complement, rather than an alternative,
81 to other ways to gain a more detailed knowledge of Emacs than the
82 Emacs manual can provide, such as browsing packages using @kbd{C-h p},
83 accessing mode documentation using @kbd{C-h m} and browsing user
84 options using Custom. Also, certain packages, or collections of
85 related features, have their own manuals. The present manual is
86 mainly intended to be a collection of smaller specialized features,
87 too small to get their own manual.
88
89 Sections intended specifically for Elisp programmers can follow the
90 style of the Elisp manual. Other sections should follow the style of
91 the Emacs manual.
92
93 @node Autorevert
94 @chapter Auto Reverting non-file Buffers
95
96 Normally Global Auto Revert Mode only reverts file buffers. There are
97 two ways to auto-revert certain non-file buffers: enabling Auto Revert
98 Mode in those buffers (using @kbd{M-x auto-revert-mode}) and setting
99 @code{global-auto-revert-non-file-buffers} to @code{t}. The latter
100 enables Auto Reverting for all types of buffers for which it is
101 implemented, that is, for the types of buffers listed in the menu
102 below.
103
104 Like file buffers, non-file buffers should normally not revert while
105 you are working on them, or while they contain information that might
106 get lost after reverting. Therefore, they do not revert if they are
107 ``modified''. This can get tricky, because deciding when a non-file
108 buffer should be marked modified is usually more difficult than for
109 file buffers.
110
111 Another tricky detail is that, for efficiency reasons, Auto Revert
112 often does not try to detect all possible changes in the buffer, only
113 changes that are ``major'' or easy to detect. Hence, enabling
114 auto-reverting for a non-file buffer does not always guarantee that
115 all information in the buffer is up to date and does not necessarily
116 make manual reverts useless.
117
118 At the other extreme, certain buffers automatically auto-revert every
119 @code{auto-revert-interval} seconds. (This currently only applies to
120 the Buffer Menu.) In this case, Auto Revert does not print any
121 messages while reverting, even when @code{auto-revert-verbose} is
122 non-@code{nil}.
123
124 The details depend on the particular types of buffers and are
125 explained in the corresponding sections.
126
127 @menu
128 * Auto Reverting the Buffer Menu::
129 * Auto Reverting Dired::
130 * Supporting additional buffers::
131 @end menu
132
133 @node Auto Reverting the Buffer Menu
134 @section Auto Reverting the Buffer Menu
135
136 If auto-reverting of non-file buffers is enabled, the Buffer Menu
137 automatically reverts every @code{auto-revert-interval} seconds,
138 whether there is a need for it or not. (It would probably take longer
139 to check whether there is a need than to actually revert.)
140
141 If the Buffer Menu inappropriately gets marked modified, just revert
142 it manually using @kbd{g} and auto-reverting will resume. However, if
143 you marked certain buffers to get deleted or to be displayed, you have
144 to be careful, because reverting erases all marks. The fact that
145 adding marks sets the buffer's modified flag prevents Auto Revert from
146 automatically erasing the marks.
147
148 @node Auto Reverting Dired
149 @section Auto Reverting Dired buffers
150
151 Auto-reverting Dired buffers currently works on GNU or Unix style
152 operating systems. It may not work satisfactorily on some other
153 systems.
154
155 Dired buffers only auto-revert when the file list of the buffer's main
156 directory changes. They do not auto-revert when information about a
157 particular file changes or when inserted subdirectories change. To be
158 sure that @emph{all} listed information is up to date, you have to
159 manually revert using @kbd{g}, @emph{even} if auto-reverting is
160 enabled in the Dired buffer. Sometimes, you might get the impression
161 that modifying or saving files listed in the main directory actually
162 does cause auto-reverting. This is because making changes to a file,
163 or saving it, very often causes changes in the directory itself, for
164 instance, through backup files or auto-save files. However, this is
165 not guaranteed.
166
167 If the Dired buffer is marked modified and there are no changes you
168 want to protect, then most of the time you can make auto-reverting
169 resume by manually reverting the buffer using @kbd{g}. There is one
170 exception. If you flag or mark files, you can safely revert the
171 buffer. This will not erase the flags or marks (unless the marked
172 file has been deleted, of course). However, the buffer will stay
173 modified, even after reverting, and auto-reverting will not resume.
174 This is because, if you flag or mark files, you may be working on the
175 buffer and you might not want the buffer to change without warning.
176 If you want auto-reverting to resume in the presence of marks and
177 flags, mark the buffer non-modified using @kbd{M-~}. However, adding,
178 deleting or changing marks or flags will mark it modified again.
179
180 Remote Dired buffers are not auto-reverted. Neither are Dired buffers
181 for which you used shell wildcards or file arguments to list only some
182 of the files. @samp{*Find*} and @samp{*Locate*} buffers do not
183 auto-revert either.
184
185 @node Supporting additional buffers
186 @section Adding Support for Auto-Reverting additional Buffers.
187
188 This section is intended for Elisp programmers who would like to add
189 support for auto-reverting new types of buffers.
190
191 To support auto-reverting the buffer must first of all have a
192 @code{revert-buffer-function}. @xref{Definition of
193 revert-buffer-function,, Reverting, elisp, the Emacs Lisp Reference Manual}.
194
195 In addition, it @emph{must} have a @code{buffer-stale-function}.
196
197 @defvar buffer-stale-function
198 The value of this variable is a function to check whether a non-file
199 buffer needs reverting. This should be a function with one optional
200 argument @var{noconfirm}. The function should return non-@code{nil}
201 if the buffer should be reverted. The buffer is current when this
202 function is called.
203
204 While this function is mainly intended for use in auto-reverting, it
205 could be used for other purposes as well. For instance, if
206 auto-reverting is not enabled, it could be used to warn the user that
207 the buffer needs reverting. The idea behind the @var{noconfirm}
208 argument is that it should be @code{t} if the buffer is going to be
209 reverted without asking the user and @code{nil} if the function is
210 just going to be used to warn the user that the buffer is out of date.
211 In particular, for use in auto-reverting, @var{noconfirm} is @code{t}.
212 If the function is only going to be used for auto-reverting, you can
213 ignore the @var{noconfirm} argument.
214
215 If you just want to automatically auto-revert every
216 @code{auto-revert-interval} seconds, use:
217
218 @example
219 (set (make-local-variable 'buffer-stale-function)
220 #'(lambda (&optional noconfirm) 'fast))
221 @end example
222
223 @noindent
224 in the buffer's mode function.
225
226 The special return value @samp{fast} tells the caller that the need
227 for reverting was not checked, but that reverting the buffer is fast.
228 It also tells Auto Revert not to print any revert messages, even if
229 @code{auto-revert-verbose} is non-@code{nil}. This is important, as
230 getting revert messages every @code{auto-revert-interval} seconds can
231 be very annoying. The information provided by this return value could
232 also be useful if the function is consulted for purposes other than
233 auto-reverting.
234 @end defvar
235
236 Once the buffer has a @code{revert-buffer-function} and a
237 @code{buffer-stale-function}, several problems usually remain.
238
239 The buffer will only auto-revert if it is marked unmodified. Hence,
240 you will have to make sure that various functions mark the buffer
241 modified if and only if either the buffer contains information that
242 might be lost by reverting or there is reason to believe that the user
243 might be inconvenienced by auto-reverting, because he is actively
244 working on the buffer. The user can always override this by manually
245 adjusting the modified status of the buffer. To support this, calling
246 the @code{revert-buffer-function} on a buffer that is marked
247 unmodified should always keep the buffer marked unmodified.
248
249 It is important to assure that point does not continuously jump around
250 as a consequence of auto-reverting. Of course, moving point might be
251 inevitable if the buffer radically changes.
252
253 You should make sure that the @code{revert-buffer-function} does not
254 print messages that unnecessarily duplicate Auto Revert's own messages
255 if @code{auto-revert-verbose} is @code{t} and effectively override a
256 @code{nil} value for @code{auto-revert-verbose}. Hence, adapting a
257 mode for auto-reverting often involves getting rid of such messages.
258 This is especially important for buffers that automatically
259 auto-revert every @code{auto-revert-interval} seconds.
260
261 Also, you may want to update the documentation string of
262 @code{global-auto-revert-non-file-buffers}.
263
264 @ifinfo
265 Finally, you should add a node to this chapter's menu. This node
266 @end ifinfo
267 @ifnotinfo
268 Finally, you should add a section to this chapter. This section
269 @end ifnotinfo
270 should at the very least make clear whether enabling auto-reverting
271 for the buffer reliably assures that all information in the buffer is
272 completely up to date (or will be after @code{auto-revert-interval}
273 seconds).
274
275 @node Subdir switches
276 @chapter Subdirectory Switches in Dired
277
278 You can insert subdirectories with specified @code{ls} switches in
279 Dired buffers, using @kbd{C-u i}. You can change the @code{ls}
280 switches of an already inserted subdirectory using @kbd{C-u l}.
281
282 In Emacs versions 22.1 and later, Dired remembers the switches, so
283 that reverting the buffer will not change them back to the main
284 directory's switches. Deleting a subdirectory forgets about its
285 switches.
286
287 Using @code{dired-undo} (usually bound to @kbd{C-_} and @kbd{C-x u})
288 to reinsert or delete subdirectories, that were inserted with explicit
289 switches, can bypass Dired's machinery for remembering (or forgetting)
290 switches. Deleting a subdirectory using @code{dired-undo} does not
291 forget its switches. When later reinserted using @kbd{i}, it will be
292 reinserted using its old switches. Using @code{dired-undo} to
293 reinsert a subdirectory that was deleted using the regular
294 Dired commands (not @code{dired-undo}) will originally insert it with
295 its old switches. However, reverting the buffer will relist it using
296 the buffer's default switches. If any of this yields problems, you
297 can easily correct the situation using @kbd{C-u i} or @kbd{C-u l}.
298
299 Dired does not remember the @code{R} switch. Inserting a subdirectory
300 with switches that include the @code{R} switch is equivalent with
301 inserting each of its subdirectories using all remaining switches.
302 For instance, updating or killing a subdirectory that was inserted
303 with the @code{R} switch will not update or kill its subdirectories.
304
305 The buffer's default switches do not affect subdirectories that were
306 inserted using explicitly specified switches. In particular,
307 commands such as @kbd{s}, that change the buffer's switches do not
308 affect such subdirectories. (They do affect subdirectories without
309 explicitly assigned switches, however.)
310
311 You can make Dired forget about all subdirectory switches and relist
312 all subdirectories with the buffer's default switches using
313 @kbd{M-x dired-reset-subdir-switches}. This also reverts the Dired buffer.
314
315
316 @c Moved here from the Emacs Lisp Reference Manual, 2005-03-26.
317 @node Advanced Calendar/Diary Usage
318 @chapter Customizing the Calendar and Diary
319
320 There are many customizations that you can use to make the calendar and
321 diary suit your personal tastes.
322
323 @menu
324 * Calendar Customizing:: Defaults you can set.
325 * Holiday Customizing:: Defining your own holidays.
326 * Date Display Format:: Changing the format.
327 * Time Display Format:: Changing the format.
328 * Daylight Savings:: Changing the default.
329 * Diary Customizing:: Defaults you can set.
330 * Hebrew/Islamic Entries:: How to obtain them.
331 * Fancy Diary Display:: Enhancing the diary display, sorting entries,
332 using included diary files.
333 * Sexp Diary Entries:: Fancy things you can do.
334 @end menu
335
336 @node Calendar Customizing
337 @section Customizing the Calendar
338 @vindex calendar-holiday-marker
339 @vindex diary-entry-marker
340 The variable @code{calendar-holiday-marker} specifies how to mark a
341 date as being a holiday. Its value may be a single-character string
342 to insert next to the date, or a face name to use for displaying the
343 date. Likewise, the variable @code{diary-entry-marker} specifies how
344 to mark a date that has diary entries. The calendar creates faces
345 named @code{holiday-face} and @code{diary-face} for these purposes;
346 those symbols are the default values of these variables.
347
348 @vindex calendar-load-hook
349 The variable @code{calendar-load-hook} is a normal hook run when the
350 calendar package is first loaded (before actually starting to display
351 the calendar).
352
353 @vindex initial-calendar-window-hook
354 Starting the calendar runs the normal hook
355 @code{initial-calendar-window-hook}. Recomputation of the calendar
356 display does not run this hook. But if you leave the calendar with the
357 @kbd{q} command and reenter it, the hook runs again.@refill
358
359 @vindex today-visible-calendar-hook
360 The variable @code{today-visible-calendar-hook} is a normal hook run
361 after the calendar buffer has been prepared with the calendar when the
362 current date is visible in the window. One use of this hook is to
363 replace today's date with asterisks; to do that, use the hook function
364 @code{calendar-star-date}.
365
366 @findex calendar-star-date
367 @example
368 (add-hook 'today-visible-calendar-hook 'calendar-star-date)
369 @end example
370
371 @noindent
372 Another standard hook function marks the current date, either by
373 changing its face or by adding an asterisk. Here's how to use it:
374
375 @findex calendar-mark-today
376 @example
377 (add-hook 'today-visible-calendar-hook 'calendar-mark-today)
378 @end example
379
380 @noindent
381 @vindex calendar-today-marker
382 The variable @code{calendar-today-marker} specifies how to mark
383 today's date. Its value should be a single-character string to insert
384 next to the date or a face name to use for displaying the date. A
385 face named @code{calendar-today-face} is provided for this purpose;
386 that symbol is the default for this variable.
387
388 @vindex today-invisible-calendar-hook
389 @noindent
390 A similar normal hook, @code{today-invisible-calendar-hook} is run if
391 the current date is @emph{not} visible in the window.
392
393 @vindex calendar-move-hook
394 Each of the calendar cursor motion commands runs the hook
395 @code{calendar-move-hook} after it moves the cursor.
396
397 @node Holiday Customizing
398 @section Customizing the Holidays
399
400 @vindex calendar-holidays
401 @vindex christian-holidays
402 @vindex hebrew-holidays
403 @vindex islamic-holidays
404 Emacs knows about holidays defined by entries on one of several lists.
405 You can customize these lists of holidays to your own needs, adding or
406 deleting holidays. The lists of holidays that Emacs uses are for
407 general holidays (@code{general-holidays}), local holidays
408 (@code{local-holidays}), Christian holidays (@code{christian-holidays}),
409 Hebrew (Jewish) holidays (@code{hebrew-holidays}), Islamic (Muslim)
410 holidays (@code{islamic-holidays}), and other holidays
411 (@code{other-holidays}).
412
413 @vindex general-holidays
414 The general holidays are, by default, holidays common throughout the
415 United States. To eliminate these holidays, set @code{general-holidays}
416 to @code{nil}.
417
418 @vindex local-holidays
419 There are no default local holidays (but sites may supply some). You
420 can set the variable @code{local-holidays} to any list of holidays, as
421 described below.
422
423 @vindex all-christian-calendar-holidays
424 @vindex all-hebrew-calendar-holidays
425 @vindex all-islamic-calendar-holidays
426 By default, Emacs does not include all the holidays of the religions
427 that it knows, only those commonly found in secular calendars. For a
428 more extensive collection of religious holidays, you can set any (or
429 all) of the variables @code{all-christian-calendar-holidays},
430 @code{all-hebrew-calendar-holidays}, or
431 @code{all-islamic-calendar-holidays} to @code{t}. If you want to
432 eliminate the religious holidays, set any or all of the corresponding
433 variables @code{christian-holidays}, @code{hebrew-holidays}, and
434 @code{islamic-holidays} to @code{nil}.@refill
435
436 @vindex other-holidays
437 You can set the variable @code{other-holidays} to any list of
438 holidays. This list, normally empty, is intended for individual use.
439
440 @cindex holiday forms
441 Each of the lists (@code{general-holidays}, @code{local-holidays},
442 @code{christian-holidays}, @code{hebrew-holidays},
443 @code{islamic-holidays}, and @code{other-holidays}) is a list of
444 @dfn{holiday forms}, each holiday form describing a holiday (or
445 sometimes a list of holidays).
446
447 Here is a table of the possible kinds of holiday form. Day numbers
448 and month numbers count starting from 1, but ``dayname'' numbers
449 count Sunday as 0. The element @var{string} is always the
450 name of the holiday, as a string.
451
452 @table @code
453 @item (holiday-fixed @var{month} @var{day} @var{string})
454 A fixed date on the Gregorian calendar.
455
456 @item (holiday-float @var{month} @var{dayname} @var{k} @var{string})
457 The @var{k}th @var{dayname} in @var{month} on the Gregorian calendar
458 (@var{dayname}=0 for Sunday, and so on); negative @var{k} means count back
459 from the end of the month.
460
461 @item (holiday-hebrew @var{month} @var{day} @var{string})
462 A fixed date on the Hebrew calendar.
463
464 @item (holiday-islamic @var{month} @var{day} @var{string})
465 A fixed date on the Islamic calendar.
466
467 @item (holiday-julian @var{month} @var{day} @var{string})
468 A fixed date on the Julian calendar.
469
470 @item (holiday-sexp @var{sexp} @var{string})
471 A date calculated by the Lisp expression @var{sexp}. The expression
472 should use the variable @code{year} to compute and return the date of a
473 holiday, or @code{nil} if the holiday doesn't happen this year. The
474 value of @var{sexp} must represent the date as a list of the form
475 @code{(@var{month} @var{day} @var{year})}.
476
477 @item (if @var{condition} @var{holiday-form})
478 A holiday that happens only if @var{condition} is true.
479
480 @item (@var{function} @r{[}@var{args}@r{]})
481 A list of dates calculated by the function @var{function}, called with
482 arguments @var{args}.
483 @end table
484
485 For example, suppose you want to add Bastille Day, celebrated in
486 France on July 14. You can do this as follows:
487
488 @smallexample
489 (setq other-holidays '((holiday-fixed 7 14 "Bastille Day")))
490 @end smallexample
491
492 @noindent
493 The holiday form @code{(holiday-fixed 7 14 "Bastille Day")} specifies the
494 fourteenth day of the seventh month (July).
495
496 Many holidays occur on a specific day of the week, at a specific time
497 of month. Here is a holiday form describing Hurricane Supplication Day,
498 celebrated in the Virgin Islands on the fourth Monday in August:
499
500 @smallexample
501 (holiday-float 8 1 4 "Hurricane Supplication Day")
502 @end smallexample
503
504 @noindent
505 Here the 8 specifies August, the 1 specifies Monday (Sunday is 0,
506 Tuesday is 2, and so on), and the 4 specifies the fourth occurrence in
507 the month (1 specifies the first occurrence, 2 the second occurrence,
508 @minus{}1 the last occurrence, @minus{}2 the second-to-last occurrence, and
509 so on).
510
511 You can specify holidays that occur on fixed days of the Hebrew,
512 Islamic, and Julian calendars too. For example,
513
514 @smallexample
515 (setq other-holidays
516 '((holiday-hebrew 10 2 "Last day of Hanukkah")
517 (holiday-islamic 3 12 "Mohammed's Birthday")
518 (holiday-julian 4 2 "Jefferson's Birthday")))
519 @end smallexample
520
521 @noindent
522 adds the last day of Hanukkah (since the Hebrew months are numbered with
523 1 starting from Nisan), the Islamic feast celebrating Mohammed's
524 birthday (since the Islamic months are numbered from 1 starting with
525 Muharram), and Thomas Jefferson's birthday, which is 2 April 1743 on the
526 Julian calendar.
527
528 To include a holiday conditionally, use either Emacs Lisp's @code{if} or the
529 @code{holiday-sexp} form. For example, American presidential elections
530 occur on the first Tuesday after the first Monday in November of years
531 divisible by 4:
532
533 @smallexample
534 (holiday-sexp '(if (= 0 (% year 4))
535 (calendar-gregorian-from-absolute
536 (1+ (calendar-dayname-on-or-before
537 1 (+ 6 (calendar-absolute-from-gregorian
538 (list 11 1 year)))))))
539 "US Presidential Election")
540 @end smallexample
541
542 @noindent
543 or
544
545 @smallexample
546 (if (= 0 (% displayed-year 4))
547 (fixed 11
548 (extract-calendar-day
549 (calendar-gregorian-from-absolute
550 (1+ (calendar-dayname-on-or-before
551 1 (+ 6 (calendar-absolute-from-gregorian
552 (list 11 1 displayed-year)))))))
553 "US Presidential Election"))
554 @end smallexample
555
556 Some holidays just don't fit into any of these forms because special
557 calculations are involved in their determination. In such cases you
558 must write a Lisp function to do the calculation. To include eclipses,
559 for example, add @code{(eclipses)} to @code{other-holidays}
560 and write an Emacs Lisp function @code{eclipses} that returns a
561 (possibly empty) list of the relevant Gregorian dates among the range
562 visible in the calendar window, with descriptive strings, like this:
563
564 @smallexample
565 (((6 27 1991) "Lunar Eclipse") ((7 11 1991) "Solar Eclipse") ... )
566 @end smallexample
567
568 @node Date Display Format
569 @section Date Display Format
570 @vindex calendar-date-display-form
571
572 You can customize the manner of displaying dates in the diary, in mode
573 lines, and in messages by setting @code{calendar-date-display-form}.
574 This variable holds a list of expressions that can involve the variables
575 @code{month}, @code{day}, and @code{year}, which are all numbers in
576 string form, and @code{monthname} and @code{dayname}, which are both
577 alphabetic strings. In the American style, the default value of this
578 list is as follows:
579
580 @smallexample
581 ((if dayname (concat dayname ", ")) monthname " " day ", " year)
582 @end smallexample
583
584 @noindent
585 while in the European style this value is the default:
586
587 @smallexample
588 ((if dayname (concat dayname ", ")) day " " monthname " " year)
589 @end smallexample
590
591 @noindent
592 The ISO standard date representation is this:
593
594 @smallexample
595 (year "-" month "-" day)
596 @end smallexample
597
598 @noindent
599 This specifies a typical American format:
600
601 @smallexample
602 (month "/" day "/" (substring year -2))
603 @end smallexample
604
605 @node Time Display Format
606 @section Time Display Format
607 @vindex calendar-time-display-form
608
609 The calendar and diary by default display times of day in the
610 conventional American style with the hours from 1 through 12, minutes,
611 and either @samp{am} or @samp{pm}. If you prefer the European style,
612 also known in the US as military, in which the hours go from 00 to 23,
613 you can alter the variable @code{calendar-time-display-form}. This
614 variable is a list of expressions that can involve the variables
615 @code{12-hours}, @code{24-hours}, and @code{minutes}, which are all
616 numbers in string form, and @code{am-pm} and @code{time-zone}, which are
617 both alphabetic strings. The default value of
618 @code{calendar-time-display-form} is as follows:
619
620 @smallexample
621 (12-hours ":" minutes am-pm
622 (if time-zone " (") time-zone (if time-zone ")"))
623 @end smallexample
624
625 @noindent
626 Here is a value that provides European style times:
627
628 @smallexample
629 (24-hours ":" minutes
630 (if time-zone " (") time-zone (if time-zone ")"))
631 @end smallexample
632
633 @node Daylight Savings
634 @section Daylight Savings Time
635 @cindex daylight savings time
636
637 Emacs understands the difference between standard time and daylight
638 savings time---the times given for sunrise, sunset, solstices,
639 equinoxes, and the phases of the moon take that into account. The rules
640 for daylight savings time vary from place to place and have also varied
641 historically from year to year. To do the job properly, Emacs needs to
642 know which rules to use.
643
644 Some operating systems keep track of the rules that apply to the place
645 where you are; on these systems, Emacs gets the information it needs
646 from the system automatically. If some or all of this information is
647 missing, Emacs fills in the gaps with the rules currently used in
648 Cambridge, Massachusetts, which is the center of GNU's world.
649
650
651 @vindex calendar-daylight-savings-starts
652 @vindex calendar-daylight-savings-ends
653 If the default choice of rules is not appropriate for your location,
654 you can tell Emacs the rules to use by setting the variables
655 @code{calendar-daylight-savings-starts} and
656 @code{calendar-daylight-savings-ends}. Their values should be Lisp
657 expressions that refer to the variable @code{year}, and evaluate to the
658 Gregorian date on which daylight savings time starts or (respectively)
659 ends, in the form of a list @code{(@var{month} @var{day} @var{year})}.
660 The values should be @code{nil} if your area does not use daylight
661 savings time.
662
663 Emacs uses these expressions to determine the start and end dates of
664 daylight savings time as holidays and for correcting times of day in the
665 solar and lunar calculations.
666
667 The values for Cambridge, Massachusetts are as follows:
668
669 @example
670 @group
671 (calendar-nth-named-day 1 0 4 year)
672 (calendar-nth-named-day -1 0 10 year)
673 @end group
674 @end example
675
676 @noindent
677 i.e., the first 0th day (Sunday) of the fourth month (April) in
678 the year specified by @code{year}, and the last Sunday of the tenth month
679 (October) of that year. If daylight savings time were
680 changed to start on October 1, you would set
681 @code{calendar-daylight-savings-starts} to this:
682
683 @example
684 (list 10 1 year)
685 @end example
686
687 For a more complex example, suppose daylight savings time begins on
688 the first of Nisan on the Hebrew calendar. You should set
689 @code{calendar-daylight-savings-starts} to this value:
690
691 @example
692 (calendar-gregorian-from-absolute
693 (calendar-absolute-from-hebrew
694 (list 1 1 (+ year 3760))))
695 @end example
696
697 @noindent
698 because Nisan is the first month in the Hebrew calendar and the Hebrew
699 year differs from the Gregorian year by 3760 at Nisan.
700
701 If there is no daylight savings time at your location, or if you want
702 all times in standard time, set @code{calendar-daylight-savings-starts}
703 and @code{calendar-daylight-savings-ends} to @code{nil}.
704
705 @vindex calendar-daylight-time-offset
706 The variable @code{calendar-daylight-time-offset} specifies the
707 difference between daylight savings time and standard time, measured in
708 minutes. The value for Cambridge is 60.
709
710 @vindex calendar-daylight-savings-starts-time
711 @vindex calendar-daylight-savings-ends-time
712 The variable @code{calendar-daylight-savings-starts-time} and the
713 variable @code{calendar-daylight-savings-ends-time} specify the number
714 of minutes after midnight local time when the transition to and from
715 daylight savings time should occur. For Cambridge, both variables'
716 values are 120.
717
718 @node Diary Customizing
719 @section Customizing the Diary
720
721 @vindex holidays-in-diary-buffer
722 Ordinarily, the mode line of the diary buffer window indicates any
723 holidays that fall on the date of the diary entries. The process of
724 checking for holidays can take several seconds, so including holiday
725 information delays the display of the diary buffer noticeably. If you'd
726 prefer to have a faster display of the diary buffer but without the
727 holiday information, set the variable @code{holidays-in-diary-buffer} to
728 @code{nil}.@refill
729
730 @vindex number-of-diary-entries
731 The variable @code{number-of-diary-entries} controls the number of
732 days of diary entries to be displayed at one time. It affects the
733 initial display when @code{view-diary-entries-initially} is @code{t}, as
734 well as the command @kbd{M-x diary}. For example, the default value is
735 1, which says to display only the current day's diary entries. If the
736 value is 2, both the current day's and the next day's entries are
737 displayed. The value can also be a vector of seven elements: for
738 example, if the value is @code{[0 2 2 2 2 4 1]} then no diary entries
739 appear on Sunday, the current date's and the next day's diary entries
740 appear Monday through Thursday, Friday through Monday's entries appear
741 on Friday, while on Saturday only that day's entries appear.
742
743 @vindex print-diary-entries-hook
744 @findex print-diary-entries
745 The variable @code{print-diary-entries-hook} is a normal hook run
746 after preparation of a temporary buffer containing just the diary
747 entries currently visible in the diary buffer. (The other, irrelevant
748 diary entries are really absent from the temporary buffer; in the diary
749 buffer, they are merely hidden.) The default value of this hook does
750 the printing with the command @code{lpr-buffer}. If you want to use a
751 different command to do the printing, just change the value of this
752 hook. Other uses might include, for example, rearranging the lines into
753 order by day and time.
754
755 @vindex diary-date-forms
756 You can customize the form of dates in your diary file, if neither the
757 standard American nor European styles suits your needs, by setting the
758 variable @code{diary-date-forms}. This variable is a list of patterns
759 for recognizing a date. Each date pattern is a list whose elements may
760 be regular expressions (@pxref{Regular Expressions,,, elisp, the Emacs
761 Lisp Reference Manual}) or the symbols @code{month}, @code{day},
762 @code{year}, @code{monthname}, and @code{dayname}. All these elements
763 serve as patterns that match certain kinds of text in the diary file.
764 In order for the date pattern, as a whole, to match, all of its elements
765 must match consecutively.
766
767 A regular expression in a date pattern matches in its usual fashion,
768 using the standard syntax table altered so that @samp{*} is a word
769 constituent.
770
771 The symbols @code{month}, @code{day}, @code{year}, @code{monthname},
772 and @code{dayname} match the month number, day number, year number,
773 month name, and day name of the date being considered. The symbols that
774 match numbers allow leading zeros; those that match names allow
775 three-letter abbreviations and capitalization. All the symbols can
776 match @samp{*}; since @samp{*} in a diary entry means ``any day'', ``any
777 month'', and so on, it should match regardless of the date being
778 considered.
779
780 The default value of @code{diary-date-forms} in the American style is
781 this:
782
783 @example
784 ((month "/" day "[^/0-9]")
785 (month "/" day "/" year "[^0-9]")
786 (monthname " *" day "[^,0-9]")
787 (monthname " *" day ", *" year "[^0-9]")
788 (dayname "\\W"))
789 @end example
790
791 The date patterns in the list must be @emph{mutually exclusive} and
792 must not match any portion of the diary entry itself, just the date and
793 one character of whitespace. If, to be mutually exclusive, the pattern
794 must match a portion of the diary entry text---beyond the whitespace
795 that ends the date---then the first element of the date pattern
796 @emph{must} be @code{backup}. This causes the date recognizer to back
797 up to the beginning of the current word of the diary entry, after
798 finishing the match. Even if you use @code{backup}, the date pattern
799 must absolutely not match more than a portion of the first word of the
800 diary entry. The default value of @code{diary-date-forms} in the
801 European style is this list:
802
803 @example
804 ((day "/" month "[^/0-9]")
805 (day "/" month "/" year "[^0-9]")
806 (backup day " *" monthname "\\W+\\<[^*0-9]")
807 (day " *" monthname " *" year "[^0-9]")
808 (dayname "\\W"))
809 @end example
810
811 @noindent
812 Notice the use of @code{backup} in the third pattern, because it needs
813 to match part of a word beyond the date itself to distinguish it from
814 the fourth pattern.
815
816 @node Hebrew/Islamic Entries
817 @section Hebrew- and Islamic-Date Diary Entries
818
819 Your diary file can have entries based on Hebrew or Islamic dates, as
820 well as entries based on the world-standard Gregorian calendar.
821 However, because recognition of such entries is time-consuming and most
822 people don't use them, you must explicitly enable their use. If you
823 want the diary to recognize Hebrew-date diary entries, for example,
824 you must do this:
825
826 @vindex nongregorian-diary-listing-hook
827 @vindex nongregorian-diary-marking-hook
828 @findex list-hebrew-diary-entries
829 @findex mark-hebrew-diary-entries
830 @smallexample
831 (add-hook 'nongregorian-diary-listing-hook 'list-hebrew-diary-entries)
832 (add-hook 'nongregorian-diary-marking-hook 'mark-hebrew-diary-entries)
833 @end smallexample
834
835 @noindent
836 If you want Islamic-date entries, do this:
837
838 @findex list-islamic-diary-entries
839 @findex mark-islamic-diary-entries
840 @smallexample
841 (add-hook 'nongregorian-diary-listing-hook 'list-islamic-diary-entries)
842 (add-hook 'nongregorian-diary-marking-hook 'mark-islamic-diary-entries)
843 @end smallexample
844
845 Hebrew- and Islamic-date diary entries have the same formats as
846 Gregorian-date diary entries, except that @samp{H} precedes a Hebrew
847 date and @samp{I} precedes an Islamic date. Moreover, because the
848 Hebrew and Islamic month names are not uniquely specified by the first
849 three letters, you may not abbreviate them. For example, a diary entry
850 for the Hebrew date Heshvan 25 could look like this:
851
852 @smallexample
853 HHeshvan 25 Happy Hebrew birthday!
854 @end smallexample
855
856 @noindent
857 and would appear in the diary for any date that corresponds to Heshvan 25
858 on the Hebrew calendar. And here is an Islamic-date diary entry that matches
859 Dhu al-Qada 25:
860
861 @smallexample
862 IDhu al-Qada 25 Happy Islamic birthday!
863 @end smallexample
864
865 As with Gregorian-date diary entries, Hebrew- and Islamic-date entries
866 are nonmarking if they are preceded with an ampersand (@samp{&}).
867
868 Here is a table of commands used in the calendar to create diary entries
869 that match the selected date and other dates that are similar in the Hebrew
870 or Islamic calendar:
871
872 @table @kbd
873 @item i h d
874 Add a diary entry for the Hebrew date corresponding to the selected date
875 (@code{insert-hebrew-diary-entry}).
876 @item i h m
877 Add a diary entry for the day of the Hebrew month corresponding to the
878 selected date (@code{insert-monthly-hebrew-diary-entry}). This diary
879 entry matches any date that has the same Hebrew day-within-month as the
880 selected date.
881 @item i h y
882 Add a diary entry for the day of the Hebrew year corresponding to the
883 selected date (@code{insert-yearly-hebrew-diary-entry}). This diary
884 entry matches any date which has the same Hebrew month and day-within-month
885 as the selected date.
886 @item i i d
887 Add a diary entry for the Islamic date corresponding to the selected date
888 (@code{insert-islamic-diary-entry}).
889 @item i i m
890 Add a diary entry for the day of the Islamic month corresponding to the
891 selected date (@code{insert-monthly-islamic-diary-entry}).
892 @item i i y
893 Add a diary entry for the day of the Islamic year corresponding to the
894 selected date (@code{insert-yearly-islamic-diary-entry}).
895 @end table
896
897 @findex insert-hebrew-diary-entry
898 @findex insert-monthly-hebrew-diary-entry
899 @findex insert-yearly-hebrew-diary-entry
900 @findex insert-islamic-diary-entry
901 @findex insert-monthly-islamic-diary-entry
902 @findex insert-yearly-islamic-diary-entry
903 These commands work much like the corresponding commands for ordinary
904 diary entries: they apply to the date that point is on in the calendar
905 window, and what they do is insert just the date portion of a diary entry
906 at the end of your diary file. You must then insert the rest of the
907 diary entry.
908
909 @node Fancy Diary Display
910 @section Fancy Diary Display
911 @vindex diary-display-hook
912 @findex simple-diary-display
913
914 Diary display works by preparing the diary buffer and then running the
915 hook @code{diary-display-hook}. The default value of this hook
916 (@code{simple-diary-display}) hides the irrelevant diary entries and
917 then displays the buffer. However, if you specify the hook as follows,
918
919 @cindex diary buffer
920 @findex fancy-diary-display
921 @example
922 (add-hook 'diary-display-hook 'fancy-diary-display)
923 @end example
924
925 @noindent
926 this enables fancy diary display. It displays diary entries and
927 holidays by copying them into a special buffer that exists only for the
928 sake of display. Copying to a separate buffer provides an opportunity
929 to change the displayed text to make it prettier---for example, to sort
930 the entries by the dates they apply to.
931
932 As with simple diary display, you can print a hard copy of the buffer
933 with @code{print-diary-entries}. To print a hard copy of a day-by-day
934 diary for a week, position point on Sunday of that week, type
935 @kbd{7 d}, and then do @kbd{M-x print-diary-entries}. As usual, the
936 inclusion of the holidays slows down the display slightly; you can speed
937 things up by setting the variable @code{holidays-in-diary-buffer} to
938 @code{nil}.
939
940 @vindex diary-list-include-blanks
941 Ordinarily, the fancy diary buffer does not show days for which there are
942 no diary entries, even if that day is a holiday. If you want such days to be
943 shown in the fancy diary buffer, set the variable
944 @code{diary-list-include-blanks} to @code{t}.@refill
945
946 @cindex sorting diary entries
947 If you use the fancy diary display, you can use the normal hook
948 @code{list-diary-entries-hook} to sort each day's diary entries by their
949 time of day. Here's how:
950
951 @findex sort-diary-entries
952 @example
953 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
954 @end example
955
956 @noindent
957 For each day, this sorts diary entries that begin with a recognizable
958 time of day according to their times. Diary entries without times come
959 first within each day.
960
961 Fancy diary display also has the ability to process included diary
962 files. This permits a group of people to share a diary file for events
963 that apply to all of them. Lines in the diary file of this form:
964
965 @smallexample
966 #include "@var{filename}"
967 @end smallexample
968
969 @noindent
970 includes the diary entries from the file @var{filename} in the fancy
971 diary buffer. The include mechanism is recursive, so that included files
972 can include other files, and so on; you must be careful not to have a
973 cycle of inclusions, of course. Here is how to enable the include
974 facility:
975
976 @vindex list-diary-entries-hook
977 @vindex mark-diary-entries-hook
978 @findex include-other-diary-files
979 @findex mark-included-diary-files
980 @smallexample
981 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
982 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
983 @end smallexample
984
985 The include mechanism works only with the fancy diary display, because
986 ordinary diary display shows the entries directly from your diary file.
987
988 @node Sexp Diary Entries
989 @section Sexp Entries and the Fancy Diary Display
990 @cindex sexp diary entries
991
992 Sexp diary entries allow you to do more than just have complicated
993 conditions under which a diary entry applies. If you use the fancy
994 diary display, sexp entries can generate the text of the entry depending
995 on the date itself. For example, an anniversary diary entry can insert
996 the number of years since the anniversary date into the text of the
997 diary entry. Thus the @samp{%d} in this dairy entry:
998
999 @findex diary-anniversary
1000 @smallexample
1001 %%(diary-anniversary 10 31 1948) Arthur's birthday (%d years old)
1002 @end smallexample
1003
1004 @noindent
1005 gets replaced by the age, so on October 31, 1990 the entry appears in
1006 the fancy diary buffer like this:
1007
1008 @smallexample
1009 Arthur's birthday (42 years old)
1010 @end smallexample
1011
1012 @noindent
1013 If the diary file instead contains this entry:
1014
1015 @smallexample
1016 %%(diary-anniversary 10 31 1948) Arthur's %d%s birthday
1017 @end smallexample
1018
1019 @noindent
1020 the entry in the fancy diary buffer for October 31, 1990 appears like this:
1021
1022 @smallexample
1023 Arthur's 42nd birthday
1024 @end smallexample
1025
1026 Similarly, cyclic diary entries can interpolate the number of repetitions
1027 that have occurred:
1028
1029 @findex diary-cyclic
1030 @smallexample
1031 %%(diary-cyclic 50 1 1 1990) Renew medication (%d%s time)
1032 @end smallexample
1033
1034 @noindent
1035 looks like this:
1036
1037 @smallexample
1038 Renew medication (5th time)
1039 @end smallexample
1040
1041 @noindent
1042 in the fancy diary display on September 8, 1990.
1043
1044 There is an early reminder diary sexp that includes its entry in the
1045 diary not only on the date of occurrence, but also on earlier dates.
1046 For example, if you want a reminder a week before your anniversary, you
1047 can use
1048
1049 @findex diary-remind
1050 @smallexample
1051 %%(diary-remind '(diary-anniversary 12 22 1968) 7) Ed's anniversary
1052 @end smallexample
1053
1054 @noindent
1055 and the fancy diary will show
1056 @smallexample
1057 Ed's anniversary
1058 @end smallexample
1059 @noindent
1060 both on December 15 and on December 22.
1061
1062 @findex diary-date
1063 The function @code{diary-date} applies to dates described by a month,
1064 day, year combination, each of which can be an integer, a list of
1065 integers, or @code{t}. The value @code{t} means all values. For
1066 example,
1067
1068 @smallexample
1069 %%(diary-date '(10 11 12) 22 t) Rake leaves
1070 @end smallexample
1071
1072 @noindent
1073 causes the fancy diary to show
1074
1075 @smallexample
1076 Rake leaves
1077 @end smallexample
1078
1079 @noindent
1080 on October 22, November 22, and December 22 of every year.
1081
1082 @findex diary-float
1083 The function @code{diary-float} allows you to describe diary entries
1084 that apply to dates like the third Friday of November, or the last
1085 Tuesday in April. The parameters are the @var{month}, @var{dayname},
1086 and an index @var{n}. The entry appears on the @var{n}th @var{dayname}
1087 of @var{month}, where @var{dayname}=0 means Sunday, 1 means Monday, and
1088 so on. If @var{n} is negative it counts backward from the end of
1089 @var{month}. The value of @var{month} can be a list of months, a single
1090 month, or @code{t} to specify all months. You can also use an optional
1091 parameter @var{day} to specify the @var{n}th @var{dayname} of
1092 @var{month} on or after/before @var{day}; the value of @var{day} defaults
1093 to 1 if @var{n} is positive and to the last day of @var{month} if
1094 @var{n} is negative. For example,
1095
1096 @smallexample
1097 %%(diary-float t 1 -1) Pay rent
1098 @end smallexample
1099
1100 @noindent
1101 causes the fancy diary to show
1102
1103 @smallexample
1104 Pay rent
1105 @end smallexample
1106
1107 @noindent
1108 on the last Monday of every month.
1109
1110 The generality of sexp diary entries lets you specify any diary
1111 entry that you can describe algorithmically. A sexp diary entry
1112 contains an expression that computes whether the entry applies to any
1113 given date. If its value is non-@code{nil}, the entry applies to that
1114 date; otherwise, it does not. The expression can use the variable
1115 @code{date} to find the date being considered; its value is a list
1116 (@var{month} @var{day} @var{year}) that refers to the Gregorian
1117 calendar.
1118
1119 The sexp diary entry applies to a date when the expression's value
1120 is non-@code{nil}, but some values have more specific meanings. If
1121 the value is a string, that string is a description of the event which
1122 occurs on that date. The value can also have the form
1123 @code{(@var{mark} . @var{string})}; then @var{mark} specifies how to
1124 mark the date in the calendar, and @var{string} is the description of
1125 the event. If @var{mark} is a single-character string, that character
1126 appears next to the date in the calendar. If @var{mark} is a face
1127 name, the date is displayed in that face. If @var{mark} is
1128 @code{nil}, that specifies no particular highlighting for the date.
1129
1130 Suppose you get paid on the 21st of the month if it is a weekday, and
1131 on the Friday before if the 21st is on a weekend. Here is how to write
1132 a sexp diary entry that matches those dates:
1133
1134 @smallexample
1135 &%%(let ((dayname (calendar-day-of-week date))
1136 (day (car (cdr date))))
1137 (or (and (= day 21) (memq dayname '(1 2 3 4 5)))
1138 (and (memq day '(19 20)) (= dayname 5)))
1139 ) Pay check deposited
1140 @end smallexample
1141
1142 The following sexp diary entries take advantage of the ability (in the fancy
1143 diary display) to concoct diary entries whose text varies based on the date:
1144
1145 @findex diary-sunrise-sunset
1146 @findex diary-phases-of-moon
1147 @findex diary-day-of-year
1148 @findex diary-iso-date
1149 @findex diary-julian-date
1150 @findex diary-astro-day-number
1151 @findex diary-hebrew-date
1152 @findex diary-islamic-date
1153 @findex diary-french-date
1154 @findex diary-mayan-date
1155 @table @code
1156 @item %%(diary-sunrise-sunset)
1157 Make a diary entry for the local times of today's sunrise and sunset.
1158 @item %%(diary-phases-of-moon)
1159 Make a diary entry for the phases (quarters) of the moon.
1160 @item %%(diary-day-of-year)
1161 Make a diary entry with today's day number in the current year and the number
1162 of days remaining in the current year.
1163 @item %%(diary-iso-date)
1164 Make a diary entry with today's equivalent ISO commercial date.
1165 @item %%(diary-julian-date)
1166 Make a diary entry with today's equivalent date on the Julian calendar.
1167 @item %%(diary-astro-day-number)
1168 Make a diary entry with today's equivalent astronomical (Julian) day number.
1169 @item %%(diary-hebrew-date)
1170 Make a diary entry with today's equivalent date on the Hebrew calendar.
1171 @item %%(diary-islamic-date)
1172 Make a diary entry with today's equivalent date on the Islamic calendar.
1173 @item %%(diary-french-date)
1174 Make a diary entry with today's equivalent date on the French Revolutionary
1175 calendar.
1176 @item %%(diary-mayan-date)
1177 Make a diary entry with today's equivalent date on the Mayan calendar.
1178 @end table
1179
1180 @noindent
1181 Thus including the diary entry
1182
1183 @example
1184 &%%(diary-hebrew-date)
1185 @end example
1186
1187 @noindent
1188 causes every day's diary display to contain the equivalent date on the
1189 Hebrew calendar, if you are using the fancy diary display. (With simple
1190 diary display, the line @samp{&%%(diary-hebrew-date)} appears in the
1191 diary for any date, but does nothing particularly useful.)
1192
1193 These functions can be used to construct sexp diary entries based on
1194 the Hebrew calendar in certain standard ways:
1195
1196 @cindex rosh hodesh
1197 @findex diary-rosh-hodesh
1198 @cindex parasha, weekly
1199 @findex diary-parasha
1200 @cindex candle lighting times
1201 @findex diary-sabbath-candles
1202 @cindex omer count
1203 @findex diary-omer
1204 @cindex yahrzeits
1205 @findex diary-yahrzeit
1206 @table @code
1207 @item %%(diary-rosh-hodesh)
1208 Make a diary entry that tells the occurrence and ritual announcement of each
1209 new Hebrew month.
1210 @item %%(diary-parasha)
1211 Make a Saturday diary entry that tells the weekly synagogue scripture reading.
1212 @item %%(diary-sabbath-candles)
1213 Make a Friday diary entry that tells the @emph{local time} of Sabbath
1214 candle lighting.
1215 @item %%(diary-omer)
1216 Make a diary entry that gives the omer count, when appropriate.
1217 @item %%(diary-yahrzeit @var{month} @var{day} @var{year}) @var{name}
1218 Make a diary entry marking the anniversary of a date of death. The date
1219 is the @emph{Gregorian} (civil) date of death. The diary entry appears
1220 on the proper Hebrew calendar anniversary and on the day before. (In
1221 the European style, the order of the parameters is changed to @var{day},
1222 @var{month}, @var{year}.)
1223 @end table
1224
1225 All the functions documented above take an optional argument
1226 @var{mark} which specifies how to mark the date in the calendar display.
1227 If one of these functions decides that it applies to a certain date,
1228 it returns a value that contains @var{mark}.
1229
1230 @node Emerge
1231 @chapter Merging Files with Emerge
1232 @cindex Emerge
1233 @cindex merging files
1234
1235 It's not unusual for programmers to get their signals crossed and
1236 modify the same program in two different directions. To recover from
1237 this confusion, you need to merge the two versions. Emerge makes this
1238 easier. For other ways to compare files, see @ref{Comparing Files,,,
1239 emacs, the Emacs Manual} and @ref{Top, Ediff,, ediff, The Ediff
1240 Manual}.
1241
1242 @menu
1243 * Overview of Emerge:: How to start Emerge. Basic concepts.
1244 * Submodes of Emerge:: Fast mode vs. Edit mode.
1245 Skip Prefers mode and Auto Advance mode.
1246 * State of Difference:: You do the merge by specifying state A or B
1247 for each difference.
1248 * Merge Commands:: Commands for selecting a difference,
1249 changing states of differences, etc.
1250 * Exiting Emerge:: What to do when you've finished the merge.
1251 * Combining in Emerge:: How to keep both alternatives for a difference.
1252 * Fine Points of Emerge:: Misc.
1253 @end menu
1254
1255 @node Overview of Emerge
1256 @section Overview of Emerge
1257
1258 To start Emerge, run one of these four commands:
1259
1260 @table @kbd
1261 @item M-x emerge-files
1262 @findex emerge-files
1263 Merge two specified files.
1264
1265 @item M-x emerge-files-with-ancestor
1266 @findex emerge-files-with-ancestor
1267 Merge two specified files, with reference to a common ancestor.
1268
1269 @item M-x emerge-buffers
1270 @findex emerge-buffers
1271 Merge two buffers.
1272
1273 @item M-x emerge-buffers-with-ancestor
1274 @findex emerge-buffers-with-ancestor
1275 Merge two buffers with reference to a common ancestor in a third
1276 buffer.
1277 @end table
1278
1279 @cindex merge buffer (Emerge)
1280 @cindex A and B buffers (Emerge)
1281 The Emerge commands compare two files or buffers, and display the
1282 comparison in three buffers: one for each input text (the @dfn{A buffer}
1283 and the @dfn{B buffer}), and one (the @dfn{merge buffer}) where merging
1284 takes place. The merge buffer shows the full merged text, not just the
1285 differences. Wherever the two input texts differ, you can choose which
1286 one of them to include in the merge buffer.
1287
1288 The Emerge commands that take input from existing buffers use only
1289 the accessible portions of those buffers, if they are narrowed.
1290 @xref{Narrowing,,, emacs, the Emacs Manual}.
1291
1292
1293 If a common ancestor version is available, from which the two texts to
1294 be merged were both derived, Emerge can use it to guess which
1295 alternative is right. Wherever one current version agrees with the
1296 ancestor, Emerge presumes that the other current version is a deliberate
1297 change which should be kept in the merged version. Use the
1298 @samp{with-ancestor} commands if you want to specify a common ancestor
1299 text. These commands read three file or buffer names---variant A,
1300 variant B, and the common ancestor.
1301
1302 After the comparison is done and the buffers are prepared, the
1303 interactive merging starts. You control the merging by typing special
1304 @dfn{merge commands} in the merge buffer (@pxref{Merge Commands}).
1305 For each run of differences between the input texts, you can choose
1306 which one of them to keep, or edit them both together.
1307
1308 The merge buffer uses a special major mode, Emerge mode, with commands
1309 for making these choices. But you can also edit the buffer with
1310 ordinary Emacs commands.
1311
1312 At any given time, the attention of Emerge is focused on one
1313 particular difference, called the @dfn{selected} difference. This
1314 difference is marked off in the three buffers like this:
1315
1316 @example
1317 vvvvvvvvvvvvvvvvvvvv
1318 @var{text that differs}
1319 ^^^^^^^^^^^^^^^^^^^^
1320 @end example
1321
1322 @noindent
1323 Emerge numbers all the differences sequentially and the mode
1324 line always shows the number of the selected difference.
1325
1326 Normally, the merge buffer starts out with the A version of the text.
1327 But when the A version of a difference agrees with the common ancestor,
1328 then the B version is initially preferred for that difference.
1329
1330 Emerge leaves the merged text in the merge buffer when you exit. At
1331 that point, you can save it in a file with @kbd{C-x C-w}. If you give a
1332 numeric argument to @code{emerge-files} or
1333 @code{emerge-files-with-ancestor}, it reads the name of the output file
1334 using the minibuffer. (This is the last file name those commands read.)
1335 Then exiting from Emerge saves the merged text in the output file.
1336
1337 Normally, Emerge commands save the output buffer in its file when you
1338 exit. If you abort Emerge with @kbd{C-]}, the Emerge command does not
1339 save the output buffer, but you can save it yourself if you wish.
1340
1341 @node Submodes of Emerge
1342 @section Submodes of Emerge
1343
1344 You can choose between two modes for giving merge commands: Fast mode
1345 and Edit mode. In Fast mode, basic merge commands are single
1346 characters, but ordinary Emacs commands are disabled. This is
1347 convenient if you use only merge commands. In Edit mode, all merge
1348 commands start with the prefix key @kbd{C-c C-c}, and the normal Emacs
1349 commands are also available. This allows editing the merge buffer, but
1350 slows down Emerge operations.
1351
1352 Use @kbd{e} to switch to Edit mode, and @kbd{C-c C-c f} to switch to
1353 Fast mode. The mode line indicates Edit and Fast modes with @samp{E}
1354 and @samp{F}.
1355
1356 Emerge has two additional submodes that affect how particular merge
1357 commands work: Auto Advance mode and Skip Prefers mode.
1358
1359 If Auto Advance mode is in effect, the @kbd{a} and @kbd{b} commands
1360 advance to the next difference. This lets you go through the merge
1361 faster as long as you simply choose one of the alternatives from the
1362 input. The mode line indicates Auto Advance mode with @samp{A}.
1363
1364 If Skip Prefers mode is in effect, the @kbd{n} and @kbd{p} commands
1365 skip over differences in states prefer-A and prefer-B (@pxref{State of
1366 Difference}). Thus you see only differences for which neither version
1367 is presumed ``correct.'' The mode line indicates Skip Prefers mode with
1368 @samp{S}.
1369
1370 @findex emerge-auto-advance-mode
1371 @findex emerge-skip-prefers-mode
1372 Use the command @kbd{s a} (@code{emerge-auto-advance-mode}) to set or
1373 clear Auto Advance mode. Use @kbd{s s}
1374 (@code{emerge-skip-prefers-mode}) to set or clear Skip Prefers mode.
1375 These commands turn on the mode with a positive argument, turns it off
1376 with a negative or zero argument, and toggle the mode with no argument.
1377
1378 @node State of Difference
1379 @section State of a Difference
1380
1381 In the merge buffer, a difference is marked with lines of @samp{v} and
1382 @samp{^} characters. Each difference has one of these seven states:
1383
1384 @table @asis
1385 @item A
1386 The difference is showing the A version. The @kbd{a} command always
1387 produces this state; the mode line indicates it with @samp{A}.
1388
1389 @item B
1390 The difference is showing the B version. The @kbd{b} command always
1391 produces this state; the mode line indicates it with @samp{B}.
1392
1393 @item default-A
1394 @itemx default-B
1395 The difference is showing the A or the B state by default, because you
1396 haven't made a choice. All differences start in the default-A state
1397 (and thus the merge buffer is a copy of the A buffer), except those for
1398 which one alternative is ``preferred'' (see below).
1399
1400 When you select a difference, its state changes from default-A or
1401 default-B to plain A or B. Thus, the selected difference never has
1402 state default-A or default-B, and these states are never displayed in
1403 the mode line.
1404
1405 The command @kbd{d a} chooses default-A as the default state, and @kbd{d
1406 b} chooses default-B. This chosen default applies to all differences
1407 which you haven't ever selected and for which no alternative is preferred.
1408 If you are moving through the merge sequentially, the differences you
1409 haven't selected are those following the selected one. Thus, while
1410 moving sequentially, you can effectively make the A version the default
1411 for some sections of the merge buffer and the B version the default for
1412 others by using @kbd{d a} and @kbd{d b} between sections.
1413
1414 @item prefer-A
1415 @itemx prefer-B
1416 The difference is showing the A or B state because it is
1417 @dfn{preferred}. This means that you haven't made an explicit choice,
1418 but one alternative seems likely to be right because the other
1419 alternative agrees with the common ancestor. Thus, where the A buffer
1420 agrees with the common ancestor, the B version is preferred, because
1421 chances are it is the one that was actually changed.
1422
1423 These two states are displayed in the mode line as @samp{A*} and @samp{B*}.
1424
1425 @item combined
1426 The difference is showing a combination of the A and B states, as a
1427 result of the @kbd{x c} or @kbd{x C} commands.
1428
1429 Once a difference is in this state, the @kbd{a} and @kbd{b} commands
1430 don't do anything to it unless you give them a numeric argument.
1431
1432 The mode line displays this state as @samp{comb}.
1433 @end table
1434
1435 @node Merge Commands
1436 @section Merge Commands
1437
1438 Here are the Merge commands for Fast mode; in Edit mode, precede them
1439 with @kbd{C-c C-c}:
1440
1441 @table @kbd
1442 @item p
1443 Select the previous difference.
1444
1445 @item n
1446 Select the next difference.
1447
1448 @item a
1449 Choose the A version of this difference.
1450
1451 @item b
1452 Choose the B version of this difference.
1453
1454 @item C-u @var{n} j
1455 Select difference number @var{n}.
1456
1457 @item .
1458 Select the difference containing point. You can use this command in the
1459 merge buffer or in the A or B buffer.
1460
1461 @item q
1462 Quit---finish the merge.
1463
1464 @item C-]
1465 Abort---exit merging and do not save the output.
1466
1467 @item f
1468 Go into Fast mode. (In Edit mode, this is actually @kbd{C-c C-c f}.)
1469
1470 @item e
1471 Go into Edit mode.
1472
1473 @item l
1474 Recenter (like @kbd{C-l}) all three windows.
1475
1476 @item -
1477 Specify part of a prefix numeric argument.
1478
1479 @item @var{digit}
1480 Also specify part of a prefix numeric argument.
1481
1482 @item d a
1483 Choose the A version as the default from here down in
1484 the merge buffer.
1485
1486 @item d b
1487 Choose the B version as the default from here down in
1488 the merge buffer.
1489
1490 @item c a
1491 Copy the A version of this difference into the kill ring.
1492
1493 @item c b
1494 Copy the B version of this difference into the kill ring.
1495
1496 @item i a
1497 Insert the A version of this difference at point.
1498
1499 @item i b
1500 Insert the B version of this difference at point.
1501
1502 @item m
1503 Put point and mark around the difference.
1504
1505 @item ^
1506 Scroll all three windows down (like @kbd{M-v}).
1507
1508 @item v
1509 Scroll all three windows up (like @kbd{C-v}).
1510
1511 @item <
1512 Scroll all three windows left (like @kbd{C-x <}).
1513
1514 @item >
1515 Scroll all three windows right (like @kbd{C-x >}).
1516
1517 @item |
1518 Reset horizontal scroll on all three windows.
1519
1520 @item x 1
1521 Shrink the merge window to one line. (Use @kbd{C-u l} to restore it
1522 to full size.)
1523
1524 @item x c
1525 Combine the two versions of this difference (@pxref{Combining in
1526 Emerge}).
1527
1528 @item x f
1529 Show the names of the files/buffers Emerge is operating on, in a Help
1530 window. (Use @kbd{C-u l} to restore windows.)
1531
1532 @item x j
1533 Join this difference with the following one.
1534 (@kbd{C-u x j} joins this difference with the previous one.)
1535
1536 @item x s
1537 Split this difference into two differences. Before you use this
1538 command, position point in each of the three buffers at the place where
1539 you want to split the difference.
1540
1541 @item x t
1542 Trim identical lines off the top and bottom of the difference.
1543 Such lines occur when the A and B versions are
1544 identical but differ from the ancestor version.
1545 @end table
1546
1547 @node Exiting Emerge
1548 @section Exiting Emerge
1549
1550 The @kbd{q} command (@code{emerge-quit}) finishes the merge, storing
1551 the results into the output file if you specified one. It restores the
1552 A and B buffers to their proper contents, or kills them if they were
1553 created by Emerge and you haven't changed them. It also disables the
1554 Emerge commands in the merge buffer, since executing them later could
1555 damage the contents of the various buffers.
1556
1557 @kbd{C-]} aborts the merge. This means exiting without writing the
1558 output file. If you didn't specify an output file, then there is no
1559 real difference between aborting and finishing the merge.
1560
1561 If the Emerge command was called from another Lisp program, then its
1562 return value is @code{t} for successful completion, or @code{nil} if you
1563 abort.
1564
1565 @node Combining in Emerge
1566 @section Combining the Two Versions
1567
1568 Sometimes you want to keep @emph{both} alternatives for a particular
1569 difference. To do this, use @kbd{x c}, which edits the merge buffer
1570 like this:
1571
1572 @example
1573 @group
1574 #ifdef NEW
1575 @var{version from A buffer}
1576 #else /* not NEW */
1577 @var{version from B buffer}
1578 #endif /* not NEW */
1579 @end group
1580 @end example
1581
1582 @noindent
1583 @vindex emerge-combine-versions-template
1584 While this example shows C preprocessor conditionals delimiting the two
1585 alternative versions, you can specify the strings to use by setting
1586 the variable @code{emerge-combine-versions-template} to a string of your
1587 choice. In the string, @samp{%a} says where to put version A, and
1588 @samp{%b} says where to put version B. The default setting, which
1589 produces the results shown above, looks like this:
1590
1591 @example
1592 @group
1593 "#ifdef NEW\n%a#else /* not NEW */\n%b#endif /* not NEW */\n"
1594 @end group
1595 @end example
1596
1597 @node Fine Points of Emerge
1598 @section Fine Points of Emerge
1599
1600 During the merge, you mustn't try to edit the A and B buffers yourself.
1601 Emerge modifies them temporarily, but ultimately puts them back the way
1602 they were.
1603
1604 You can have any number of merges going at once---just don't use any one
1605 buffer as input to more than one merge at once, since the temporary
1606 changes made in these buffers would get in each other's way.
1607
1608 Starting Emerge can take a long time because it needs to compare the
1609 files fully. Emacs can't do anything else until @code{diff} finishes.
1610 Perhaps in the future someone will change Emerge to do the comparison in
1611 the background when the input files are large---then you could keep on
1612 doing other things with Emacs until Emerge is ready to accept
1613 commands.
1614
1615 @vindex emerge-startup-hook
1616 After setting up the merge, Emerge runs the hook
1617 @code{emerge-startup-hook}. @xref{Hooks,,, emacs, the Emacs Manual}.
1618
1619 @node Picture Mode
1620 @chapter Editing Pictures
1621 @cindex pictures
1622 @cindex making pictures out of text characters
1623 @findex edit-picture
1624
1625 To edit a picture made out of text characters (for example, a picture
1626 of the division of a register into fields, as a comment in a program),
1627 use the command @kbd{M-x edit-picture} to enter Picture mode.
1628
1629 In Picture mode, editing is based on the @dfn{quarter-plane} model of
1630 text, according to which the text characters lie studded on an area that
1631 stretches infinitely far to the right and downward. The concept of the end
1632 of a line does not exist in this model; the most you can say is where the
1633 last nonblank character on the line is found.
1634
1635 Of course, Emacs really always considers text as a sequence of
1636 characters, and lines really do have ends. But Picture mode replaces
1637 the most frequently-used commands with variants that simulate the
1638 quarter-plane model of text. They do this by inserting spaces or by
1639 converting tabs to spaces.
1640
1641 Most of the basic editing commands of Emacs are redefined by Picture mode
1642 to do essentially the same thing but in a quarter-plane way. In addition,
1643 Picture mode defines various keys starting with the @kbd{C-c} prefix to
1644 run special picture editing commands.
1645
1646 One of these keys, @kbd{C-c C-c}, is particularly important. Often a
1647 picture is part of a larger file that is usually edited in some other
1648 major mode. @kbd{M-x edit-picture} records the name of the previous
1649 major mode so you can use the @kbd{C-c C-c} command
1650 (@code{picture-mode-exit}) later to go back to that mode. @kbd{C-c C-c}
1651 also deletes spaces from the ends of lines, unless given a numeric
1652 argument.
1653
1654 The special commands of Picture mode all work in other modes (provided
1655 the @file{picture} library is loaded), but are not bound to keys except
1656 in Picture mode. The descriptions below talk of moving ``one column''
1657 and so on, but all the picture mode commands handle numeric arguments as
1658 their normal equivalents do.
1659
1660 @vindex picture-mode-hook
1661 Turning on Picture mode runs the hook @code{picture-mode-hook}.
1662 Additional extensions to Picture mode can be found in
1663 @file{artist.el}.
1664
1665 @menu
1666 * Basic Picture:: Basic concepts and simple commands of Picture Mode.
1667 * Insert in Picture:: Controlling direction of cursor motion
1668 after "self-inserting" characters.
1669 * Tabs in Picture:: Various features for tab stops and indentation.
1670 * Rectangles in Picture:: Clearing and superimposing rectangles.
1671 @end menu
1672
1673 @node Basic Picture
1674 @section Basic Editing in Picture Mode
1675
1676 @findex picture-forward-column
1677 @findex picture-backward-column
1678 @findex picture-move-down
1679 @findex picture-move-up
1680 @cindex editing in Picture mode
1681
1682 Most keys do the same thing in Picture mode that they usually do, but
1683 do it in a quarter-plane style. For example, @kbd{C-f} is rebound to
1684 run @code{picture-forward-column}, a command which moves point one
1685 column to the right, inserting a space if necessary so that the actual
1686 end of the line makes no difference. @kbd{C-b} is rebound to run
1687 @code{picture-backward-column}, which always moves point left one
1688 column, converting a tab to multiple spaces if necessary. @kbd{C-n} and
1689 @kbd{C-p} are rebound to run @code{picture-move-down} and
1690 @code{picture-move-up}, which can either insert spaces or convert tabs
1691 as necessary to make sure that point stays in exactly the same column.
1692 @kbd{C-e} runs @code{picture-end-of-line}, which moves to after the last
1693 nonblank character on the line. There is no need to change @kbd{C-a},
1694 as the choice of screen model does not affect beginnings of
1695 lines.
1696
1697 @findex picture-newline
1698 Insertion of text is adapted to the quarter-plane screen model
1699 through the use of Overwrite mode (@pxref{Minor Modes,,, emacs, the
1700 Emacs Manual}.) Self-inserting characters replace existing text,
1701 column by column, rather than pushing existing text to the right.
1702 @key{RET} runs @code{picture-newline}, which just moves to the
1703 beginning of the following line so that new text will replace that
1704 line.
1705
1706 @findex picture-backward-clear-column
1707 @findex picture-clear-column
1708 @findex picture-clear-line
1709 In Picture mode, the commands that normally delete or kill text,
1710 instead erase text (replacing it with spaces). @key{DEL}
1711 (@code{picture-backward-clear-column}) replaces the preceding
1712 character with a space rather than removing it; this moves point
1713 backwards. @kbd{C-d} (@code{picture-clear-column}) replaces the next
1714 character or characters with spaces, but does not move point. (If you
1715 want to clear characters to spaces and move forward over them, use
1716 @key{SPC}.) @kbd{C-k} (@code{picture-clear-line}) really kills the
1717 contents of lines, but does not delete the newlines from the buffer.
1718
1719 @findex picture-open-line
1720 To do actual insertion, you must use special commands. @kbd{C-o}
1721 (@code{picture-open-line}) creates a blank line after the current
1722 line; it never splits a line. @kbd{C-M-o} (@code{split-line}) makes
1723 sense in Picture mode, so it is not changed. @kbd{C-j}
1724 (@code{picture-duplicate-line}) inserts another line with the same
1725 contents below the current line.
1726
1727 @kindex C-c C-d @r{(Picture mode)}
1728 To do actual deletion in Picture mode, use @kbd{C-w}, @kbd{C-c C-d}
1729 (which is defined as @code{delete-char}, as @kbd{C-d} is in other
1730 modes), or one of the picture rectangle commands (@pxref{Rectangles in
1731 Picture}).
1732
1733 @node Insert in Picture
1734 @section Controlling Motion after Insert
1735
1736 @findex picture-movement-up
1737 @findex picture-movement-down
1738 @findex picture-movement-left
1739 @findex picture-movement-right
1740 @findex picture-movement-nw
1741 @findex picture-movement-ne
1742 @findex picture-movement-sw
1743 @findex picture-movement-se
1744 @kindex C-c < @r{(Picture mode)}
1745 @kindex C-c > @r{(Picture mode)}
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 Since ``self-inserting'' characters in Picture mode overwrite and move
1753 point, there is no essential restriction on how point should be moved.
1754 Normally point moves right, but you can specify any of the eight
1755 orthogonal or diagonal directions for motion after a ``self-inserting''
1756 character. This is useful for drawing lines in the buffer.
1757
1758 @table @kbd
1759 @item C-c <
1760 @itemx C-c @key{LEFT}
1761 Move left after insertion (@code{picture-movement-left}).
1762 @item C-c >
1763 @itemx C-c @key{RIGHT}
1764 Move right after insertion (@code{picture-movement-right}).
1765 @item C-c ^
1766 @itemx C-c @key{UP}
1767 Move up after insertion (@code{picture-movement-up}).
1768 @item C-c .
1769 @itemx C-c @key{DOWN}
1770 Move down after insertion (@code{picture-movement-down}).
1771 @item C-c `
1772 @itemx C-c @key{HOME}
1773 Move up and left (``northwest'') after insertion (@code{picture-movement-nw}).
1774 @item C-c '
1775 @itemx C-c @key{PAGEUP}
1776 Move up and right (``northeast'') after insertion
1777 (@code{picture-movement-ne}).
1778 @item C-c /
1779 @itemx C-c @key{END}
1780 Move down and left (``southwest'') after insertion
1781 @*(@code{picture-movement-sw}).
1782 @item C-c \
1783 @itemx C-c @key{PAGEDOWN}
1784 Move down and right (``southeast'') after insertion
1785 @*(@code{picture-movement-se}).
1786 @end table
1787
1788 @kindex C-c C-f @r{(Picture mode)}
1789 @kindex C-c C-b @r{(Picture mode)}
1790 @findex picture-motion
1791 @findex picture-motion-reverse
1792 Two motion commands move based on the current Picture insertion
1793 direction. The command @kbd{C-c C-f} (@code{picture-motion}) moves in the
1794 same direction as motion after ``insertion'' currently does, while @kbd{C-c
1795 C-b} (@code{picture-motion-reverse}) moves in the opposite direction.
1796
1797 @node Tabs in Picture
1798 @section Picture Mode Tabs
1799
1800 @kindex M-TAB @r{(Picture mode)}
1801 @findex picture-tab-search
1802 @vindex picture-tab-chars
1803 Two kinds of tab-like action are provided in Picture mode. Use
1804 @kbd{M-@key{TAB}} (@code{picture-tab-search}) for context-based tabbing.
1805 With no argument, it moves to a point underneath the next
1806 ``interesting'' character that follows whitespace in the previous
1807 nonblank line. ``Next'' here means ``appearing at a horizontal position
1808 greater than the one point starts out at.'' With an argument, as in
1809 @kbd{C-u M-@key{TAB}}, this command moves to the next such interesting
1810 character in the current line. @kbd{M-@key{TAB}} does not change the
1811 text; it only moves point. ``Interesting'' characters are defined by
1812 the variable @code{picture-tab-chars}, which should define a set of
1813 characters. The syntax for this variable is like the syntax used inside
1814 of @samp{[@dots{}]} in a regular expression---but without the @samp{[}
1815 and the @samp{]}. Its default value is @code{"!-~"}.
1816
1817 @findex picture-tab
1818 @key{TAB} itself runs @code{picture-tab}, which operates based on the
1819 current tab stop settings; it is the Picture mode equivalent of
1820 @code{tab-to-tab-stop}. Normally it just moves point, but with a numeric
1821 argument it clears the text that it moves over.
1822
1823 @kindex C-c TAB @r{(Picture mode)}
1824 @findex picture-set-tab-stops
1825 The context-based and tab-stop-based forms of tabbing are brought
1826 together by the command @kbd{C-c @key{TAB}} (@code{picture-set-tab-stops}).
1827 This command sets the tab stops to the positions which @kbd{M-@key{TAB}}
1828 would consider significant in the current line. The use of this command,
1829 together with @key{TAB}, can get the effect of context-based tabbing. But
1830 @kbd{M-@key{TAB}} is more convenient in the cases where it is sufficient.
1831
1832 It may be convenient to prevent use of actual tab characters in
1833 pictures. For example, this prevents @kbd{C-x @key{TAB}} from messing
1834 up the picture. You can do this by setting the variable
1835 @code{indent-tabs-mode} to @code{nil}.
1836
1837 @node Rectangles in Picture
1838 @section Picture Mode Rectangle Commands
1839 @cindex rectangles and Picture mode
1840 @cindex Picture mode and rectangles
1841
1842 Picture mode defines commands for working on rectangular pieces of
1843 the text in ways that fit with the quarter-plane model. The standard
1844 rectangle commands may also be useful. @xref{Rectangles,,, emacs, the
1845 Emacs Manual}.
1846
1847 @table @kbd
1848 @item C-c C-k
1849 Clear out the region-rectangle with spaces
1850 (@code{picture-clear-rectangle}). With argument, delete the text.
1851 @item C-c C-w @var{r}
1852 Similar, but save rectangle contents in register @var{r} first
1853 (@code{picture-clear-rectangle-to-register}).
1854 @item C-c C-y
1855 Copy last killed rectangle into the buffer by overwriting, with upper
1856 left corner at point (@code{picture-yank-rectangle}). With argument,
1857 insert instead.
1858 @item C-c C-x @var{r}
1859 Similar, but use the rectangle in register @var{r}
1860 (@code{picture-yank-rectangle-from-register}).
1861 @end table
1862
1863 @kindex C-c C-k @r{(Picture mode)}
1864 @kindex C-c C-w @r{(Picture mode)}
1865 @findex picture-clear-rectangle
1866 @findex picture-clear-rectangle-to-register
1867 The picture rectangle commands @kbd{C-c C-k}
1868 (@code{picture-clear-rectangle}) and @kbd{C-c C-w}
1869 (@code{picture-clear-rectangle-to-register}) differ from the standard
1870 rectangle commands in that they normally clear the rectangle instead of
1871 deleting it; this is analogous with the way @kbd{C-d} is changed in Picture
1872 mode.
1873
1874 However, deletion of rectangles can be useful in Picture mode, so
1875 these commands delete the rectangle if given a numeric argument.
1876 @kbd{C-c C-k} either with or without a numeric argument saves the
1877 rectangle for @kbd{C-c C-y}.
1878
1879 @kindex C-c C-y @r{(Picture mode)}
1880 @kindex C-c C-x @r{(Picture mode)}
1881 @findex picture-yank-rectangle
1882 @findex picture-yank-rectangle-from-register
1883 The Picture mode commands for yanking rectangles differ from the
1884 standard ones in that they overwrite instead of inserting. This is
1885 the same way that Picture mode insertion of other text differs from
1886 other modes. @kbd{C-c C-y} (@code{picture-yank-rectangle}) inserts
1887 (by overwriting) the rectangle that was most recently killed, while
1888 @kbd{C-c C-x} (@code{picture-yank-rectangle-from-register}) does
1889 likewise for the rectangle found in a specified register.
1890
1891 @node Fortran
1892 @chapter Fortran Mode
1893 @cindex Fortran mode
1894 @cindex mode, Fortran
1895
1896 Fortran mode provides special motion commands for Fortran statements
1897 and subprograms, and indentation commands that understand Fortran
1898 conventions of nesting, line numbers and continuation statements.
1899 Fortran mode has support for Auto Fill mode that breaks long lines into
1900 proper Fortran continuation lines.
1901
1902 Special commands for comments are provided because Fortran comments
1903 are unlike those of other languages. Built-in abbrevs optionally save
1904 typing when you insert Fortran keywords.
1905
1906 Use @kbd{M-x fortran-mode} to switch to this major mode. This
1907 command runs the hook @code{fortran-mode-hook}. @xref{Hooks,,, emacs,
1908 the Emacs Manual}.
1909
1910 @cindex Fortran77 and Fortran90
1911 @findex f90-mode
1912 @findex fortran-mode
1913 Fortran mode is meant for editing Fortran77 ``fixed format'' (and also
1914 ``tab format'') source code. For editing the modern Fortran90 or
1915 Fortran95 ``free format'' source code, use F90 mode (@code{f90-mode}).
1916 Emacs normally uses Fortran mode for files with extension @samp{.f},
1917 @samp{.F} or @samp{.for}, and F90 mode for the extension @samp{.f90} and
1918 @samp{.f95}. GNU Fortran supports both kinds of format.
1919
1920 @menu
1921 * Motion: Fortran Motion. Moving point by statements or subprograms.
1922 * Indent: Fortran Indent. Indentation commands for Fortran.
1923 * Comments: Fortran Comments. Inserting and aligning comments.
1924 * Autofill: Fortran Autofill. Auto fill support for Fortran.
1925 * Columns: Fortran Columns. Measuring columns for valid Fortran.
1926 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
1927 @end menu
1928
1929 @node Fortran Motion
1930 @section Motion Commands
1931
1932 In addition to the normal commands for moving by and operating on
1933 ``defuns'' (Fortran subprograms---functions and subroutines, as well as
1934 modules for F90 mode), Fortran mode provides special commands to move by
1935 statements and other program units.
1936
1937 @table @kbd
1938 @kindex C-c C-n @r{(Fortran mode)}
1939 @findex fortran-next-statement
1940 @findex f90-next-statement
1941 @item C-c C-n
1942 Move to the beginning of the next statement
1943 (@code{fortran-next-statement}/@code{f90-next-statement}).
1944
1945 @kindex C-c C-p @r{(Fortran mode)}
1946 @findex fortran-previous-statement
1947 @findex f90-previous-statement
1948 @item C-c C-p
1949 Move to the beginning of the previous statement
1950 (@code{fortran-previous-statement}/@code{f90-previous-statement}).
1951 If there is no previous statement (i.e. if called from the first
1952 statement in the buffer), move to the start of the buffer.
1953
1954 @kindex C-c C-e @r{(F90 mode)}
1955 @findex f90-next-block
1956 @item C-c C-e
1957 Move point forward to the start of the next code block
1958 (@code{f90-next-block}). A code block is a subroutine,
1959 @code{if}--@code{endif} statement, and so forth. This command exists
1960 for F90 mode only, not Fortran mode. With a numeric argument, this
1961 moves forward that many blocks.
1962
1963 @kindex C-c C-a @r{(F90 mode)}
1964 @findex f90-previous-block
1965 @item C-c C-a
1966 Move point backward to the previous code block
1967 (@code{f90-previous-block}). This is like @code{f90-next-block}, but
1968 moves backwards.
1969
1970 @kindex C-M-n @r{(Fortran mode)}
1971 @findex fortran-end-of-block
1972 @findex f90-end-of-block
1973 @item C-M-n
1974 Move to the end of the current code block
1975 (@code{fortran-end-of-block}/@code{f90-end-of-block}). With a numeric
1976 agument, move forward that number of blocks. The mark is set before
1977 moving point. The F90 mode version of this command checks for
1978 consistency of block types and labels (if present), but it does not
1979 check the outermost block since that may be incomplete.
1980
1981 @kindex C-M-p @r{(Fortran mode)}
1982 @findex fortran-beginning-of-block
1983 @findex f90-beginning-of-block
1984 @item C-M-p
1985 Move to the start of the current code block
1986 (@code{fortran-beginning-of-block}/@code{f90-beginning-of-block}). This
1987 is like @code{fortran-end-of-block}, but moves backwards.
1988 @end table
1989
1990 @node Fortran Indent
1991 @section Fortran Indentation
1992
1993 Special commands and features are needed for indenting Fortran code in
1994 order to make sure various syntactic entities (line numbers, comment line
1995 indicators and continuation line flags) appear in the columns that are
1996 required for standard, fixed (or tab) format Fortran.
1997
1998 @menu
1999 * Commands: ForIndent Commands. Commands for indenting and filling Fortran.
2000 * Contline: ForIndent Cont. How continuation lines indent.
2001 * Numbers: ForIndent Num. How line numbers auto-indent.
2002 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
2003 * Vars: ForIndent Vars. Variables controlling Fortran indent style.
2004 @end menu
2005
2006 @node ForIndent Commands
2007 @subsection Fortran Indentation and Filling Commands
2008
2009 @table @kbd
2010 @item C-M-j
2011 Break the current line at point and set up a continuation line
2012 (@code{fortran-split-line}).
2013 @item M-^
2014 Join this line to the previous line (@code{fortran-join-line}).
2015 @item C-M-q
2016 Indent all the lines of the subprogram point is in
2017 (@code{fortran-indent-subprogram}).
2018 @item M-q
2019 Fill a comment block or statement.
2020 @end table
2021
2022 @kindex C-M-q @r{(Fortran mode)}
2023 @findex fortran-indent-subprogram
2024 The key @kbd{C-M-q} runs @code{fortran-indent-subprogram}, a command
2025 to reindent all the lines of the Fortran subprogram (function or
2026 subroutine) containing point.
2027
2028 @kindex C-M-j @r{(Fortran mode)}
2029 @findex fortran-split-line
2030 The key @kbd{C-M-j} runs @code{fortran-split-line}, which splits
2031 a line in the appropriate fashion for Fortran. In a non-comment line,
2032 the second half becomes a continuation line and is indented
2033 accordingly. In a comment line, both halves become separate comment
2034 lines.
2035
2036 @kindex M-^ @r{(Fortran mode)}
2037 @kindex C-c C-d @r{(Fortran mode)}
2038 @findex fortran-join-line
2039 @kbd{M-^} or @kbd{C-c C-d} runs the command @code{fortran-join-line},
2040 which joins a continuation line back to the previous line, roughly as
2041 the inverse of @code{fortran-split-line}. The point must be on a
2042 continuation line when this command is invoked.
2043
2044 @kindex M-q @r{(Fortran mode)}
2045 @kbd{M-q} in Fortran mode fills the comment block or statement that
2046 point is in. This removes any excess statement continuations.
2047
2048 @node ForIndent Cont
2049 @subsection Continuation Lines
2050 @cindex Fortran continuation lines
2051
2052 @vindex fortran-continuation-string
2053 Most Fortran77 compilers allow two ways of writing continuation lines.
2054 If the first non-space character on a line is in column 5, then that
2055 line is a continuation of the previous line. We call this @dfn{fixed
2056 format}. (In GNU Emacs we always count columns from 0; but note that
2057 the Fortran standard counts from 1.) The variable
2058 @code{fortran-continuation-string} specifies what character to put in
2059 column 5. A line that starts with a tab character followed by any digit
2060 except @samp{0} is also a continuation line. We call this style of
2061 continuation @dfn{tab format}. (Fortran90 introduced ``free format'',
2062 with another style of continuation lines).
2063
2064 @vindex indent-tabs-mode @r{(Fortran mode)}
2065 @vindex fortran-analyze-depth
2066 @vindex fortran-tab-mode-default
2067 Fortran mode can use either style of continuation line. When you
2068 enter Fortran mode, it tries to deduce the proper continuation style
2069 automatically from the buffer contents. It does this by scanning up to
2070 @code{fortran-analyze-depth} (default 100) lines from the start of the
2071 buffer. The first line that begins with either a tab character or six
2072 spaces determines the choice. If the scan fails (for example, if the
2073 buffer is new and therefore empty), the value of
2074 @code{fortran-tab-mode-default} (@code{nil} for fixed format, and
2075 non-@code{nil} for tab format) is used. @samp{/t} in the mode line
2076 indicates tab format is selected. Fortran mode sets the value of
2077 @code{indent-tabs-mode} accordingly.
2078
2079 If the text on a line starts with the Fortran continuation marker
2080 @samp{$}, or if it begins with any non-whitespace character in column
2081 5, Fortran mode treats it as a continuation line. When you indent a
2082 continuation line with @key{TAB}, it converts the line to the current
2083 continuation style. When you split a Fortran statement with
2084 @kbd{C-M-j}, the continuation marker on the newline is created according
2085 to the continuation style.
2086
2087 The setting of continuation style affects several other aspects of
2088 editing in Fortran mode. In fixed format mode, the minimum column
2089 number for the body of a statement is 6. Lines inside of Fortran
2090 blocks that are indented to larger column numbers always use only the
2091 space character for whitespace. In tab format mode, the minimum
2092 column number for the statement body is 8, and the whitespace before
2093 column 8 must always consist of one tab character.
2094
2095 @node ForIndent Num
2096 @subsection Line Numbers
2097
2098 If a number is the first non-whitespace in the line, Fortran
2099 indentation assumes it is a line number and moves it to columns 0
2100 through 4. (Columns always count from 0 in GNU Emacs.)
2101
2102 @vindex fortran-line-number-indent
2103 Line numbers of four digits or less are normally indented one space.
2104 The variable @code{fortran-line-number-indent} controls this; it
2105 specifies the maximum indentation a line number can have. The default
2106 value of the variable is 1. Fortran mode tries to prevent line number
2107 digits passing column 4, reducing the indentation below the specified
2108 maximum if necessary. If @code{fortran-line-number-indent} has the
2109 value 5, line numbers are right-justified to end in column 4.
2110
2111 @vindex fortran-electric-line-number
2112 Simply inserting a line number is enough to indent it according to
2113 these rules. As each digit is inserted, the indentation is recomputed.
2114 To turn off this feature, set the variable
2115 @code{fortran-electric-line-number} to @code{nil}.
2116
2117
2118 @node ForIndent Conv
2119 @subsection Syntactic Conventions
2120
2121 Fortran mode assumes that you follow certain conventions that simplify
2122 the task of understanding a Fortran program well enough to indent it
2123 properly:
2124
2125 @itemize @bullet
2126 @item
2127 Two nested @samp{do} loops never share a @samp{continue} statement.
2128
2129 @item
2130 Fortran keywords such as @samp{if}, @samp{else}, @samp{then}, @samp{do}
2131 and others are written without embedded whitespace or line breaks.
2132
2133 Fortran compilers generally ignore whitespace outside of string
2134 constants, but Fortran mode does not recognize these keywords if they
2135 are not contiguous. Constructs such as @samp{else if} or @samp{end do}
2136 are acceptable, but the second word should be on the same line as the
2137 first and not on a continuation line.
2138 @end itemize
2139
2140 @noindent
2141 If you fail to follow these conventions, the indentation commands may
2142 indent some lines unaesthetically. However, a correct Fortran program
2143 retains its meaning when reindented even if the conventions are not
2144 followed.
2145
2146 @node ForIndent Vars
2147 @subsection Variables for Fortran Indentation
2148
2149 @vindex fortran-do-indent
2150 @vindex fortran-if-indent
2151 @vindex fortran-structure-indent
2152 @vindex fortran-continuation-indent
2153 @vindex fortran-check-all-num@dots{}
2154 @vindex fortran-minimum-statement-indent@dots{}
2155 Several additional variables control how Fortran indentation works:
2156
2157 @table @code
2158 @item fortran-do-indent
2159 Extra indentation within each level of @samp{do} statement (default 3).
2160
2161 @item fortran-if-indent
2162 Extra indentation within each level of @samp{if}, @samp{select case}, or
2163 @samp{where} statements (default 3).
2164
2165 @item fortran-structure-indent
2166 Extra indentation within each level of @samp{structure}, @samp{union},
2167 @samp{map}, or @samp{interface} statements (default 3).
2168
2169 @item fortran-continuation-indent
2170 Extra indentation for bodies of continuation lines (default 5).
2171
2172 @item fortran-check-all-num-for-matching-do
2173 In Fortran77, a numbered @samp{do} statement is ended by any statement
2174 with a matching line number. It is common (but not compulsory) to use a
2175 @samp{continue} statement for this purpose. If this variable has a
2176 non-@code{nil} value, indenting any numbered statement must check for a
2177 @samp{do} that ends there. If you always end @samp{do} statements with
2178 a @samp{continue} line (or if you use the more modern @samp{enddo}),
2179 then you can speed up indentation by setting this variable to
2180 @code{nil}. The default is @code{nil}.
2181
2182 @item fortran-blink-matching-if
2183 If this is @code{t}, indenting an @samp{endif} (or @samp{enddo}
2184 statement moves the cursor momentarily to the matching @samp{if} (or
2185 @samp{do}) statement to show where it is. The default is @code{nil}.
2186
2187 @item fortran-minimum-statement-indent-fixed
2188 Minimum indentation for Fortran statements when using fixed format
2189 continuation line style. Statement bodies are never indented less than
2190 this much. The default is 6.
2191
2192 @item fortran-minimum-statement-indent-tab
2193 Minimum indentation for Fortran statements for tab format continuation line
2194 style. Statement bodies are never indented less than this much. The
2195 default is 8.
2196 @end table
2197
2198 The variables controlling the indentation of comments are described in
2199 the following section.
2200
2201 @node Fortran Comments
2202 @section Fortran Comments
2203
2204 The usual Emacs comment commands assume that a comment can follow a
2205 line of code. In Fortran77, the standard comment syntax requires an
2206 entire line to be just a comment. Therefore, Fortran mode replaces the
2207 standard Emacs comment commands and defines some new variables.
2208
2209 @vindex fortran-comment-line-start
2210 Fortran mode can also handle the Fortran90 comment syntax where comments
2211 start with @samp{!} and can follow other text. Because only some Fortran77
2212 compilers accept this syntax, Fortran mode will not insert such comments
2213 unless you have said in advance to do so. To do this, set the variable
2214 @code{fortran-comment-line-start} to @samp{"!"}.
2215
2216 @table @kbd
2217 @item M-;
2218 Align comment or insert new comment (@code{fortran-indent-comment}).
2219
2220 @item C-x ;
2221 Applies to nonstandard @samp{!} comments only.
2222
2223 @item C-c ;
2224 Turn all lines of the region into comments, or (with argument) turn them back
2225 into real code (@code{fortran-comment-region}).
2226 @end table
2227
2228 @findex fortran-indent-comment
2229 @kbd{M-;} in Fortran mode is redefined as the command
2230 @code{fortran-indent-comment}. Like the usual @kbd{M-;} command, this
2231 recognizes any kind of existing comment and aligns its text appropriately;
2232 if there is no existing comment, a comment is inserted and aligned. But
2233 inserting and aligning comments are not the same in Fortran mode as in
2234 other modes.
2235
2236 When a new comment must be inserted, if the current line is blank, a
2237 full-line comment is inserted. On a non-blank line, a nonstandard @samp{!}
2238 comment is inserted if you have said you want to use them. Otherwise a
2239 full-line comment is inserted on a new line before the current line.
2240
2241 Nonstandard @samp{!} comments are aligned like comments in other
2242 languages, but full-line comments are different. In a standard full-line
2243 comment, the comment delimiter itself must always appear in column zero.
2244 What can be aligned is the text within the comment. You can choose from
2245 three styles of alignment by setting the variable
2246 @code{fortran-comment-indent-style} to one of these values:
2247
2248 @vindex fortran-comment-indent-style
2249 @vindex fortran-comment-line-extra-indent
2250 @table @code
2251 @item fixed
2252 Align the text at a fixed column, which is the sum of
2253 @code{fortran-comment-line-extra-indent} and the minimum statement
2254 indentation. This is the default.
2255
2256 The minimum statement indentation is
2257 @code{fortran-minimum-statement-indent-fixed} for fixed format
2258 continuation line style and @code{fortran-minimum-statement-indent-tab}
2259 for tab format style.
2260
2261 @item relative
2262 Align the text as if it were a line of code, but with an additional
2263 @code{fortran-comment-line-extra-indent} columns of indentation.
2264
2265 @item nil
2266 Don't move text in full-line comments automatically.
2267 @end table
2268
2269 @vindex fortran-comment-indent-char
2270 In addition, you can specify the character to be used to indent within
2271 full-line comments by setting the variable
2272 @code{fortran-comment-indent-char} to the single-character string you want
2273 to use.
2274
2275 @vindex fortran-directive-re
2276 Compiler directive lines, or preprocessor lines, have much the same
2277 appearance as comment lines. It is important, though, that such lines
2278 never be indented at all, no matter what the value of
2279 @code{fortran-comment-indent-style}. The variable
2280 @code{fortran-directive-re} is a regular expression that specifies which
2281 lines are directives. Matching lines are never indented, and receive
2282 distinctive font-locking.
2283
2284 The normal Emacs comment command @kbd{C-x ;} has not been redefined. If
2285 you use @samp{!} comments, this command can be used with them. Otherwise
2286 it is useless in Fortran mode.
2287
2288 @kindex C-c ; @r{(Fortran mode)}
2289 @findex fortran-comment-region
2290 @vindex fortran-comment-region
2291 The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the
2292 lines of the region into comments by inserting the string @samp{C$$$} at
2293 the front of each one. With a numeric argument, it turns the region
2294 back into live code by deleting @samp{C$$$} from the front of each line
2295 in it. The string used for these comments can be controlled by setting
2296 the variable @code{fortran-comment-region}. Note that here we have an
2297 example of a command and a variable with the same name; these two uses
2298 of the name never conflict because in Lisp and in Emacs it is always
2299 clear from the context which one is meant.
2300
2301 @node Fortran Autofill
2302 @section Auto Fill in Fortran Mode
2303
2304 Fortran mode has specialized support for Auto Fill mode, which is a
2305 minor mode that automatically splits statements as you insert them
2306 when they become too wide. Splitting a statement involves making
2307 continuation lines using @code{fortran-continuation-string}
2308 (@pxref{ForIndent Cont}). This splitting happens when you type
2309 @key{SPC}, @key{RET}, or @key{TAB}, and also in the Fortran
2310 indentation commands. You activate Auto Fill in Fortran mode in the
2311 normal way. @xref{Auto Fill,,, emacs, the Emacs Manual}.
2312
2313 @vindex fortran-break-before-delimiters
2314 Auto Fill breaks lines at spaces or delimiters when the lines get
2315 longer than the desired width (the value of @code{fill-column}). The
2316 delimiters (besides whitespace) that Auto Fill can break at are
2317 @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, @samp{<}, @samp{>},
2318 and @samp{,}. The line break comes after the delimiter if the
2319 variable @code{fortran-break-before-delimiters} is @code{nil}.
2320 Otherwise (and by default), the break comes before the delimiter.
2321
2322 To enable Auto Fill in all Fortran buffers, add
2323 @code{turn-on-auto-fill} to @code{fortran-mode-hook}. @xref{Hooks,,,
2324 emacs, the Emacs Manual}.
2325
2326 @node Fortran Columns
2327 @section Checking Columns in Fortran
2328
2329 @table @kbd
2330 @item C-c C-r
2331 Display a ``column ruler'' momentarily above the current line
2332 (@code{fortran-column-ruler}).
2333 @item C-c C-w
2334 Split the current window horizontally temporarily so that it is 72
2335 columns wide (@code{fortran-window-create-momentarily}). This may
2336 help you avoid making lines longer than the 72-character limit that
2337 some Fortran compilers impose.
2338 @item C-u C-c C-w
2339 Split the current window horizontally so that it is 72 columns wide
2340 (@code{fortran-window-create}). You can then continue editing.
2341 @item M-x fortran-strip-sequence-nos
2342 Delete all text in column 72 and beyond.
2343 @end table
2344
2345 @kindex C-c C-r @r{(Fortran mode)}
2346 @findex fortran-column-ruler
2347 The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column
2348 ruler momentarily above the current line. The comment ruler is two lines
2349 of text that show you the locations of columns with special significance in
2350 Fortran programs. Square brackets show the limits of the columns for line
2351 numbers, and curly brackets show the limits of the columns for the
2352 statement body. Column numbers appear above them.
2353
2354 Note that the column numbers count from zero, as always in GNU Emacs.
2355 As a result, the numbers may be one less than those you are familiar
2356 with; but the positions they indicate in the line are standard for
2357 Fortran.
2358
2359 @vindex fortran-column-ruler-fixed
2360 @vindex fortran-column-ruler-tabs
2361 The text used to display the column ruler depends on the value of the
2362 variable @code{indent-tabs-mode}. If @code{indent-tabs-mode} is
2363 @code{nil}, then the value of the variable
2364 @code{fortran-column-ruler-fixed} is used as the column ruler.
2365 Otherwise, the value of the variable @code{fortran-column-ruler-tab} is
2366 displayed. By changing these variables, you can change the column ruler
2367 display.
2368
2369 @kindex C-c C-w @r{(Fortran mode)}
2370 @findex fortran-window-create-momentarily
2371 @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily
2372 splits the current window horizontally, making a window 72 columns
2373 wide, so you can see any lines that are too long. Type a space to
2374 restore the normal width.
2375
2376 @kindex C-u C-c C-w @r{(Fortran mode)}
2377 @findex fortran-window-create
2378 You can also split the window horizontally and continue editing with
2379 the split in place. To do this, use @kbd{C-u C-c C-w} (@code{M-x
2380 fortran-window-create}). By editing in this window you can
2381 immediately see when you make a line too wide to be correct Fortran.
2382
2383 @findex fortran-strip-sequence-nos
2384 The command @kbd{M-x fortran-strip-sequence-nos} deletes all text in
2385 column 72 and beyond, on all lines in the current buffer. This is the
2386 easiest way to get rid of old sequence numbers.
2387
2388 @node Fortran Abbrev
2389 @section Fortran Keyword Abbrevs
2390
2391 Fortran mode provides many built-in abbrevs for common keywords and
2392 declarations. These are the same sort of abbrev that you can define
2393 yourself. To use them, you must turn on Abbrev mode.
2394 @xref{Abbrevs,,, emacs, the Emacs Manual}.
2395
2396 The built-in abbrevs are unusual in one way: they all start with a
2397 semicolon. You cannot normally use semicolon in an abbrev, but Fortran
2398 mode makes this possible by changing the syntax of semicolon to ``word
2399 constituent.''
2400
2401 For example, one built-in Fortran abbrev is @samp{;c} for
2402 @samp{continue}. If you insert @samp{;c} and then insert a punctuation
2403 character such as a space or a newline, the @samp{;c} expands automatically
2404 to @samp{continue}, provided Abbrev mode is enabled.@refill
2405
2406 Type @samp{;?} or @samp{;C-h} to display a list of all the built-in
2407 Fortran abbrevs and what they stand for.
2408
2409 @node Index
2410 @unnumbered Index
2411
2412 @printindex cp
2413
2414 @bye
2415
2416 @ignore
2417 arch-tag: 75c33f13-32c6-41b6-9537-847a312e2e49
2418 @end ignore