This commit was generated by cvs2svn to compensate for changes in r5670,
[chise/xemacs-chise.git.1] / info / xemacs.info-11
1 This is Info file ../../info/xemacs.info, produced by Makeinfo version
2 1.68 from the input file xemacs.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * XEmacs: (xemacs).             XEmacs Editor.
7 END-INFO-DIR-ENTRY
8
9    This file documents the XEmacs editor.
10
11    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
12 1991, 1992, 1993, 1994 Lucid, Inc.  Copyright (C) 1993, 1994 Sun
13 Microsystems, Inc.  Copyright (C) 1995 Amdahl Corporation.
14
15    Permission is granted to make and distribute verbatim copies of this
16 manual provided the copyright notice and this permission notice are
17 preserved on all copies.
18
19    Permission is granted to copy and distribute modified versions of
20 this manual under the conditions for verbatim copying, provided also
21 that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
22 General Public License" are included exactly as in the original, and
23 provided that the entire resulting derived work is distributed under the
24 terms of a permission notice identical to this one.
25
26    Permission is granted to copy and distribute translations of this
27 manual into another language, under the above conditions for modified
28 versions, except that the sections entitled "The GNU Manifesto",
29 "Distribution" and "GNU General Public License" may be included in a
30 translation approved by the author instead of in the original English.
31
32 \1f
33 File: xemacs.info,  Node: Change Log,  Next: Tags,  Prev: Documentation,  Up: Programs
34
35 Change Logs
36 ===========
37
38    The Emacs command `M-x add-change-log-entry' helps you keep a record
39 of when and why you have changed a program.  It assumes that you have a
40 file in which you write a chronological sequence of entries describing
41 individual changes.  The default is to store the change entries in a
42 file called `ChangeLog' in the same directory as the file you are
43 editing.  The same `ChangeLog' file therefore records changes for all
44 the files in a directory.
45
46    A change log entry starts with a header line that contains your name
47 and the current date.  Except for these header lines, every line in the
48 change log starts with a tab.  One entry can describe several changes;
49 each change starts with a line starting with a tab and a star.  `M-x
50 add-change-log-entry' visits the change log file and creates a new entry
51 unless the most recent entry is for today's date and your name.  In
52 either case, it adds a new line to start the description of another
53 change just after the header line of the entry.  When `M-x
54 add-change-log-entry' is finished, all is prepared for you to edit in
55 the description of what you changed and how.  You must then save the
56 change log file yourself.
57
58    The change log file is always visited in Indented Text mode, which
59 means that <LFD> and auto-filling indent each new line like the previous
60 line.  This is convenient for entering the contents of an entry, which
61 must be indented.  *Note Text Mode::.
62
63    Here is an example of the formatting conventions used in the change
64 log for Emacs:
65
66      Wed Jun 26 19:29:32 1985  Richard M. Stallman  (rms at mit-prep)
67      
68              * xdisp.c (try_window_id):
69              If C-k is done at end of next-to-last line,
70              this fn updates window_end_vpos and cannot leave
71              window_end_pos nonnegative (it is zero, in fact).
72              If display is preempted before lines are output,
73              this is inconsistent.  Fix by setting
74              blank_end_of_window to nonzero.
75      
76      Tue Jun 25 05:25:33 1985  Richard M. Stallman  (rms at mit-prep)
77      
78              * cmds.c (Fnewline):
79              Call the auto fill hook if appropriate.
80      
81              * xdisp.c (try_window_id):
82              If point is found by compute_motion after xp, record that
83              permanently.  If display_text_line sets point position wrong
84              (case where line is killed, point is at eob and that line is
85              not displayed), set it again in final compute_motion.
86
87 \1f
88 File: xemacs.info,  Node: Tags,  Next: Fortran,  Prev: Change Log,  Up: Programs
89
90 Tags Tables
91 ===========
92
93    A "tags table" is a description of how a multi-file program is
94 broken up into files.  It lists the names of the component files and the
95 names and positions of the functions (or other named subunits) in each
96 file.  Grouping the related files makes it possible to search or replace
97 through all the files with one command.  Recording the function names
98 and positions makes possible the `M-.'  command which finds the
99 definition of a function by looking up which of the files it is in.
100
101    Tags tables are stored in files called "tags table files".  The
102 conventional name for a tags table file is `TAGS'.
103
104    Each entry in the tags table records the name of one tag, the name
105 of the file that the tag is defined in (implicitly), and the position
106 in that file of the tag's definition.
107
108    Just what names from the described files are recorded in the tags
109 table depends on the programming language of the described file.  They
110 normally include all functions and subroutines, and may also include
111 global variables, data types, and anything else convenient.  Each name
112 recorded is called a "tag".
113
114 * Menu:
115
116 * Tag Syntax::          Tag syntax for various types of code and text files.
117 * Create Tags Table::   Creating a tags table with `etags'.
118 * Select Tags Table::   How to visit a tags table.
119 * Find Tag::            Commands to find the definition of a specific tag.
120 * Tags Search::         Using a tags table for searching and replacing.
121 * List Tags::           Listing and finding tags defined in a file.
122
123 \1f
124 File: xemacs.info,  Node: Tag Syntax,  Next: Create Tags Table,  Up: Tags
125
126 Source File Tag Syntax
127 ----------------------
128
129    Here is how tag syntax is defined for the most popular languages:
130
131    * In C code, any C function or typedef is a tag, and so are
132      definitions of `struct', `union' and `enum'.  `#define' macro
133      definitions and `enum' constants are also tags, unless you specify
134      `--no-defines' when making the tags table.  Similarly, global
135      variables are tags, unless you specify `--no-globals'.  Use of
136      `--no-globals' and `--no-defines' can make the tags table file
137      much smaller.
138
139    * In C++ code, in addition to all the tag constructs of C code,
140      member functions are also recognized, and optionally member
141      variables if you use the `--members' option.  Tags for variables
142      and functions in classes are named `CLASS::VARIABLE' and
143      `CLASS::FUNCTION'.
144
145    * In Java code, tags include all the constructs recognized in C++,
146      plus the `extends' and `implements' constructs.  Tags for variables
147      and functions in classes are named `CLASS.VARIABLE' and
148      `CLASS.FUNCTION'.
149
150    * In LaTeX text, the argument of any of the commands `\chapter',
151      `\section', `\subsection', `\subsubsection', `\eqno', `\label',
152      `\ref', `\cite', `\bibitem', `\part', `\appendix', `\entry', or
153      `\index', is a tag.
154
155      Other commands can make tags as well, if you specify them in the
156      environment variable `TEXTAGS' before invoking `etags'.  The value
157      of this environment variable should be a colon-separated list of
158      commands names.  For example,
159
160           TEXTAGS="def:newcommand:newenvironment"
161           export TEXTAGS
162
163      specifies (using Bourne shell syntax) that the commands `\def',
164      `\newcommand' and `\newenvironment' also define tags.
165
166    * In Lisp code, any function defined with `defun', any variable
167      defined with `defvar' or `defconst', and in general the first
168      argument of any expression that starts with `(def' in column zero,
169      is a tag.
170
171    * In Scheme code, tags include anything defined with `def' or with a
172      construct whose name starts with `def'.  They also include
173      variables set with `set!' at top level in the file.
174
175    Several other languages are also supported:
176
177    * In assembler code, labels appearing at the beginning of a line,
178      followed by a colon, are tags.
179
180    * In Bison or Yacc input files, each rule defines as a tag the
181      nonterminal it constructs.  The portions of the file that contain
182      C code are parsed as C code.
183
184    * In Cobol code, paragraphs names are the tags, i.e. any word
185      starting in column 8 and followed by a full stop.
186
187    * In Erlang code, the tags are the functions, records, and macros
188      defined in the file.
189
190    * In Fortran code, functions and subroutines are tags.
191
192    * In Objective C code, tags include Objective C definitions for
193      classes, class categories, methods and protocols.
194
195    * In Pascal code, the tags are the functions and procedures defined
196      in the file.
197
198    * In Perl code, the tags are the procedures defined by the `sub'
199      keyword.
200
201    * In Postscript code, the tags are the functions.
202
203    * In Prolog code, a tag name appears at the left margin.
204
205    You can also generate tags based on regexp matching (*note Create
206 Tags Table::.) to handle other formats and languages.
207
208 \1f
209 File: xemacs.info,  Node: Create Tags Table,  Next: Select Tags Table,  Prev: Tag Syntax,  Up: Tags
210
211 Creating Tags Tables
212 --------------------
213
214    The `etags' program is used to create a tags table file.  It knows
215 the syntax of several languages, as described in *Note Tag Syntax::.
216 Here is how to run `etags':
217
218      etags INPUTFILES...
219
220 The `etags' program reads the specified files, and writes a tags table
221 named `TAGS' in the current working directory.  `etags' recognizes the
222 language used in an input file based on its file name and contents.
223 You can specify the language with the `--language=NAME' option,
224 described below.
225
226    If the tags table data become outdated due to changes in the files
227 described in the table, the way to update the tags table is the same
228 way it was made in the first place.  It is not necessary to do this
229 often.
230
231    If the tags table fails to record a tag, or records it for the wrong
232 file, then Emacs cannot possibly find its definition.  However, if the
233 position recorded in the tags table becomes a little bit wrong (due to
234 some editing in the file that the tag definition is in), the only
235 consequence is a slight delay in finding the tag.  Even if the stored
236 position is very wrong, Emacs will still find the tag, but it must
237 search the entire file for it.
238
239    So you should update a tags table when you define new tags that you
240 want to have listed, or when you move tag definitions from one file to
241 another, or when changes become substantial.  Normally there is no need
242 to update the tags table after each edit, or even every day.
243
244    One tags table can effectively include another.  Specify the included
245 tags file name with the `--include=FILE' option when creating the file
246 that is to include it.  The latter file then acts as if it contained
247 all the files specified in the included file, as well as the files it
248 directly contains.
249
250    If you specify the source files with relative file names when you run
251 `etags', the tags file will contain file names relative to the
252 directory where the tags file was initially written.  This way, you can
253 move an entire directory tree containing both the tags file and the
254 source files, and the tags file will still refer correctly to the source
255 files.
256
257    If you specify absolute file names as arguments to `etags', then the
258 tags file will contain absolute file names.  This way, the tags file
259 will still refer to the same files even if you move it, as long as the
260 source files remain in the same place.  Absolute file names start with
261 `/', or with `DEVICE:/' on MS-DOS and Windows.
262
263    When you want to make a tags table from a great number of files, you
264 may have problems listing them on the command line, because some systems
265 have a limit on its length.  The simplest way to circumvent this limit
266 is to tell `etags' to read the file names from its standard input, by
267 typing a dash in place of the file names, like this:
268
269      find . -name "*.[chCH]" -print | etags -
270
271    Use the option `--language=NAME' to specify the language explicitly.
272 You can intermix these options with file names; each one applies to
273 the file names that follow it.  Specify `--language=auto' to tell
274 `etags' to resume guessing the language from the file names and file
275 contents.  Specify `--language=none' to turn off language-specific
276 processing entirely; then `etags' recognizes tags by regexp matching
277 alone.  `etags --help' prints the list of the languages `etags' knows,
278 and the file name rules for guessing the language.
279
280    The `--regex' option provides a general way of recognizing tags
281 based on regexp matching.  You can freely intermix it with file names.
282 Each `--regex' option adds to the preceding ones, and applies only to
283 the following files.  The syntax is:
284
285      --regex=/TAGREGEXP[/NAMEREGEXP]/
286
287 where TAGREGEXP is used to match the lines to tag.  It is always
288 anchored, that is, it behaves as if preceded by `^'.  If you want to
289 account for indentation, just match any initial number of blanks by
290 beginning your regular expression with `[ \t]*'.  In the regular
291 expressions, `\' quotes the next character, and `\t' stands for the tab
292 character.  Note that `etags' does not handle the other C escape
293 sequences for special characters.
294
295    The syntax of regular expressions in `etags' is the same as in
296 Emacs, augmented with the "interval operator", which works as in `grep'
297 and `ed'.  The syntax of an interval operator is `\{M,N\}', and its
298 meaning is to match the preceding expression at least M times and up to
299 N times.
300
301    You should not match more characters with TAGREGEXP than that needed
302 to recognize what you want to tag.  If the match is such that more
303 characters than needed are unavoidably matched by TAGREGEXP, you may
304 find useful to add a NAMEREGEXP, in order to narrow the tag scope.  You
305 can find some examples below.
306
307    The `-R' option deletes all the regexps defined with `--regex'
308 options.  It applies to the file names following it, as you can see
309 from the following example:
310
311      etags --regex=/REG1/ voo.doo --regex=/REG2/ \
312          bar.ber -R --lang=lisp los.er
313
314 Here `etags' chooses the parsing language for `voo.doo' and `bar.ber'
315 according to their contents.  `etags' also uses REG1 to recognize
316 additional tags in `voo.doo', and both REG1 and REG2 to recognize
317 additional tags in `bar.ber'.  `etags' uses the Lisp tags rules, and no
318 regexp matching, to recognize tags in `los.er'.
319
320    Here are some more examples.  The regexps are quoted to protect them
321 from shell interpretation.
322
323 Tag the `DEFVAR' macros in the emacs source files:
324
325      --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
326
327 Tag VHDL files (this example is a single long line, broken here for
328 formatting reasons):
329
330      --language=none
331      --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/'
332      --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
333      \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
334
335 Tag TCL files (this last example shows the usage of a NAMEREGEXP):
336
337      --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
338
339    For a list of the other available `etags' options, execute `etags
340 --help'.
341
342 \1f
343 File: xemacs.info,  Node: Select Tags Table,  Next: Find Tag,  Prev: Create Tags Table,  Up: Tags
344
345 Selecting a Tags Table
346 ----------------------
347
348    At any time Emacs has one "selected" tags table, and all the commands
349 for working with tags tables use the selected one.  To select a tags
350 table, use the variable `tag-table-alist'.
351
352    The value of `tag-table-alist' is a list that determines which
353 `TAGS' files should be active for a given buffer.  This is not really
354 an association list, in that all elements are checked.  The car of each
355 element of this list is a pattern against which the buffers file name
356 is compared; if it matches, then the cdr of the list should be the name
357 of the tags table to use.  If more than one element of this list
358 matches the buffers file name, all of the associated tags tables are
359 used.  Earlier ones are searched first.
360
361    If the car of elements of this list are strings, they are treated as
362 regular-expressions against which the file is compared (like the
363 `auto-mode-alist').  If they are not strings, they are evaluated.  If
364 they evaluate to non-`nil', the current buffer is considered to match.
365
366    If the cdr of the elements of this list are strings, they are
367 assumed to name a tags file.  If they name a directory, the string
368 `tags' is appended to them to get the file name.  If they are not
369 strings, they are evaluated and must return an appropriate string.
370
371    For example:
372
373        (setq tag-table-alist
374         '(("/usr/src/public/perl/" . "/usr/src/public/perl/perl-3.0/")
375           ("\\.el$" . "/usr/local/emacs/src/")
376           ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
377           ("" . "/usr/local/emacs/src/")
378           ))
379
380    The example defines the tags table alist in the following way:
381
382    * Anything in the directory `/usr/src/public/perl/' should use the
383      `TAGS' file `/usr/src/public/perl/perl-3.0/TAGS'.
384
385    * Files ending in `.el' should use the `TAGS' file
386      `/usr/local/emacs/src/TAGS'.
387
388    * Anything in or below the directory `/jbw/gnu/' should use the
389      `TAGS' file `/usr15/degree/stud/jbw/gnu/TAGS'.
390
391    If you had a file called `/usr/jbw/foo.el', it would use both `TAGS'
392 files,
393 `/usr/local/emacs/src/TAGS' and `/usr15/degree/stud/jbw/gnu/TAGS' (in
394 that order), because it matches both patterns.
395
396    If the buffer-local variable `buffer-tag-table' is set, it names a
397 tags table that is searched before all others when `find-tag' is
398 executed from this buffer.
399
400    If there is a file called `TAGS' in the same directory as the file
401 in question, then that tags file will always be used as well (after the
402 `buffer-tag-table' but before the tables specified by this list).
403
404    If the variable `tags-file-name' is set, the `TAGS' file it names
405 will apply to all buffers (for backwards compatibility.)  It is searched
406 first.
407
408    If the value of the variable `tags-always-build-completion-table' is
409 `t', the tags file will always be added to the completion table without
410 asking first, regardless of the size of the tags file.
411
412    The function `M-x visit-tags-table', is largely made obsolete by the
413 variable `tag-table-alist', tells tags commands to use the tags table
414 file FILE first.  The FILE should be the name of a file created with
415 the `etags' program.  A directory name is also acceptable; it means the
416 file `TAGS' in that directory.  The function only stores the file name
417 you provide in the variable `tags-file-name'.  Emacs does not actually
418 read in the tags table contents until you try to use them.  You can set
419 the variable explicitly instead of using `visit-tags-table'.  The value
420 of the variable `tags-file-name' is the name of the tags table used by
421 all buffers.  This is for backward compatibility, and is largely
422 supplanted by the variable `tag-table-alist'.
423
424 \1f
425 File: xemacs.info,  Node: Find Tag,  Next: Tags Search,  Prev: Select Tags Table,  Up: Tags
426
427 Finding a Tag
428 -------------
429
430    The most important thing that a tags table enables you to do is to
431 find the definition of a specific tag.
432
433 `M-. TAG &OPTIONAL OTHER-WINDOW'
434      Find first definition of TAG (`find-tag').
435
436 `C-u M-.'
437      Find next alternate definition of last tag specified.
438
439 `C-x 4 . TAG'
440      Find first definition of TAG, but display it in another window
441      (`find-tag-other-window').
442
443    `M-.' (`find-tag') is the command to find the definition of a
444 specified tag.  It searches through the tags table for that tag, as a
445 string, then uses the tags table information to determine the file in
446 which the definition is used and the approximate character position of
447 the definition in the file.  Then `find-tag' visits the file, moves
448 point to the approximate character position, and starts searching
449 ever-increasing distances away for the text that should appear at the
450 beginning of the definition.
451
452    If an empty argument is given (by typing <RET>), the sexp in the
453 buffer before or around point is used as the name of the tag to find.
454 *Note Lists::, for information on sexps.
455
456    The argument to `find-tag' need not be the whole tag name; it can be
457 a substring of a tag name.  However, there can be many tag names
458 containing the substring you specify.  Since `find-tag' works by
459 searching the text of the tags table, it finds the first tag in the
460 table that the specified substring appears in.  To find other tags that
461 match the substring, give `find-tag' a numeric argument, as in `C-u
462 M-.'.  This does not read a tag name, but continues searching the tag
463 table's text for another tag containing the same substring last used.
464 If your keyboard has a real <META> key, `M-0 M-.' is an easier
465 alternative to `C-u M-.'.
466
467    If the optional second argument OTHER-WINDOW is non-`nil', it uses
468 another window to display the tag.  Multiple active tags tables and
469 completion are supported.
470
471    Variables of note include the following:
472
473 `tag-table-alist'
474      Controls which tables apply to which buffers.
475
476 `tags-file-name'
477      Stores a default tags table.
478
479 `tags-build-completion-table'
480      Controls completion behavior.
481
482 `buffer-tag-table'
483      Specifies a buffer-local table.
484
485 `make-tags-files-invisible'
486      Sets whether tags tables should be very hidden.
487
488 `tag-mark-stack-max'
489      Specifies how many tags-based hops to remember.
490
491    Like most commands that can switch buffers, `find-tag' has another
492 similar command that displays the new buffer in another window.  `C-x 4
493 .' invokes the function `find-tag-other-window'.  (This key sequence
494 ends with a period.)
495
496    Emacs comes with a tags table file `TAGS' (in the directory
497 containing Lisp libraries) that includes all the Lisp libraries and all
498 the C sources of Emacs.  By specifying this file with `visit-tags-table'
499 and then using `M-.' you can quickly look at the source of any Emacs
500 function.
501
502 \1f
503 File: xemacs.info,  Node: Tags Search,  Next: List Tags,  Prev: Find Tag,  Up: Tags
504
505 Searching and Replacing with Tags Tables
506 ----------------------------------------
507
508    The commands in this section visit and search all the files listed
509 in the selected tags table, one by one.  For these commands, the tags
510 table serves only to specify a sequence of files to search.  A related
511 command is `M-x grep' (*note Compilation::.).
512
513 `M-x tags-search <RET> REGEXP <RET>'
514      Search for REGEXP through the files in the selected tags table.
515
516 `M-x tags-query-replace <RET> REGEXP <RET> REPLACEMENT <RET>'
517      Perform a `query-replace-regexp' on each file in the selected tags
518      table.
519
520 `M-,'
521      Restart one of the commands above, from the current location of
522      point (`tags-loop-continue').
523
524    `M-x tags-search' reads a regexp using the minibuffer, then searches
525 for matches in all the files in the selected tags table, one file at a
526 time.  It displays the name of the file being searched so you can
527 follow its progress.  As soon as it finds an occurrence, `tags-search'
528 returns.
529
530    Having found one match, you probably want to find all the rest.  To
531 find one more match, type `M-,' (`tags-loop-continue') to resume the
532 `tags-search'.  This searches the rest of the current buffer, followed
533 by the remaining files of the tags table.
534
535    `M-x tags-query-replace' performs a single `query-replace-regexp'
536 through all the files in the tags table.  It reads a regexp to search
537 for and a string to replace with, just like ordinary `M-x
538 query-replace-regexp'.  It searches much like `M-x tags-search', but
539 repeatedly, processing matches according to your input.  *Note
540 Replace::, for more information on query replace.
541
542    It is possible to get through all the files in the tags table with a
543 single invocation of `M-x tags-query-replace'.  But often it is useful
544 to exit temporarily, which you can do with any input event that has no
545 special query replace meaning.  You can resume the query replace
546 subsequently by typing `M-,'; this command resumes the last tags search
547 or replace command that you did.
548
549    The commands in this section carry out much broader searches than the
550 `find-tag' family.  The `find-tag' commands search only for definitions
551 of tags that match your substring or regexp.  The commands
552 `tags-search' and `tags-query-replace' find every occurrence of the
553 regexp, as ordinary search commands and replace commands do in the
554 current buffer.
555
556    These commands create buffers only temporarily for the files that
557 they have to search (those which are not already visited in Emacs
558 buffers).  Buffers in which no match is found are quickly killed; the
559 others continue to exist.
560
561    It may have struck you that `tags-search' is a lot like `grep'.  You
562 can also run `grep' itself as an inferior of Emacs and have Emacs show
563 you the matching lines one by one.  This works much like running a
564 compilation; finding the source locations of the `grep' matches works
565 like finding the compilation errors.  *Note Compilation::.
566
567    If you wish to process all the files in a selected tags table, but
568 `M-x tags-search' and `M-x tags-query-replace' are not giving you the
569 desired result, you can use `M-x next-file'.
570
571 `C-u M-x next-file'
572      With a numeric argument, regardless of its value, visit the first
573      file in the tags table and prepare to advance sequentially by
574      files.
575
576 `M-x next-file'
577      Visit the next file in the selected tags table.
578
579 \1f
580 File: xemacs.info,  Node: List Tags,  Prev: Tags Search,  Up: Tags
581
582 Tags Table Inquiries
583 --------------------
584
585 `M-x list-tags'
586      Display a list of the tags defined in a specific program file.
587
588 `M-x tags-apropos'
589      Display a list of all tags matching a specified regexp.
590
591    `M-x list-tags' reads the name of one of the files described by the
592 selected tags table, and displays a list of all the tags defined in that
593 file.  The "file name" argument is really just a string to compare
594 against the names recorded in the tags table; it is read as a string
595 rather than a file name.  Therefore, completion and defaulting are not
596 available, and you must enter the string the same way it appears in the
597 tag table.  Do not include a directory as part of the file name unless
598 the file name recorded in the tags table contains that directory.
599
600    `M-x tags-apropos' is like `apropos' for tags.  It reads a regexp,
601 then finds all the tags in the selected tags table whose entries match
602 that regexp, and displays the tag names found.
603
604 \1f
605 File: xemacs.info,  Node: Fortran,  Next: Asm Mode,  Prev: Tags,  Up: Programs
606
607 Fortran Mode
608 ============
609
610    Fortran mode provides special motion commands for Fortran statements
611 and subprograms, and indentation commands that understand Fortran
612 conventions of nesting, line numbers, and continuation statements.
613
614    Special commands for comments are provided because Fortran comments
615 are unlike those of other languages.
616
617    Built-in abbrevs optionally save typing when you insert Fortran
618 keywords.
619
620    Use `M-x fortran-mode' to switch to this major mode.  Doing so calls
621 the value of `fortran-mode-hook' as a function of no arguments if that
622 variable has a non-`nil' value.
623
624 * Menu:
625
626 * Motion: Fortran Motion.     Moving point by statements or subprograms.
627 * Indent: Fortran Indent.     Indentation commands for Fortran.
628 * Comments: Fortran Comments. Inserting and aligning comments.
629 * Columns: Fortran Columns.   Measuring columns for valid Fortran.
630 * Abbrev: Fortran Abbrev.     Built-in abbrevs for Fortran keywords.
631
632    Fortran mode was contributed by Michael Prange.
633
634 \1f
635 File: xemacs.info,  Node: Fortran Motion,  Next: Fortran Indent,  Prev: Fortran,  Up: Fortran
636
637 Motion Commands
638 ---------------
639
640    Fortran mode provides special commands to move by subprograms
641 (functions and subroutines) and by statements.  There is also a command
642 to put the region around one subprogram, which is convenient for
643 killing it or moving it.
644
645 `C-M-a'
646      Move to beginning of subprogram
647      (`beginning-of-fortran-subprogram').
648
649 `C-M-e'
650      Move to end of subprogram (`end-of-fortran-subprogram').
651
652 `C-M-h'
653      Put point at beginning of subprogram and mark at end
654      (`mark-fortran-subprogram').
655
656 `C-c C-n'
657      Move to beginning of current or next statement (`fortran-next-
658      statement').
659
660 `C-c C-p'
661      Move to beginning of current or previous statement (`fortran-
662      previous-statement').
663
664 \1f
665 File: xemacs.info,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
666
667 Fortran Indentation
668 -------------------
669
670    Special commands and features are available for indenting Fortran
671 code.  They make sure various syntactic entities (line numbers, comment
672 line indicators, and continuation line flags) appear in the columns
673 that are required for standard Fortran.
674
675 * Menu:
676
677 * Commands: ForIndent Commands. Commands for indenting Fortran.
678 * Numbers:  ForIndent Num.      How line numbers auto-indent.
679 * Conv:     ForIndent Conv.     Conventions you must obey to avoid trouble.
680 * Vars:     ForIndent Vars.     Variables controlling Fortran indent style.
681
682 \1f
683 File: xemacs.info,  Node: ForIndent Commands,  Next: ForIndent Num,  Prev: Fortran Indent,  Up: Fortran Indent
684
685 Fortran Indentation Commands
686 ............................
687
688 `<TAB>'
689      Indent the current line (`fortran-indent-line').
690
691 `M-<LFD>'
692      Break the current line and set up a continuation line.
693
694 `C-M-q'
695      Indent all the lines of the subprogram point is in
696      (`fortran-indent-subprogram').
697
698    <TAB> is redefined by Fortran mode to reindent the current line for
699 Fortran (`fortran-indent-line').  Line numbers and continuation markers
700 are indented to their required columns, and the body of the statement
701 is independently indented, based on its nesting in the program.
702
703    The key `C-M-q' is redefined as `fortran-indent-subprogram', a
704 command that reindents all the lines of the Fortran subprogram
705 (function or subroutine) containing point.
706
707    The key `M-<LFD>' is redefined as `fortran-split-line', a command to
708 split a line in the appropriate fashion for Fortran.  In a non-comment
709 line, the second half becomes a continuation line and is indented
710 accordingly.  In a comment line, both halves become separate comment
711 lines.
712
713 \1f
714 File: xemacs.info,  Node: ForIndent Num,  Next: ForIndent Conv,  Prev: ForIndent Commands,  Up: Fortran Indent
715
716 Line Numbers and Continuation
717 .............................
718
719    If a number is the first non-whitespace in the line, it is assumed
720 to be a line number and is moved to columns 0 through 4.  (Columns are
721 always counted from 0 in XEmacs.)  If the text on the line starts with
722 the conventional Fortran continuation marker `$', it is moved to column
723 5.  If the text begins with any non whitespace character in column 5,
724 it is assumed to be an unconventional continuation marker and remains
725 in column 5.
726
727    Line numbers of four digits or less are normally indented one space.
728 This amount is controlled by the variable `fortran-line-number-indent',
729 which is the maximum indentation a line number can have.  Line numbers
730 are indented to right-justify them to end in column 4 unless that would
731 require more than the maximum indentation.  The default value of the
732 variable is 1.
733
734    Simply inserting a line number is enough to indent it according to
735 these rules.  As each digit is inserted, the indentation is recomputed.
736 To turn off this feature, set the variable
737 `fortran-electric-line-number' to `nil'.  Then inserting line numbers
738 is like inserting anything else.
739
740 \1f
741 File: xemacs.info,  Node: ForIndent Conv,  Next: ForIndent Vars,  Prev: ForIndent Num,  Up: Fortran Indent
742
743 Syntactic Conventions
744 .....................
745
746    Fortran mode assumes that you follow certain conventions that
747 simplify the task of understanding a Fortran program well enough to
748 indent it properly:
749
750    * Two nested `do' loops never share a `continue' statement.
751
752    * The same character appears in column 5 of all continuation lines.
753      It is the value of the variable `fortran-continuation-char'.  By
754      default, this character is `$'.
755
756 If you fail to follow these conventions, the indentation commands may
757 indent some lines unaesthetically.  However, a correct Fortran program
758 will retain its meaning when reindented even if the conventions are not
759 followed.
760
761 \1f
762 File: xemacs.info,  Node: ForIndent Vars,  Prev: ForIndent Conv,  Up: Fortran Indent
763
764 Variables for Fortran Indentation
765 .................................
766
767    Several additional variables control how Fortran indentation works.
768
769 `fortran-do-indent'
770      Extra indentation within each level of `do' statement (the default
771      is 3).
772
773 `fortran-if-indent'
774      Extra indentation within each level of `if' statement (the default
775      is 3).
776
777 `fortran-continuation-indent'
778      Extra indentation for bodies of continuation lines (the default is
779      5).
780
781 `fortran-check-all-num-for-matching-do'
782      If this is `nil', indentation assumes that each `do' statement
783      ends on a `continue' statement.  Therefore, when computing
784      indentation for a statement other than `continue', it can save
785      time by not checking for a `do' statement ending there.  If this
786      is non-`nil', indenting any numbered statement must check for a
787      `do' that ends there.  The default is `nil'.
788
789 `fortran-minimum-statement-indent'
790      Minimum indentation for Fortran statements.  For standard Fortran,
791      this is 6.  Statement bodies are always indented at least this
792      much.
793
794 \1f
795 File: xemacs.info,  Node: Fortran Comments,  Next: Fortran Columns,  Prev: Fortran Indent,  Up: Fortran
796
797 Comments
798 --------
799
800    The usual Emacs comment commands assume that a comment can follow a
801 line of code.  In Fortran, the standard comment syntax requires an
802 entire line to be just a comment.  Therefore, Fortran mode replaces the
803 standard Emacs comment commands and defines some new variables.
804
805    Fortran mode can also handle a non-standard comment syntax where
806 comments start with `!' and can follow other text.  Because only some
807 Fortran compilers accept this syntax, Fortran mode will not insert such
808 comments unless you have specified to do so in advance by setting the
809 variable `comment-start' to `"!"' (*note Variables::.).
810
811 `M-;'
812      Align comment or insert new comment (`fortran-comment-indent').
813
814 `C-x ;'
815      Applies to nonstandard `!' comments only.
816
817 `C-c ;'
818      Turn all lines of the region into comments, or (with arg) turn
819      them back into real code (`fortran-comment-region').
820
821    `M-;' in Fortran mode is redefined as the command
822 `fortran-comment-indent'.  Like the usual `M-;' command, it recognizes
823 an existing comment and aligns its text appropriately.  If there is no
824 existing comment, a comment is inserted and aligned.
825
826    Inserting and aligning comments is not the same in Fortran mode as in
827 other modes.  When a new comment must be inserted, a full-line comment
828 is inserted if the current line is blank.  On a non-blank line, a
829 non-standard `!' comment is inserted if you previously specified you
830 wanted to use them.  Otherwise a full-line comment is inserted on a new
831 line before the current line.
832
833    Non-standard `!' comments are aligned like comments in other
834 languages, but full-line comments are aligned differently.  In a
835 standard full-line comment, the comment delimiter itself must always
836 appear in column zero.  What can be aligned is the text within the
837 comment.  You can choose from three styles of alignment by setting the
838 variable `fortran-comment-indent-style' to one of these values:
839
840 `fixed'
841      The text is aligned at a fixed column, which is the value of
842      `fortran-comment-line-column'.  This is the default.
843
844 `relative'
845      The text is aligned as if it were a line of code, but with an
846      additional `fortran-comment-line-column' columns of indentation.
847
848 `nil'
849      Text in full-line columns is not moved automatically.
850
851    You can also specify the character to be used to indent within
852 full-line comments by setting the variable `fortran-comment-indent-char'
853 to the character you want to use.
854
855    Fortran mode introduces two variables `comment-line-start' and
856 `comment-line-start-skip', which do for full-line comments what
857 `comment-start' and `comment-start-skip' do for ordinary text-following
858 comments.  Normally these are set properly by Fortran mode, so you do
859 not need to change them.
860
861    The normal Emacs comment command `C-x ;' has not been redefined.  It
862 can therefore be used if you use `!' comments, but is useless in
863 Fortran mode otherwise.
864
865    The command `C-c ;' (`fortran-comment-region') turns all the lines
866 of the region into comments by inserting the string `C$$$' at the front
867 of each one.  With a numeric arg, the region is turned back into live
868 code by deleting `C$$$' from the front of each line.  You can control
869 the string used for the comments by setting the variable
870 `fortran-comment-region'.  Note that here we have an example of a
871 command and a variable with the same name; the two uses of the name
872 never conflict because in Lisp and in Emacs it is always clear from the
873 context which one is referred to.
874
875 \1f
876 File: xemacs.info,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Comments,  Up: Fortran
877
878 Columns
879 -------
880
881 `C-c C-r'
882      Displays a "column ruler" momentarily above the current line
883      (`fortran-column-ruler').
884
885 `C-c C-w'
886      Splits the current window horizontally so that it is 72 columns
887      wide.  This may help you avoid going over that limit
888      (`fortran-window-create').
889
890    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
891 above the current line.  The comment ruler consists of two lines of
892 text that show you the locations of columns with special significance
893 in Fortran programs.  Square brackets show the limits of the columns for
894 line numbers, and curly brackets show the limits of the columns for the
895 statement body.  Column numbers appear above them.
896
897    Note that the column numbers count from zero, as always in XEmacs.
898 As a result, the numbers may not be those you are familiar with; but the
899 actual positions in the line are standard Fortran.
900
901    The text used to display the column ruler is the value of the
902 variable `fortran-comment-ruler'.  By changing this variable, you can
903 change the display.
904
905    For even more help, use `C-c C-w' (`fortran-window-create'), a
906 command which splits the current window horizontally, resulting in a
907 window 72 columns wide.  When you edit in this window, you can
908 immediately see when a line gets too wide to be correct Fortran.
909
910 \1f
911 File: xemacs.info,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
912
913 Fortran Keyword Abbrevs
914 -----------------------
915
916    Fortran mode provides many built-in abbrevs for common keywords and
917 declarations.  These are the same sort of abbrevs that you can define
918 yourself.  To use them, you must turn on Abbrev mode.  *note Abbrevs::..
919
920    The built-in abbrevs are unusual in one way: they all start with a
921 semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
922 mode makes this possible by changing the syntax of semicolon to "word
923 constituent".
924
925    For example, one built-in Fortran abbrev is `;c' for `continue'.  If
926 you insert `;c' and then insert a punctuation character such as a space
927 or a newline, the `;c' changes automatically to `continue', provided
928 Abbrev mode is enabled.
929
930    Type `;?' or `;C-h' to display a list of all built-in Fortran
931 abbrevs and what they stand for.
932
933 \1f
934 File: xemacs.info,  Node: Asm Mode,  Prev: Fortran,  Up: Programs
935
936 Asm Mode
937 ========
938
939    Asm mode is a major mode for editing files of assembler code.  It
940 defines these commands:
941
942 `<TAB>'
943      `tab-to-tab-stop'.
944
945 `<LFD>'
946      Insert a newline and then indent using `tab-to-tab-stop'.
947
948 `:'
949      Insert a colon and then remove the indentation from before the
950      label preceding colon.  Then do `tab-to-tab-stop'.
951
952 `;'
953      Insert or align a comment.
954
955    The variable `asm-comment-char' specifies which character starts
956 comments in assembler syntax.
957
958 \1f
959 File: xemacs.info,  Node: Running,  Next: Packages,  Prev: Programs,  Up: Top
960
961 Compiling and Testing Programs
962 ******************************
963
964    The previous chapter discusses the Emacs commands that are useful for
965 making changes in programs.  This chapter deals with commands that
966 assist in the larger process of developing and maintaining programs.
967
968 * Menu:
969
970 * Compilation::        Compiling programs in languages other than Lisp
971                         (C, Pascal, etc.)
972 * Modes: Lisp Modes.   Various modes for editing Lisp programs, with
973                        different facilities for running the Lisp programs.
974 * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
975 * Eval: Lisp Eval.     Executing a single Lisp expression in Emacs.
976 * Debug: Lisp Debug.   Debugging Lisp programs running in Emacs.
977 * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
978 * External Lisp::      Communicating through Emacs with a separate Lisp.
979
980 \1f
981 File: xemacs.info,  Node: Compilation,  Next: Lisp Modes,  Prev: Running,  Up: Running
982
983 Running "make", or Compilers Generally
984 ======================================
985
986    Emacs can run compilers for non-interactive languages like C and
987 Fortran as inferior processes, feeding the error log into an Emacs
988 buffer.  It can also parse the error messages and visit the files in
989 which errors are found, moving point to the line where the error
990 occurred.
991
992 `M-x compile'
993      Run a compiler asynchronously under Emacs, with error messages to
994      `*compilation*' buffer.
995
996 `M-x grep'
997      Run `grep' asynchronously under Emacs, with matching lines listed
998      in the buffer named `*compilation*'.
999
1000 `M-x kill-compilation'
1001      Kill the process made by the `M-x compile' command.
1002
1003 `M-x kill-grep'
1004      Kill the running compilation or `grep' subprocess.
1005
1006 `C-x `'
1007      Visit the next compiler error message or `grep' match.
1008
1009    To run `make' or another compiler, type `M-x compile'.  This command
1010 reads a shell command line using the minibuffer, then executes the
1011 specified command line in an inferior shell with output going to the
1012 buffer named `*compilation*'.  By default, the current buffer's default
1013 directory is used as the working directory for the execution of the
1014 command; therefore, the makefile comes from this directory.
1015
1016    When the shell command line is read, the minibuffer appears
1017 containing a default command line (the command you used the last time
1018 you typed `M-x compile').  If you type just <RET>, the same command
1019 line is used again.  The first `M-x compile' provides `make -k' as the
1020 default.  The default is taken from the variable `compile-command'; if
1021 the appropriate compilation command for a file is something other than
1022 `make -k', it can be useful to have the file specify a local value for
1023 `compile-command' (*note File Variables::.).
1024
1025    When you start a compilation, the buffer `*compilation*' is
1026 displayed in another window but not selected.  Its mode line displays
1027 the word `run' or `exit' in the parentheses to tell you whether
1028 compilation is finished.  You do not have to keep this buffer visible;
1029 compilation continues in any case.
1030
1031    To kill the compilation process, type `M-x-kill-compilation'.  The
1032 mode line of the `*compilation*' buffer changes to say `signal' instead
1033 of `run'.  Starting a new compilation also kills any running
1034 compilation, as only one can occur at any time.  Starting a new
1035 compilation prompts for confirmation before actually killing a
1036 compilation that is running.
1037
1038    To parse the compiler error messages, type `C-x `' (`next-error').
1039 The character following `C-x' is the grave accent, not the single
1040 quote.  The command displays the buffer `*compilation*' in one window
1041 and the buffer in which the next error occurred in another window.
1042 Point in that buffer is moved to the line where the error was found.
1043 The corresponding error message is scrolled to the top of the window in
1044 which `*compilation*' is displayed.
1045
1046    The first time you use `C-x `' after the start of a compilation, it
1047 parses all the error messages, visits all the files that have error
1048 messages, and creates markers pointing at the lines the error messages
1049 refer to.  It then moves to the first error message location.
1050 Subsequent uses of `C-x `' advance down the data set up by the first
1051 use.  When the preparsed error messages are exhausted, the next `C-x `'
1052 checks for any more error messages that have come in; this is useful if
1053 you start editing compiler errors while compilation is still going on.
1054 If no additional error messages have come in, `C-x `' reports an error.
1055
1056    `C-u C-x `' discards the preparsed error message data and parses the
1057 `*compilation*' buffer again, then displays the first error.  This way,
1058 you can process the same set of errors again.
1059
1060    Instead of running a compiler, you can run `grep' and see the lines
1061 on which matches were found.  To do this, type `M-x grep' with an
1062 argument line that contains the same arguments you would give to
1063 `grep': a `grep'-style regexp (usually in single quotes to quote the
1064 shell's special characters) followed by filenames, which may use
1065 wildcard characters.  The output from `grep' goes in the
1066 `*compilation*' buffer.  You can use `C-x `' to find the lines that
1067 match as if they were compilation errors.
1068
1069    Note: a shell is used to run the compile command, but the shell is
1070 not run in interactive mode.  In particular, this means that the shell
1071 starts up with no prompt.  If you find your usual shell prompt making an
1072 unsightly appearance in the `*compilation*' buffer, it means you have
1073 made a mistake in your shell's initialization file (`.cshrc' or `.shrc'
1074 or ...) by setting the prompt unconditionally.  The shell
1075 initialization file should set the prompt only if there already is a
1076 prompt.  Here's how to do it in `csh':
1077
1078      if ($?prompt) set prompt = ...
1079
1080 \1f
1081 File: xemacs.info,  Node: Lisp Modes,  Next: Lisp Libraries,  Prev: Compilation,  Up: Running
1082
1083 Major Modes for Lisp
1084 ====================
1085
1086    Emacs has four different major modes for Lisp.  They are the same in
1087 terms of editing commands, but differ in the commands for executing Lisp
1088 expressions.
1089
1090 Emacs-Lisp mode
1091      The mode for editing source files of programs to run in Emacs Lisp.
1092      This mode defines `C-M-x' to evaluate the current defun.  *Note
1093      Lisp Libraries::.
1094
1095 Lisp Interaction mode
1096      The mode for an interactive session with Emacs Lisp.  It defines
1097      <LFD> to evaluate the sexp before point and insert its value in the
1098      buffer.  *Note Lisp Interaction::.
1099
1100 Lisp mode
1101      The mode for editing source files of programs that run in other
1102      dialects of Lisp than Emacs Lisp.  This mode defines `C-M-x' to
1103      send the current defun to an inferior Lisp process.  *Note
1104      External Lisp::.
1105
1106 Inferior Lisp mode
1107      The mode for an interactive session with an inferior Lisp process.
1108      This mode combines the special features of Lisp mode and Shell mode
1109      (*note Shell Mode::.).
1110
1111 Scheme mode
1112      Like Lisp mode but for Scheme programs.
1113
1114 Inferior Scheme mode
1115      The mode for an interactive session with an inferior Scheme
1116      process.
1117
1118 \1f
1119 File: xemacs.info,  Node: Lisp Libraries,  Next: Lisp Eval,  Prev: Lisp Modes,  Up: Running
1120
1121 Libraries of Lisp Code for Emacs
1122 ================================
1123
1124    Lisp code for Emacs editing commands is stored in files whose names
1125 conventionally end in `.el'.  This ending tells Emacs to edit them in
1126 Emacs-Lisp mode (*note Lisp Modes::.).
1127
1128 * Menu:
1129
1130 * Loading::             Loading libraries of Lisp code into Emacs for use.
1131 * Compiling Libraries:: Compiling a library makes it load and run faster.
1132 * Mocklisp::            Converting Mocklisp to Lisp so XEmacs can run it.
1133