1 This is ../info/xemacs.info, produced by makeinfo version 4.0b from
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 * Etags Regexps:: Create arbitrary tags using regular expressions.
119 * Select Tags Table:: How to visit a tags table.
120 * Find Tag:: Commands to find the definition of a specific tag.
121 * Tags Search:: Using a tags table for searching and replacing.
122 * List Tags:: Listing and finding tags defined in a file.
125 File: xemacs.info, Node: Tag Syntax, Next: Create Tags Table, Prev: Tags, Up: Tags
127 Source File Tag Syntax
128 ----------------------
130 Here is how tag syntax is defined for the most popular languages:
132 * In C code, any C function or typedef is a tag, and so are
133 definitions of `struct', `union' and `enum'. You can tag function
134 declarations and external variables in addition to function
135 definitions by giving the `--declarations' option to `etags'.
136 `#define' macro definitions and `enum' constants are also tags,
137 unless you specify `--no-defines' when making the tags table.
138 Similarly, global variables are tags, unless you specify
139 `--no-globals'. Use of `--no-globals' and `--no-defines' can make
140 the tags table file much smaller.
142 * In C++ code, in addition to all the tag constructs of C code,
143 member functions are also recognized, and optionally member
144 variables if you use the `--members' option. Tags for variables
145 and functions in classes are named `CLASS::VARIABLE' and
146 `CLASS::FUNCTION'. `operator' functions tags are named, for
149 * In Java code, tags include all the constructs recognized in C++,
150 plus the `interface', `extends' and `implements' constructs. Tags
151 for variables and functions in classes are named `CLASS.VARIABLE'
152 and `CLASS.FUNCTION'.
154 * In LaTeX text, the argument of any of the commands `\chapter',
155 `\section', `\subsection', `\subsubsection', `\eqno', `\label',
156 `\ref', `\cite', `\bibitem', `\part', `\appendix', `\entry', or
159 Other commands can make tags as well, if you specify them in the
160 environment variable `TEXTAGS' before invoking `etags'. The value
161 of this environment variable should be a colon-separated list of
162 command names. For example,
164 TEXTAGS="def:newcommand:newenvironment"
167 specifies (using Bourne shell syntax) that the commands `\def',
168 `\newcommand' and `\newenvironment' also define tags.
170 * In Lisp code, any function defined with `defun', any variable
171 defined with `defvar' or `defconst', and in general the first
172 argument of any expression that starts with `(def' in column zero,
175 * In Scheme code, tags include anything defined with `def' or with a
176 construct whose name starts with `def'. They also include
177 variables set with `set!' at top level in the file.
179 Several other languages are also supported:
181 * In Ada code, functions, procedures, packages, tasks, and types are
182 tags. Use the `--packages-only' option to create tags for packages
185 * In assembler code, labels appearing at the beginning of a line,
186 followed by a colon, are tags.
188 * In Bison or Yacc input files, each rule defines as a tag the
189 nonterminal it constructs. The portions of the file that contain
190 C code are parsed as C code.
192 * In Cobol code, tags are paragraph names; that is, any word
193 starting in column 8 and followed by a period.
195 * In Erlang code, the tags are the functions, records, and macros
198 * In Fortran code, functions, subroutines and blockdata are tags.
200 * In Objective C code, tags include Objective C definitions for
201 classes, class categories, methods, and protocols.
203 * In Pascal code, the tags are the functions and procedures defined
206 * In Perl code, the tags are the procedures defined by the `sub',
207 `my' and `local' keywords. Use `--globals' if you want to tag
210 * In Postscript code, the tags are the functions.
212 * In Prolog code, a tag name appears at the left margin.
214 * In Python code, `def' or `class' at the beginning of a line
217 You can also generate tags based on regexp matching (*note Etags
218 Regexps::) to handle other formats and languages.
221 File: xemacs.info, Node: Create Tags Table, Next: Etags Regexps, Prev: Tag Syntax, Up: Tags
226 The `etags' program is used to create a tags table file. It knows
227 the syntax of several languages, as described in *Note Tag Syntax::.
228 Here is how to run `etags':
232 The `etags' program reads the specified files, and writes a tags table
233 named `TAGS' in the current working directory. You can intermix
234 compressed and plain text source file names. `etags' knows about the
235 most common compression formats, and does the right thing. So you can
236 compress all your source files and have `etags' look for compressed
237 versions of its file name arguments, if it does not find uncompressed
238 versions. Under MS-DOS, `etags' also looks for file names like
239 `mycode.cgz' if it is given `mycode.c' on the command line and
240 `mycode.c' does not exist.
242 `etags' recognizes the language used in an input file based on its
243 file name and contents. You can specify the language with the
244 `--language=NAME' option, described below.
246 If the tags table data become outdated due to changes in the files
247 described in the table, the way to update the tags table is the same
248 way it was made in the first place. It is not necessary to do this
251 If the tags table fails to record a tag, or records it for the wrong
252 file, then Emacs cannot possibly find its definition. However, if the
253 position recorded in the tags table becomes a little bit wrong (due to
254 some editing in the file that the tag definition is in), the only
255 consequence is a slight delay in finding the tag. Even if the stored
256 position is very wrong, Emacs will still find the tag, but it must
257 search the entire file for it.
259 So you should update a tags table when you define new tags that you
260 want to have listed, or when you move tag definitions from one file to
261 another, or when changes become substantial. Normally there is no need
262 to update the tags table after each edit, or even every day.
264 One tags table can effectively include another. Specify the included
265 tags file name with the `--include=FILE' option when creating the file
266 that is to include it. The latter file then acts as if it contained
267 all the files specified in the included file, as well as the files it
270 If you specify the source files with relative file names when you run
271 `etags', the tags file will contain file names relative to the
272 directory where the tags file was initially written. This way, you can
273 move an entire directory tree containing both the tags file and the
274 source files, and the tags file will still refer correctly to the source
277 If you specify absolute file names as arguments to `etags', then the
278 tags file will contain absolute file names. This way, the tags file
279 will still refer to the same files even if you move it, as long as the
280 source files remain in the same place. Absolute file names start with
281 `/', or with `DEVICE:/' on MS-DOS and MS-Windows.
283 When you want to make a tags table from a great number of files, you
284 may have problems listing them on the command line, because some systems
285 have a limit on its length. The simplest way to circumvent this limit
286 is to tell `etags' to read the file names from its standard input, by
287 typing a dash in place of the file names, like this:
289 find . -name "*.[chCH]" -print | etags -
291 Use the option `--language=NAME' to specify the language explicitly.
292 You can intermix these options with file names; each one applies to
293 the file names that follow it. Specify `--language=auto' to tell
294 `etags' to resume guessing the language from the file names and file
295 contents. Specify `--language=none' to turn off language-specific
296 processing entirely; then `etags' recognizes tags by regexp matching
297 alone (*note Etags Regexps::).
299 `etags --help' prints the list of the languages `etags' knows, and
300 the file name rules for guessing the language. It also prints a list of
301 all the available `etags' options, together with a short explanation.
304 File: xemacs.info, Node: Etags Regexps, Next: Select Tags Table, Prev: Create Tags Table, Up: Tags
309 The `--regex' option provides a general way of recognizing tags
310 based on regexp matching. You can freely intermix it with file names.
311 Each `--regex' option adds to the preceding ones, and applies only to
312 the following files. The syntax is:
314 --regex=/TAGREGEXP[/NAMEREGEXP]/
316 where TAGREGEXP is used to match the lines to tag. It is always
317 anchored, that is, it behaves as if preceded by `^'. If you want to
318 account for indentation, just match any initial number of blanks by
319 beginning your regular expression with `[ \t]*'. In the regular
320 expressions, `\' quotes the next character, and `\t' stands for the tab
321 character. Note that `etags' does not handle the other C escape
322 sequences for special characters.
324 The syntax of regular expressions in `etags' is the same as in
325 Emacs, augmented with the "interval operator", which works as in `grep'
326 and `ed'. The syntax of an interval operator is `\{M,N\}', and its
327 meaning is to match the preceding expression at least M times and up to
330 You should not match more characters with TAGREGEXP than that needed
331 to recognize what you want to tag. If the match is such that more
332 characters than needed are unavoidably matched by TAGREGEXP (as will
333 usually be the case), you should add a NAMEREGEXP, to pick out just the
334 tag. This will enable Emacs to find tags more accurately and to do
335 completion on tag names more reliably. You can find some examples
338 The option `--ignore-case-regex' (or `-c') is like `--regex', except
339 that the regular expression provided will be matched without regard to
340 case, which is appropriate for various programming languages.
342 The `-R' option deletes all the regexps defined with `--regex'
343 options. It applies to the file names following it, as you can see
344 from the following example:
346 etags --regex=/REG1/ voo.doo --regex=/REG2/ \
347 bar.ber -R --lang=lisp los.er
349 Here `etags' chooses the parsing language for `voo.doo' and `bar.ber'
350 according to their contents. `etags' also uses REG1 to recognize
351 additional tags in `voo.doo', and both REG1 and REG2 to recognize
352 additional tags in `bar.ber'. `etags' uses the Lisp tags rules, and no
353 regexp matching, to recognize tags in `los.er'.
355 A regular expression can be bound to a given language, by prepending
356 it with `{lang}'. When you do this, `etags' will use the regular
357 expression only for files of that language. `etags --help' prints the
358 list of languages recognised by `etags'. The following example tags
359 the `DEFVAR' macros in the Emacs source files. `etags' applies this
360 regular expression to C files only:
362 --regex='{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
364 This feature is particularly useful when storing a list of regular
365 expressions in a file. The following option syntax instructs `etags'
366 to read two files of regular expressions. The regular expressions
367 contained in the second file are matched without regard to case.
369 --regex=@first-file --ignore-case-regex=@second-file
371 A regex file contains one regular expressions per line. Empty lines,
372 and lines beginning with space or tab are ignored. When the first
373 character in a line is `@', `etags' assumes that the rest of the line
374 is the name of a file of regular expressions. This means that such
375 files can be nested. All the other lines are taken to be regular
376 expressions. For example, one can create a file called `emacs.tags'
377 with the following contents (the first line in the file is a comment):
379 -- This is for GNU Emacs source files
380 {c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/
382 and then use it like this:
384 etags --regex=@emacs.tags *.[ch] */*.[ch]
386 Here are some more examples. The regexps are quoted to protect them
387 from shell interpretation.
391 etags --language=none \
392 --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \
393 --regex='/###key \(.*\)/\1/' \
394 --regex='/[ \t]*global[ \t].*/' \
397 Note that tags are not generated for scripts so that you have to
398 add a line by yourself of the form `###key <script-name>' if you
403 etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl
408 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \
409 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
410 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
413 File: xemacs.info, Node: Select Tags Table, Next: Find Tag, Prev: Etags Regexps, Up: Tags
415 Selecting a Tags Table
416 ----------------------
418 At any time Emacs has one "selected" tags table, and all the commands
419 for working with tags tables use the selected one. To select a tags
420 table, use the variable `tag-table-alist'.
422 The value of `tag-table-alist' is a list that determines which
423 `TAGS' files should be active for a given buffer. This is not really
424 an association list, in that all elements are checked. The car of each
425 element of this list is a pattern against which the buffers file name
426 is compared; if it matches, then the cdr of the list should be the name
427 of the tags table to use. If more than one element of this list
428 matches the buffers file name, all of the associated tags tables are
429 used. Earlier ones are searched first.
431 If the car of elements of this list are strings, they are treated as
432 regular-expressions against which the file is compared (like the
433 `auto-mode-alist'). If they are not strings, they are evaluated. If
434 they evaluate to non-`nil', the current buffer is considered to match.
436 If the cdr of the elements of this list are strings, they are
437 assumed to name a tags file. If they name a directory, the string
438 `tags' is appended to them to get the file name. If they are not
439 strings, they are evaluated and must return an appropriate string.
443 (setq tag-table-alist
444 '(("/usr/src/public/perl/" . "/usr/src/public/perl/perl-3.0/")
445 ("\\.el$" . "/usr/local/emacs/src/")
446 ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
447 ("" . "/usr/local/emacs/src/")
450 The example defines the tags table alist in the following way:
452 * Anything in the directory `/usr/src/public/perl/' should use the
453 `TAGS' file `/usr/src/public/perl/perl-3.0/TAGS'.
455 * Files ending in `.el' should use the `TAGS' file
456 `/usr/local/emacs/src/TAGS'.
458 * Anything in or below the directory `/jbw/gnu/' should use the
459 `TAGS' file `/usr15/degree/stud/jbw/gnu/TAGS'.
461 If you had a file called `/usr/jbw/foo.el', it would use both `TAGS'
463 `/usr/local/emacs/src/TAGS' and `/usr15/degree/stud/jbw/gnu/TAGS' (in
464 that order), because it matches both patterns.
466 If the buffer-local variable `buffer-tag-table' is set, it names a
467 tags table that is searched before all others when `find-tag' is
468 executed from this buffer.
470 If there is a file called `TAGS' in the same directory as the file
471 in question, then that tags file will always be used as well (after the
472 `buffer-tag-table' but before the tables specified by this list).
474 If the variable `tags-file-name' is set, the `TAGS' file it names
475 will apply to all buffers (for backwards compatibility.) It is searched
478 If the value of the variable `tags-always-build-completion-table' is
479 `t', the tags file will always be added to the completion table without
480 asking first, regardless of the size of the tags file.
482 The function `M-x visit-tags-table', is largely made obsolete by the
483 variable `tag-table-alist', tells tags commands to use the tags table
484 file FILE first. The FILE should be the name of a file created with
485 the `etags' program. A directory name is also acceptable; it means the
486 file `TAGS' in that directory. The function only stores the file name
487 you provide in the variable `tags-file-name'. Emacs does not actually
488 read in the tags table contents until you try to use them. You can set
489 the variable explicitly instead of using `visit-tags-table'. The value
490 of the variable `tags-file-name' is the name of the tags table used by
491 all buffers. This is for backward compatibility, and is largely
492 supplanted by the variable `tag-table-alist'.
495 File: xemacs.info, Node: Find Tag, Next: Tags Search, Prev: Select Tags Table, Up: Tags
500 The most important thing that a tags table enables you to do is to
501 find the definition of a specific tag.
503 `M-. TAG &OPTIONAL OTHER-WINDOW'
504 Find first definition of TAG (`find-tag').
507 Find next alternate definition of last tag specified.
510 Find first definition of TAG, but display it in another window
511 (`find-tag-other-window').
513 `M-.' (`find-tag') is the command to find the definition of a
514 specified tag. It searches through the tags table for that tag, as a
515 string, then uses the tags table information to determine the file in
516 which the definition is used and the approximate character position of
517 the definition in the file. Then `find-tag' visits the file, moves
518 point to the approximate character position, and starts searching
519 ever-increasing distances away for the text that should appear at the
520 beginning of the definition.
522 If an empty argument is given (by typing <RET>), the sexp in the
523 buffer before or around point is used as the name of the tag to find.
524 *Note Lists::, for information on sexps.
526 The argument to `find-tag' need not be the whole tag name; it can be
527 a substring of a tag name. However, there can be many tag names
528 containing the substring you specify. Since `find-tag' works by
529 searching the text of the tags table, it finds the first tag in the
530 table that the specified substring appears in. To find other tags that
531 match the substring, give `find-tag' a numeric argument, as in `C-u
532 M-.'. This does not read a tag name, but continues searching the tag
533 table's text for another tag containing the same substring last used.
534 If your keyboard has a real <META> key, `M-0 M-.' is an easier
535 alternative to `C-u M-.'.
537 If the optional second argument OTHER-WINDOW is non-`nil', it uses
538 another window to display the tag. Multiple active tags tables and
539 completion are supported.
541 Variables of note include the following:
544 Controls which tables apply to which buffers.
547 Stores a default tags table.
549 `tags-build-completion-table'
550 Controls completion behavior.
553 Specifies a buffer-local table.
555 `make-tags-files-invisible'
556 Sets whether tags tables should be very hidden.
559 Specifies how many tags-based hops to remember.
561 Like most commands that can switch buffers, `find-tag' has another
562 similar command that displays the new buffer in another window. `C-x 4
563 .' invokes the function `find-tag-other-window'. (This key sequence
566 Emacs comes with a tags table file `TAGS' (in the directory
567 containing Lisp libraries) that includes all the Lisp libraries and all
568 the C sources of Emacs. By specifying this file with `visit-tags-table'
569 and then using `M-.' you can quickly look at the source of any Emacs
573 File: xemacs.info, Node: Tags Search, Next: List Tags, Prev: Find Tag, Up: Tags
575 Searching and Replacing with Tags Tables
576 ----------------------------------------
578 The commands in this section visit and search all the files listed
579 in the selected tags table, one by one. For these commands, the tags
580 table serves only to specify a sequence of files to search. A related
581 command is `M-x grep' (*note Compilation::).
583 `M-x tags-search <RET> REGEXP <RET>'
584 Search for REGEXP through the files in the selected tags table.
586 `M-x tags-query-replace <RET> REGEXP <RET> REPLACEMENT <RET>'
587 Perform a `query-replace-regexp' on each file in the selected tags
591 Restart one of the commands above, from the current location of
592 point (`tags-loop-continue').
594 `M-x tags-search' reads a regexp using the minibuffer, then searches
595 for matches in all the files in the selected tags table, one file at a
596 time. It displays the name of the file being searched so you can
597 follow its progress. As soon as it finds an occurrence, `tags-search'
600 Having found one match, you probably want to find all the rest. To
601 find one more match, type `M-,' (`tags-loop-continue') to resume the
602 `tags-search'. This searches the rest of the current buffer, followed
603 by the remaining files of the tags table.
605 `M-x tags-query-replace' performs a single `query-replace-regexp'
606 through all the files in the tags table. It reads a regexp to search
607 for and a string to replace with, just like ordinary `M-x
608 query-replace-regexp'. It searches much like `M-x tags-search', but
609 repeatedly, processing matches according to your input. *Note
610 Replace::, for more information on query replace.
612 It is possible to get through all the files in the tags table with a
613 single invocation of `M-x tags-query-replace'. But often it is useful
614 to exit temporarily, which you can do with any input event that has no
615 special query replace meaning. You can resume the query replace
616 subsequently by typing `M-,'; this command resumes the last tags search
617 or replace command that you did.
619 The commands in this section carry out much broader searches than the
620 `find-tag' family. The `find-tag' commands search only for definitions
621 of tags that match your substring or regexp. The commands
622 `tags-search' and `tags-query-replace' find every occurrence of the
623 regexp, as ordinary search commands and replace commands do in the
626 These commands create buffers only temporarily for the files that
627 they have to search (those which are not already visited in Emacs
628 buffers). Buffers in which no match is found are quickly killed; the
629 others continue to exist.
631 It may have struck you that `tags-search' is a lot like `grep'. You
632 can also run `grep' itself as an inferior of Emacs and have Emacs show
633 you the matching lines one by one. This works much like running a
634 compilation; finding the source locations of the `grep' matches works
635 like finding the compilation errors. *Note Compilation::.
637 If you wish to process all the files in a selected tags table, but
638 `M-x tags-search' and `M-x tags-query-replace' are not giving you the
639 desired result, you can use `M-x next-file'.
642 With a numeric argument, regardless of its value, visit the first
643 file in the tags table and prepare to advance sequentially by
647 Visit the next file in the selected tags table.
650 File: xemacs.info, Node: List Tags, Prev: Tags Search, Up: Tags
656 Display a list of the tags defined in a specific program file.
659 Display a list of all tags matching a specified regexp.
661 `M-x list-tags' reads the name of one of the files described by the
662 selected tags table, and displays a list of all the tags defined in that
663 file. The "file name" argument is really just a string to compare
664 against the names recorded in the tags table; it is read as a string
665 rather than a file name. Therefore, completion and defaulting are not
666 available, and you must enter the string the same way it appears in the
667 tag table. Do not include a directory as part of the file name unless
668 the file name recorded in the tags table contains that directory.
670 `M-x tags-apropos' is like `apropos' for tags. It reads a regexp,
671 then finds all the tags in the selected tags table whose entries match
672 that regexp, and displays the tag names found.
675 File: xemacs.info, Node: Fortran, Next: Asm Mode, Prev: Tags, Up: Programs
680 Fortran mode provides special motion commands for Fortran statements
681 and subprograms, and indentation commands that understand Fortran
682 conventions of nesting, line numbers, and continuation statements.
684 Special commands for comments are provided because Fortran comments
685 are unlike those of other languages.
687 Built-in abbrevs optionally save typing when you insert Fortran
690 Use `M-x fortran-mode' to switch to this major mode. Doing so calls
691 the value of `fortran-mode-hook' as a function of no arguments if that
692 variable has a non-`nil' value.
696 * Motion: Fortran Motion. Moving point by statements or subprograms.
697 * Indent: Fortran Indent. Indentation commands for Fortran.
698 * Comments: Fortran Comments. Inserting and aligning comments.
699 * Columns: Fortran Columns. Measuring columns for valid Fortran.
700 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
702 Fortran mode was contributed by Michael Prange.
705 File: xemacs.info, Node: Fortran Motion, Next: Fortran Indent, Prev: Fortran, Up: Fortran
710 Fortran mode provides special commands to move by subprograms
711 (functions and subroutines) and by statements. There is also a command
712 to put the region around one subprogram, which is convenient for
713 killing it or moving it.
716 Move to beginning of subprogram
717 (`beginning-of-fortran-subprogram').
720 Move to end of subprogram (`end-of-fortran-subprogram').
723 Put point at beginning of subprogram and mark at end
724 (`mark-fortran-subprogram').
727 Move to beginning of current or next statement (`fortran-next-
731 Move to beginning of current or previous statement (`fortran-
732 previous-statement').
735 File: xemacs.info, Node: Fortran Indent, Next: Fortran Comments, Prev: Fortran Motion, Up: Fortran
740 Special commands and features are available for indenting Fortran
741 code. They make sure various syntactic entities (line numbers, comment
742 line indicators, and continuation line flags) appear in the columns
743 that are required for standard Fortran.
747 * Commands: ForIndent Commands. Commands for indenting Fortran.
748 * Numbers: ForIndent Num. How line numbers auto-indent.
749 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
750 * Vars: ForIndent Vars. Variables controlling Fortran indent style.
753 File: xemacs.info, Node: ForIndent Commands, Next: ForIndent Num, Prev: Fortran Indent, Up: Fortran Indent
755 Fortran Indentation Commands
756 ............................
759 Indent the current line (`fortran-indent-line').
762 Break the current line and set up a continuation line.
765 Indent all the lines of the subprogram point is in
766 (`fortran-indent-subprogram').
768 <TAB> is redefined by Fortran mode to reindent the current line for
769 Fortran (`fortran-indent-line'). Line numbers and continuation markers
770 are indented to their required columns, and the body of the statement
771 is independently indented, based on its nesting in the program.
773 The key `C-M-q' is redefined as `fortran-indent-subprogram', a
774 command that reindents all the lines of the Fortran subprogram
775 (function or subroutine) containing point.
777 The key `M-<LFD>' is redefined as `fortran-split-line', a command to
778 split a line in the appropriate fashion for Fortran. In a non-comment
779 line, the second half becomes a continuation line and is indented
780 accordingly. In a comment line, both halves become separate comment
784 File: xemacs.info, Node: ForIndent Num, Next: ForIndent Conv, Prev: ForIndent Commands, Up: Fortran Indent
786 Line Numbers and Continuation
787 .............................
789 If a number is the first non-whitespace in the line, it is assumed
790 to be a line number and is moved to columns 0 through 4. (Columns are
791 always counted from 0 in XEmacs.) If the text on the line starts with
792 the conventional Fortran continuation marker `$', it is moved to column
793 5. If the text begins with any non whitespace character in column 5,
794 it is assumed to be an unconventional continuation marker and remains
797 Line numbers of four digits or less are normally indented one space.
798 This amount is controlled by the variable `fortran-line-number-indent',
799 which is the maximum indentation a line number can have. Line numbers
800 are indented to right-justify them to end in column 4 unless that would
801 require more than the maximum indentation. The default value of the
804 Simply inserting a line number is enough to indent it according to
805 these rules. As each digit is inserted, the indentation is recomputed.
806 To turn off this feature, set the variable
807 `fortran-electric-line-number' to `nil'. Then inserting line numbers
808 is like inserting anything else.
811 File: xemacs.info, Node: ForIndent Conv, Next: ForIndent Vars, Prev: ForIndent Num, Up: Fortran Indent
813 Syntactic Conventions
814 .....................
816 Fortran mode assumes that you follow certain conventions that
817 simplify the task of understanding a Fortran program well enough to
820 * Two nested `do' loops never share a `continue' statement.
822 * The same character appears in column 5 of all continuation lines.
823 It is the value of the variable `fortran-continuation-char'. By
824 default, this character is `$'.
826 If you fail to follow these conventions, the indentation commands may
827 indent some lines unaesthetically. However, a correct Fortran program
828 will retain its meaning when reindented even if the conventions are not
832 File: xemacs.info, Node: ForIndent Vars, Prev: ForIndent Conv, Up: Fortran Indent
834 Variables for Fortran Indentation
835 .................................
837 Several additional variables control how Fortran indentation works.
840 Extra indentation within each level of `do' statement (the default
844 Extra indentation within each level of `if' statement (the default
847 `fortran-continuation-indent'
848 Extra indentation for bodies of continuation lines (the default is
851 `fortran-check-all-num-for-matching-do'
852 If this is `nil', indentation assumes that each `do' statement
853 ends on a `continue' statement. Therefore, when computing
854 indentation for a statement other than `continue', it can save
855 time by not checking for a `do' statement ending there. If this
856 is non-`nil', indenting any numbered statement must check for a
857 `do' that ends there. The default is `nil'.
859 `fortran-minimum-statement-indent'
860 Minimum indentation for Fortran statements. For standard Fortran,
861 this is 6. Statement bodies are always indented at least this
865 File: xemacs.info, Node: Fortran Comments, Next: Fortran Columns, Prev: Fortran Indent, Up: Fortran
870 The usual Emacs comment commands assume that a comment can follow a
871 line of code. In Fortran, the standard comment syntax requires an
872 entire line to be just a comment. Therefore, Fortran mode replaces the
873 standard Emacs comment commands and defines some new variables.
875 Fortran mode can also handle a non-standard comment syntax where
876 comments start with `!' and can follow other text. Because only some
877 Fortran compilers accept this syntax, Fortran mode will not insert such
878 comments unless you have specified to do so in advance by setting the
879 variable `comment-start' to `"!"' (*note Variables::).
882 Align comment or insert new comment (`fortran-comment-indent').
885 Applies to nonstandard `!' comments only.
888 Turn all lines of the region into comments, or (with arg) turn
889 them back into real code (`fortran-comment-region').
891 `M-;' in Fortran mode is redefined as the command
892 `fortran-comment-indent'. Like the usual `M-;' command, it recognizes
893 an existing comment and aligns its text appropriately. If there is no
894 existing comment, a comment is inserted and aligned.
896 Inserting and aligning comments is not the same in Fortran mode as in
897 other modes. When a new comment must be inserted, a full-line comment
898 is inserted if the current line is blank. On a non-blank line, a
899 non-standard `!' comment is inserted if you previously specified you
900 wanted to use them. Otherwise a full-line comment is inserted on a new
901 line before the current line.
903 Non-standard `!' comments are aligned like comments in other
904 languages, but full-line comments are aligned differently. In a
905 standard full-line comment, the comment delimiter itself must always
906 appear in column zero. What can be aligned is the text within the
907 comment. You can choose from three styles of alignment by setting the
908 variable `fortran-comment-indent-style' to one of these values:
911 The text is aligned at a fixed column, which is the value of
912 `fortran-comment-line-column'. This is the default.
915 The text is aligned as if it were a line of code, but with an
916 additional `fortran-comment-line-column' columns of indentation.
919 Text in full-line columns is not moved automatically.
921 You can also specify the character to be used to indent within
922 full-line comments by setting the variable `fortran-comment-indent-char'
923 to the character you want to use.
925 Fortran mode introduces two variables `comment-line-start' and
926 `comment-line-start-skip', which do for full-line comments what
927 `comment-start' and `comment-start-skip' do for ordinary text-following
928 comments. Normally these are set properly by Fortran mode, so you do
929 not need to change them.
931 The normal Emacs comment command `C-x ;' has not been redefined. It
932 can therefore be used if you use `!' comments, but is useless in
933 Fortran mode otherwise.
935 The command `C-c ;' (`fortran-comment-region') turns all the lines
936 of the region into comments by inserting the string `C$$$' at the front
937 of each one. With a numeric arg, the region is turned back into live
938 code by deleting `C$$$' from the front of each line. You can control
939 the string used for the comments by setting the variable
940 `fortran-comment-region'. Note that here we have an example of a
941 command and a variable with the same name; the two uses of the name
942 never conflict because in Lisp and in Emacs it is always clear from the
943 context which one is referred to.
946 File: xemacs.info, Node: Fortran Columns, Next: Fortran Abbrev, Prev: Fortran Comments, Up: Fortran
952 Displays a "column ruler" momentarily above the current line
953 (`fortran-column-ruler').
956 Splits the current window horizontally so that it is 72 columns
957 wide. This may help you avoid going over that limit
958 (`fortran-window-create').
960 The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
961 above the current line. The comment ruler consists of two lines of
962 text that show you the locations of columns with special significance
963 in Fortran programs. Square brackets show the limits of the columns for
964 line numbers, and curly brackets show the limits of the columns for the
965 statement body. Column numbers appear above them.
967 Note that the column numbers count from zero, as always in XEmacs.
968 As a result, the numbers may not be those you are familiar with; but the
969 actual positions in the line are standard Fortran.
971 The text used to display the column ruler is the value of the
972 variable `fortran-comment-ruler'. By changing this variable, you can
975 For even more help, use `C-c C-w' (`fortran-window-create'), a
976 command which splits the current window horizontally, resulting in a
977 window 72 columns wide. When you edit in this window, you can
978 immediately see when a line gets too wide to be correct Fortran.
981 File: xemacs.info, Node: Fortran Abbrev, Prev: Fortran Columns, Up: Fortran
983 Fortran Keyword Abbrevs
984 -----------------------
986 Fortran mode provides many built-in abbrevs for common keywords and
987 declarations. These are the same sort of abbrevs that you can define
988 yourself. To use them, you must turn on Abbrev mode. *note Abbrevs::.
990 The built-in abbrevs are unusual in one way: they all start with a
991 semicolon. You cannot normally use semicolon in an abbrev, but Fortran
992 mode makes this possible by changing the syntax of semicolon to "word
995 For example, one built-in Fortran abbrev is `;c' for `continue'. If
996 you insert `;c' and then insert a punctuation character such as a space
997 or a newline, the `;c' changes automatically to `continue', provided
998 Abbrev mode is enabled.
1000 Type `;?' or `;C-h' to display a list of all built-in Fortran
1001 abbrevs and what they stand for.
1004 File: xemacs.info, Node: Asm Mode, Prev: Fortran, Up: Programs
1009 Asm mode is a major mode for editing files of assembler code. It
1010 defines these commands:
1016 Insert a newline and then indent using `tab-to-tab-stop'.
1019 Insert a colon and then remove the indentation from before the
1020 label preceding colon. Then do `tab-to-tab-stop'.
1023 Insert or align a comment.
1025 The variable `asm-comment-char' specifies which character starts
1026 comments in assembler syntax.
1029 File: xemacs.info, Node: Running, Next: Abbrevs, Prev: Programs, Up: Top
1031 Compiling and Testing Programs
1032 ******************************
1034 The previous chapter discusses the Emacs commands that are useful for
1035 making changes in programs. This chapter deals with commands that
1036 assist in the larger process of developing and maintaining programs.
1040 * Compilation:: Compiling programs in languages other than Lisp
1042 * Modes: Lisp Modes. Various modes for editing Lisp programs, with
1043 different facilities for running the Lisp programs.
1044 * Libraries: Lisp Libraries. Creating Lisp programs to run in Emacs.
1045 * Eval: Lisp Eval. Executing a single Lisp expression in Emacs.
1046 * Debug: Lisp Debug. Debugging Lisp programs running in Emacs.
1047 * Interaction: Lisp Interaction. Executing Lisp in an Emacs buffer.
1048 * External Lisp:: Communicating through Emacs with a separate Lisp.
1051 File: xemacs.info, Node: Compilation, Next: Lisp Modes, Prev: Running, Up: Running
1053 Running "make", or Compilers Generally
1054 ======================================
1056 Emacs can run compilers for non-interactive languages like C and
1057 Fortran as inferior processes, feeding the error log into an Emacs
1058 buffer. It can also parse the error messages and visit the files in
1059 which errors are found, moving point to the line where the error
1063 Run a compiler asynchronously under Emacs, with error messages to
1064 `*compilation*' buffer.
1067 Run `grep' asynchronously under Emacs, with matching lines listed
1068 in the buffer named `*compilation*'.
1070 `M-x kill-compilation'
1071 Kill the process made by the `M-x compile' command.
1074 Kill the running compilation or `grep' subprocess.
1077 Visit the next compiler error message or `grep' match.
1079 To run `make' or another compiler, type `M-x compile'. This command
1080 reads a shell command line using the minibuffer, then executes the
1081 specified command line in an inferior shell with output going to the
1082 buffer named `*compilation*'. By default, the current buffer's default
1083 directory is used as the working directory for the execution of the
1084 command; therefore, the makefile comes from this directory.
1086 When the shell command line is read, the minibuffer appears
1087 containing a default command line (the command you used the last time
1088 you typed `M-x compile'). If you type just <RET>, the same command
1089 line is used again. The first `M-x compile' provides `make -k' as the
1090 default. The default is taken from the variable `compile-command'; if
1091 the appropriate compilation command for a file is something other than
1092 `make -k', it can be useful to have the file specify a local value for
1093 `compile-command' (*note File Variables::).
1095 When you start a compilation, the buffer `*compilation*' is
1096 displayed in another window but not selected. Its mode line displays
1097 the word `run' or `exit' in the parentheses to tell you whether
1098 compilation is finished. You do not have to keep this buffer visible;
1099 compilation continues in any case.
1101 To kill the compilation process, type `M-x kill-compilation'. The
1102 mode line of the `*compilation*' buffer changes to say `signal' instead
1103 of `run'. Starting a new compilation also kills any running
1104 compilation, as only one can occur at any time. Starting a new
1105 compilation prompts for confirmation before actually killing a
1106 compilation that is running.
1108 To parse the compiler error messages, type `C-x `' (`next-error').
1109 The character following `C-x' is the grave accent, not the single
1110 quote. The command displays the buffer `*compilation*' in one window
1111 and the buffer in which the next error occurred in another window.
1112 Point in that buffer is moved to the line where the error was found.
1113 The corresponding error message is scrolled to the top of the window in
1114 which `*compilation*' is displayed.
1116 The first time you use `C-x `' after the start of a compilation, it
1117 parses all the error messages, visits all the files that have error
1118 messages, and creates markers pointing at the lines the error messages
1119 refer to. It then moves to the first error message location.
1120 Subsequent uses of `C-x `' advance down the data set up by the first
1121 use. When the preparsed error messages are exhausted, the next `C-x `'
1122 checks for any more error messages that have come in; this is useful if
1123 you start editing compiler errors while compilation is still going on.
1124 If no additional error messages have come in, `C-x `' reports an error.
1126 `C-u C-x `' discards the preparsed error message data and parses the
1127 `*compilation*' buffer again, then displays the first error. This way,
1128 you can process the same set of errors again.
1130 Instead of running a compiler, you can run `grep' and see the lines
1131 on which matches were found. To do this, type `M-x grep' with an
1132 argument line that contains the same arguments you would give to
1133 `grep': a `grep'-style regexp (usually in single quotes to quote the
1134 shell's special characters) followed by filenames, which may use
1135 wildcard characters. The output from `grep' goes in the
1136 `*compilation*' buffer. You can use `C-x `' to find the lines that
1137 match as if they were compilation errors.
1139 Note: a shell is used to run the compile command, but the shell is
1140 not run in interactive mode. In particular, this means that the shell
1141 starts up with no prompt. If you find your usual shell prompt making an
1142 unsightly appearance in the `*compilation*' buffer, it means you have
1143 made a mistake in your shell's initialization file (`.cshrc' or `.shrc'
1144 or ...) by setting the prompt unconditionally. The shell
1145 initialization file should set the prompt only if there already is a
1146 prompt. Here's how to do it in `csh':
1148 if ($?prompt) set prompt = ...
1151 File: xemacs.info, Node: Lisp Modes, Next: Lisp Libraries, Prev: Compilation, Up: Running
1153 Major Modes for Lisp
1154 ====================
1156 Emacs has four different major modes for Lisp. They are the same in
1157 terms of editing commands, but differ in the commands for executing Lisp
1161 The mode for editing source files of programs to run in Emacs Lisp.
1162 This mode defines `C-M-x' to evaluate the current defun. *Note
1165 Lisp Interaction mode
1166 The mode for an interactive session with Emacs Lisp. It defines
1167 <LFD> to evaluate the sexp before point and insert its value in the
1168 buffer. *Note Lisp Interaction::.
1171 The mode for editing source files of programs that run in other
1172 dialects of Lisp than Emacs Lisp. This mode defines `C-M-x' to
1173 send the current defun to an inferior Lisp process. *Note
1177 The mode for an interactive session with an inferior Lisp process.
1178 This mode combines the special features of Lisp mode and Shell mode
1179 (*note Shell Mode::).
1182 Like Lisp mode but for Scheme programs.
1184 Inferior Scheme mode
1185 The mode for an interactive session with an inferior Scheme
1189 File: xemacs.info, Node: Lisp Libraries, Next: Lisp Eval, Prev: Lisp Modes, Up: Running
1191 Libraries of Lisp Code for Emacs
1192 ================================
1194 Lisp code for Emacs editing commands is stored in files whose names
1195 conventionally end in `.el'. This ending tells Emacs to edit them in
1196 Emacs-Lisp mode (*note Lisp Modes::).
1200 * Loading:: Loading libraries of Lisp code into Emacs for use.
1201 * Compiling Libraries:: Compiling a library makes it load and run faster.
1202 * Mocklisp:: Converting Mocklisp to Lisp so XEmacs can run it.