1 This is Info file ../../info/xemacs.info, produced by Makeinfo version
2 1.68 from the input file xemacs.texi.
4 INFO-DIR-SECTION XEmacs Editor
6 * XEmacs: (xemacs). XEmacs Editor.
9 This file documents the XEmacs editor.
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.
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.
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.
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.
33 File: xemacs.info, Node: Change Log, Next: Tags, Prev: Documentation, Up: Programs
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.
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.
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::.
63 Here is an example of the formatting conventions used in the change
66 Wed Jun 26 19:29:32 1985 Richard M. Stallman (rms at mit-prep)
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.
76 Tue Jun 25 05:25:33 1985 Richard M. Stallman (rms at mit-prep)
79 Call the auto fill hook if appropriate.
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.
88 File: xemacs.info, Node: Tags, Next: Fortran, Prev: Change Log, Up: Programs
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.
101 Tags tables are stored in files called "tags table files". The
102 conventional name for a tags table file is `TAGS'.
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.
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".
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.
124 File: xemacs.info, Node: Tag Syntax, Next: Create Tags Table, Up: Tags
126 Source File Tag Syntax
127 ----------------------
129 Here is how tag syntax is defined for the most popular languages:
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
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
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
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
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,
160 TEXTAGS="def:newcommand:newenvironment"
163 specifies (using Bourne shell syntax) that the commands `\def',
164 `\newcommand' and `\newenvironment' also define tags.
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,
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.
175 Several other languages are also supported:
177 * In assembler code, labels appearing at the beginning of a line,
178 followed by a colon, are tags.
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.
184 * In Cobol code, paragraphs names are the tags, i.e. any word
185 starting in column 8 and followed by a full stop.
187 * In Erlang code, the tags are the functions, records, and macros
190 * In Fortran code, functions and subroutines are tags.
192 * In Objective C code, tags include Objective C definitions for
193 classes, class categories, methods and protocols.
195 * In Pascal code, the tags are the functions and procedures defined
198 * In Perl code, the tags are the procedures defined by the `sub'
201 * In Postscript code, the tags are the functions.
203 * In Prolog code, a tag name appears at the left margin.
205 You can also generate tags based on regexp matching (*note Create
206 Tags Table::.) to handle other formats and languages.
209 File: xemacs.info, Node: Create Tags Table, Next: Select Tags Table, Prev: Tag Syntax, Up: Tags
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':
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,
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
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.
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.
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
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
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.
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:
269 find . -name "*.[chCH]" -print | etags -
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.
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:
285 --regex=/TAGREGEXP[/NAMEREGEXP]/
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.
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
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.
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:
311 etags --regex=/REG1/ voo.doo --regex=/REG2/ \
312 bar.ber -R --lang=lisp los.er
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'.
320 Here are some more examples. The regexps are quoted to protect them
321 from shell interpretation.
323 Tag the `DEFVAR' macros in the emacs source files:
325 --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
327 Tag VHDL files (this example is a single long line, broken here for
331 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/'
332 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
333 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
335 Tag TCL files (this last example shows the usage of a NAMEREGEXP):
337 --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
339 For a list of the other available `etags' options, execute `etags
343 File: xemacs.info, Node: Select Tags Table, Next: Find Tag, Prev: Create Tags Table, Up: Tags
345 Selecting a Tags Table
346 ----------------------
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'.
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.
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.
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.
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/")
380 The example defines the tags table alist in the following way:
382 * Anything in the directory `/usr/src/public/perl/' should use the
383 `TAGS' file `/usr/src/public/perl/perl-3.0/TAGS'.
385 * Files ending in `.el' should use the `TAGS' file
386 `/usr/local/emacs/src/TAGS'.
388 * Anything in or below the directory `/jbw/gnu/' should use the
389 `TAGS' file `/usr15/degree/stud/jbw/gnu/TAGS'.
391 If you had a file called `/usr/jbw/foo.el', it would use both `TAGS'
393 `/usr/local/emacs/src/TAGS' and `/usr15/degree/stud/jbw/gnu/TAGS' (in
394 that order), because it matches both patterns.
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.
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).
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
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.
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'.
425 File: xemacs.info, Node: Find Tag, Next: Tags Search, Prev: Select Tags Table, Up: Tags
430 The most important thing that a tags table enables you to do is to
431 find the definition of a specific tag.
433 `M-. TAG &OPTIONAL OTHER-WINDOW'
434 Find first definition of TAG (`find-tag').
437 Find next alternate definition of last tag specified.
440 Find first definition of TAG, but display it in another window
441 (`find-tag-other-window').
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.
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.
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-.'.
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.
471 Variables of note include the following:
474 Controls which tables apply to which buffers.
477 Stores a default tags table.
479 `tags-build-completion-table'
480 Controls completion behavior.
483 Specifies a buffer-local table.
485 `make-tags-files-invisible'
486 Sets whether tags tables should be very hidden.
489 Specifies how many tags-based hops to remember.
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
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
503 File: xemacs.info, Node: Tags Search, Next: List Tags, Prev: Find Tag, Up: Tags
505 Searching and Replacing with Tags Tables
506 ----------------------------------------
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::.).
513 `M-x tags-search <RET> REGEXP <RET>'
514 Search for REGEXP through the files in the selected tags table.
516 `M-x tags-query-replace <RET> REGEXP <RET> REPLACEMENT <RET>'
517 Perform a `query-replace-regexp' on each file in the selected tags
521 Restart one of the commands above, from the current location of
522 point (`tags-loop-continue').
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'
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.
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.
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.
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
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.
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::.
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'.
572 With a numeric argument, regardless of its value, visit the first
573 file in the tags table and prepare to advance sequentially by
577 Visit the next file in the selected tags table.
580 File: xemacs.info, Node: List Tags, Prev: Tags Search, Up: Tags
586 Display a list of the tags defined in a specific program file.
589 Display a list of all tags matching a specified regexp.
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.
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.
605 File: xemacs.info, Node: Fortran, Next: Asm Mode, Prev: Tags, Up: Programs
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.
614 Special commands for comments are provided because Fortran comments
615 are unlike those of other languages.
617 Built-in abbrevs optionally save typing when you insert Fortran
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.
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.
632 Fortran mode was contributed by Michael Prange.
635 File: xemacs.info, Node: Fortran Motion, Next: Fortran Indent, Prev: Fortran, Up: Fortran
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.
646 Move to beginning of subprogram
647 (`beginning-of-fortran-subprogram').
650 Move to end of subprogram (`end-of-fortran-subprogram').
653 Put point at beginning of subprogram and mark at end
654 (`mark-fortran-subprogram').
657 Move to beginning of current or next statement (`fortran-next-
661 Move to beginning of current or previous statement (`fortran-
662 previous-statement').
665 File: xemacs.info, Node: Fortran Indent, Next: Fortran Comments, Prev: Fortran Motion, Up: Fortran
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.
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.
683 File: xemacs.info, Node: ForIndent Commands, Next: ForIndent Num, Prev: Fortran Indent, Up: Fortran Indent
685 Fortran Indentation Commands
686 ............................
689 Indent the current line (`fortran-indent-line').
692 Break the current line and set up a continuation line.
695 Indent all the lines of the subprogram point is in
696 (`fortran-indent-subprogram').
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.
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.
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
714 File: xemacs.info, Node: ForIndent Num, Next: ForIndent Conv, Prev: ForIndent Commands, Up: Fortran Indent
716 Line Numbers and Continuation
717 .............................
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
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
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.
741 File: xemacs.info, Node: ForIndent Conv, Next: ForIndent Vars, Prev: ForIndent Num, Up: Fortran Indent
743 Syntactic Conventions
744 .....................
746 Fortran mode assumes that you follow certain conventions that
747 simplify the task of understanding a Fortran program well enough to
750 * Two nested `do' loops never share a `continue' statement.
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 `$'.
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
762 File: xemacs.info, Node: ForIndent Vars, Prev: ForIndent Conv, Up: Fortran Indent
764 Variables for Fortran Indentation
765 .................................
767 Several additional variables control how Fortran indentation works.
770 Extra indentation within each level of `do' statement (the default
774 Extra indentation within each level of `if' statement (the default
777 `fortran-continuation-indent'
778 Extra indentation for bodies of continuation lines (the default is
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'.
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
795 File: xemacs.info, Node: Fortran Comments, Next: Fortran Columns, Prev: Fortran Indent, Up: Fortran
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.
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::.).
812 Align comment or insert new comment (`fortran-comment-indent').
815 Applies to nonstandard `!' comments only.
818 Turn all lines of the region into comments, or (with arg) turn
819 them back into real code (`fortran-comment-region').
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.
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.
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:
841 The text is aligned at a fixed column, which is the value of
842 `fortran-comment-line-column'. This is the default.
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.
849 Text in full-line columns is not moved automatically.
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.
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.
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.
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.
876 File: xemacs.info, Node: Fortran Columns, Next: Fortran Abbrev, Prev: Fortran Comments, Up: Fortran
882 Displays a "column ruler" momentarily above the current line
883 (`fortran-column-ruler').
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').
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.
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.
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
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.
911 File: xemacs.info, Node: Fortran Abbrev, Prev: Fortran Columns, Up: Fortran
913 Fortran Keyword Abbrevs
914 -----------------------
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::..
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
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.
930 Type `;?' or `;C-h' to display a list of all built-in Fortran
931 abbrevs and what they stand for.
934 File: xemacs.info, Node: Asm Mode, Prev: Fortran, Up: Programs
939 Asm mode is a major mode for editing files of assembler code. It
940 defines these commands:
946 Insert a newline and then indent using `tab-to-tab-stop'.
949 Insert a colon and then remove the indentation from before the
950 label preceding colon. Then do `tab-to-tab-stop'.
953 Insert or align a comment.
955 The variable `asm-comment-char' specifies which character starts
956 comments in assembler syntax.
959 File: xemacs.info, Node: Running, Next: Packages, Prev: Programs, Up: Top
961 Compiling and Testing Programs
962 ******************************
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.
970 * Compilation:: Compiling programs in languages other than Lisp
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.
981 File: xemacs.info, Node: Compilation, Next: Lisp Modes, Prev: Running, Up: Running
983 Running "make", or Compilers Generally
984 ======================================
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
993 Run a compiler asynchronously under Emacs, with error messages to
994 `*compilation*' buffer.
997 Run `grep' asynchronously under Emacs, with matching lines listed
998 in the buffer named `*compilation*'.
1000 `M-x kill-compilation'
1001 Kill the process made by the `M-x compile' command.
1004 Kill the running compilation or `grep' subprocess.
1007 Visit the next compiler error message or `grep' match.
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.
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::.).
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.
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.
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.
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.
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.
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.
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':
1078 if ($?prompt) set prompt = ...
1081 File: xemacs.info, Node: Lisp Modes, Next: Lisp Libraries, Prev: Compilation, Up: Running
1083 Major Modes for Lisp
1084 ====================
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
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
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::.
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
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::.).
1112 Like Lisp mode but for Scheme programs.
1114 Inferior Scheme mode
1115 The mode for an interactive session with an inferior Scheme
1119 File: xemacs.info, Node: Lisp Libraries, Next: Lisp Eval, Prev: Lisp Modes, Up: Running
1121 Libraries of Lisp Code for Emacs
1122 ================================
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::.).
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.