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".
114 The Ebrowse is a separate facility tailored for C++, with tags and a
115 class browser. *Note : (ebrowse).
119 * Tag Syntax:: Tag syntax for various types of code and text files.
120 * Create Tags Table:: Creating a tags table with `etags'.
121 * Etags Regexps:: Create arbitrary tags using regular expressions.
122 * Select Tags Table:: How to visit a tags table.
123 * Find Tag:: Commands to find the definition of a specific tag.
124 * Tags Search:: Using a tags table for searching and replacing.
125 * List Tags:: Listing and finding tags defined in a file.
128 File: xemacs.info, Node: Tag Syntax, Next: Create Tags Table, Up: Tags
130 Source File Tag Syntax
131 ----------------------
133 Here is how tag syntax is defined for the most popular languages:
135 * In C code, any C function or typedef is a tag, and so are
136 definitions of `struct', `union' and `enum'. You can tag function
137 declarations and external variables in addition to function
138 definitions by giving the `--declarations' option to `etags'.
139 `#define' macro definitions and `enum' constants are also tags,
140 unless you specify `--no-defines' when making the tags table.
141 Similarly, global variables are tags, unless you specify
142 `--no-globals'. Use of `--no-globals' and `--no-defines' can make
143 the tags table file much smaller.
145 * In C++ code, in addition to all the tag constructs of C code,
146 member functions are also recognized, and optionally member
147 variables if you use the `--members' option. Tags for variables
148 and functions in classes are named `CLASS::VARIABLE' and
149 `CLASS::FUNCTION'. `operator' functions tags are named, for
152 * In Java code, tags include all the constructs recognized in C++,
153 plus the `interface', `extends' and `implements' constructs. Tags
154 for variables and functions in classes are named `CLASS.VARIABLE'
155 and `CLASS.FUNCTION'.
157 * In LaTeX text, the argument of any of the commands `\chapter',
158 `\section', `\subsection', `\subsubsection', `\eqno', `\label',
159 `\ref', `\cite', `\bibitem', `\part', `\appendix', `\entry', or
162 Other commands can make tags as well, if you specify them in the
163 environment variable `TEXTAGS' before invoking `etags'. The value
164 of this environment variable should be a colon-separated list of
165 command names. For example,
167 TEXTAGS="def:newcommand:newenvironment"
170 specifies (using Bourne shell syntax) that the commands `\def',
171 `\newcommand' and `\newenvironment' also define tags.
173 * In Lisp code, any function defined with `defun', any variable
174 defined with `defvar' or `defconst', and in general the first
175 argument of any expression that starts with `(def' in column zero,
178 * In Scheme code, tags include anything defined with `def' or with a
179 construct whose name starts with `def'. They also include
180 variables set with `set!' at top level in the file.
182 Several other languages are also supported:
184 * In Ada code, functions, procedures, packages, tasks, and types are
185 tags. Use the `--packages-only' option to create tags for
188 With Ada, it is possible to have the same name used for different
189 entity kinds (e.g. the same name for a procedure and a function).
190 Also, for things like packages, procedures and functions, there is
191 the spec (i.e. the interface) and the body (i.e. the
192 implementation). To facilitate the choice to the user, a tag
193 value is appended with a qualifier:
213 So, as an example, `M-x find-tag bidule/b' will go directly to the
214 body of the package BIDULE while `M-x find-tag bidule' will just
215 search for any tag BIDULE.
217 * In assembler code, labels appearing at the beginning of a line,
218 followed by a colon, are tags.
220 * In Bison or Yacc input files, each rule defines as a tag the
221 nonterminal it constructs. The portions of the file that contain
222 C code are parsed as C code.
224 * In Cobol code, tags are paragraph names; that is, any word
225 starting in column 8 and followed by a period.
227 * In Erlang code, the tags are the functions, records, and macros
230 * In Fortran code, functions, subroutines and blockdata are tags.
232 * In makefiles, targets are tags.
234 * In Objective C code, tags include Objective C definitions for
235 classes, class categories, methods, and protocols.
237 * In Pascal code, the tags are the functions and procedures defined
240 * In Perl code, the tags are the procedures defined by the `sub',
241 `my' and `local' keywords. Use `--globals' if you want to tag
244 * In PostScript code, the tags are the functions.
246 * In Prolog code, a tag name appears at the left margin.
248 * In Python code, `def' or `class' at the beginning of a line
251 You can also generate tags based on regexp matching (*note Etags
252 Regexps::) to handle other formats and languages.
255 File: xemacs.info, Node: Create Tags Table, Next: Etags Regexps, Prev: Tag Syntax, Up: Tags
260 The `etags' program is used to create a tags table file. It knows
261 the syntax of several languages, as described in *Note Tag Syntax::.
262 Here is how to run `etags':
266 The `etags' program reads the specified files, and writes a tags table
267 named `TAGS' in the current working directory. You can intermix
268 compressed and plain text source file names. `etags' knows about the
269 most common compression formats, and does the right thing. So you can
270 compress all your source files and have `etags' look for compressed
271 versions of its file name arguments, if it does not find uncompressed
272 versions. Under MS-DOS, `etags' also looks for file names like
273 `mycode.cgz' if it is given `mycode.c' on the command line and
274 `mycode.c' does not exist.
276 `etags' recognizes the language used in an input file based on its
277 file name and contents. You can specify the language with the
278 `--language=NAME' option, described below.
280 If the tags table data become outdated due to changes in the files
281 described in the table, the way to update the tags table is the same
282 way it was made in the first place. It is not necessary to do this
285 If the tags table fails to record a tag, or records it for the wrong
286 file, then Emacs cannot possibly find its definition. However, if the
287 position recorded in the tags table becomes a little bit wrong (due to
288 some editing in the file that the tag definition is in), the only
289 consequence is a slight delay in finding the tag. Even if the stored
290 position is very wrong, Emacs will still find the tag, but it must
291 search the entire file for it.
293 So you should update a tags table when you define new tags that you
294 want to have listed, or when you move tag definitions from one file to
295 another, or when changes become substantial. Normally there is no need
296 to update the tags table after each edit, or even every day.
298 One tags table can effectively include another. Specify the included
299 tags file name with the `--include=FILE' option when creating the file
300 that is to include it. The latter file then acts as if it contained
301 all the files specified in the included file, as well as the files it
304 If you specify the source files with relative file names when you run
305 `etags', the tags file will contain file names relative to the
306 directory where the tags file was initially written. This way, you can
307 move an entire directory tree containing both the tags file and the
308 source files, and the tags file will still refer correctly to the source
311 If you specify absolute file names as arguments to `etags', then the
312 tags file will contain absolute file names. This way, the tags file
313 will still refer to the same files even if you move it, as long as the
314 source files remain in the same place. Absolute file names start with
315 `/', or with `DEVICE:/' on MS-DOS and MS-Windows.
317 When you want to make a tags table from a great number of files, you
318 may have problems listing them on the command line, because some systems
319 have a limit on its length. The simplest way to circumvent this limit
320 is to tell `etags' to read the file names from its standard input, by
321 typing a dash in place of the file names, like this:
323 find . -name "*.[chCH]" -print | etags -
325 Use the option `--language=NAME' to specify the language explicitly.
326 You can intermix these options with file names; each one applies to
327 the file names that follow it. Specify `--language=auto' to tell
328 `etags' to resume guessing the language from the file names and file
329 contents. Specify `--language=none' to turn off language-specific
330 processing entirely; then `etags' recognizes tags by regexp matching
331 alone (*note Etags Regexps::).
333 `etags --help' prints the list of the languages `etags' knows, and
334 the file name rules for guessing the language. It also prints a list of
335 all the available `etags' options, together with a short explanation.
338 File: xemacs.info, Node: Etags Regexps, Next: Select Tags Table, Prev: Create Tags Table, Up: Tags
343 The `--regex' option provides a general way of recognizing tags
344 based on regexp matching. You can freely intermix it with file names.
345 Each `--regex' option adds to the preceding ones, and applies only to
346 the following files. The syntax is:
348 --regex=/TAGREGEXP[/NAMEREGEXP]/
350 where TAGREGEXP is used to match the lines to tag. It is always
351 anchored, that is, it behaves as if preceded by `^'. If you want to
352 account for indentation, just match any initial number of blanks by
353 beginning your regular expression with `[ \t]*'. In the regular
354 expressions, `\' quotes the next character, and `\t' stands for the tab
355 character. Note that `etags' does not handle the other C escape
356 sequences for special characters.
358 The syntax of regular expressions in `etags' is the same as in
359 Emacs, augmented with the "interval operator", which works as in `grep'
360 and `ed'. The syntax of an interval operator is `\{M,N\}', and its
361 meaning is to match the preceding expression at least M times and up to
364 You should not match more characters with TAGREGEXP than that needed
365 to recognize what you want to tag. If the match is such that more
366 characters than needed are unavoidably matched by TAGREGEXP (as will
367 usually be the case), you should add a NAMEREGEXP, to pick out just the
368 tag. This will enable Emacs to find tags more accurately and to do
369 completion on tag names more reliably. You can find some examples
372 The option `--ignore-case-regex' (or `-c') is like `--regex', except
373 that the regular expression provided will be matched without regard to
374 case, which is appropriate for various programming languages.
376 The `-R' option deletes all the regexps defined with `--regex'
377 options. It applies to the file names following it, as you can see
378 from the following example:
380 etags --regex=/REG1/ voo.doo --regex=/REG2/ \
381 bar.ber -R --lang=lisp los.er
383 Here `etags' chooses the parsing language for `voo.doo' and `bar.ber'
384 according to their contents. `etags' also uses REG1 to recognize
385 additional tags in `voo.doo', and both REG1 and REG2 to recognize
386 additional tags in `bar.ber'. `etags' uses the Lisp tags rules, and no
387 regexp matching, to recognize tags in `los.er'.
389 A regular expression can be bound to a given language, by prepending
390 it with `{lang}'. When you do this, `etags' will use the regular
391 expression only for files of that language. `etags --help' prints the
392 list of languages recognised by `etags'. The following example tags
393 the `DEFVAR' macros in the Emacs source files. `etags' applies this
394 regular expression to C files only:
396 --regex='{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
398 This feature is particularly useful when storing a list of regular
399 expressions in a file. The following option syntax instructs `etags'
400 to read two files of regular expressions. The regular expressions
401 contained in the second file are matched without regard to case.
403 --regex=@first-file --ignore-case-regex=@second-file
405 A regex file contains one regular expressions per line. Empty lines,
406 and lines beginning with space or tab are ignored. When the first
407 character in a line is `@', `etags' assumes that the rest of the line
408 is the name of a file of regular expressions. This means that such
409 files can be nested. All the other lines are taken to be regular
410 expressions. For example, one can create a file called `emacs.tags'
411 with the following contents (the first line in the file is a comment):
413 -- This is for GNU Emacs source files
414 {c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/
416 and then use it like this:
418 etags --regex=@emacs.tags *.[ch] */*.[ch]
420 Here are some more examples. The regexps are quoted to protect them
421 from shell interpretation.
425 etags --language=none \
426 --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \
427 --regex='/###key \(.*\)/\1/' \
428 --regex='/[ \t]*global[ \t].*/' \
431 Note that tags are not generated for scripts so that you have to
432 add a line by yourself of the form `###key <script-name>' if you
437 etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl
442 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \
443 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
444 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
447 File: xemacs.info, Node: Select Tags Table, Next: Find Tag, Prev: Etags Regexps, Up: Tags
449 Selecting a Tags Table
450 ----------------------
452 At any time Emacs has one "selected" tags table, and all the commands
453 for working with tags tables use the selected one. To select a tags
454 table, use the variable `tag-table-alist'.
456 The value of `tag-table-alist' is a list that determines which
457 `TAGS' files should be active for a given buffer. This is not really
458 an association list, in that all elements are checked. The car of each
459 element of this list is a pattern against which the buffers file name
460 is compared; if it matches, then the cdr of the list should be the name
461 of the tags table to use. If more than one element of this list
462 matches the buffers file name, all of the associated tags tables are
463 used. Earlier ones are searched first.
465 If the car of elements of this list are strings, they are treated as
466 regular-expressions against which the file is compared (like the
467 `auto-mode-alist'). If they are not strings, they are evaluated. If
468 they evaluate to non-`nil', the current buffer is considered to match.
470 If the cdr of the elements of this list are strings, they are
471 assumed to name a tags file. If they name a directory, the string
472 `tags' is appended to them to get the file name. If they are not
473 strings, they are evaluated and must return an appropriate string.
477 (setq tag-table-alist
478 '(("/usr/src/public/perl/" . "/usr/src/public/perl/perl-3.0/")
479 ("\\.el$" . "/usr/local/emacs/src/")
480 ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
481 ("" . "/usr/local/emacs/src/")
484 The example defines the tags table alist in the following way:
486 * Anything in the directory `/usr/src/public/perl/' should use the
487 `TAGS' file `/usr/src/public/perl/perl-3.0/TAGS'.
489 * Files ending in `.el' should use the `TAGS' file
490 `/usr/local/emacs/src/TAGS'.
492 * Anything in or below the directory `/jbw/gnu/' should use the
493 `TAGS' file `/usr15/degree/stud/jbw/gnu/TAGS'.
495 If you had a file called `/usr/jbw/foo.el', it would use both `TAGS'
497 `/usr/local/emacs/src/TAGS' and `/usr15/degree/stud/jbw/gnu/TAGS' (in
498 that order), because it matches both patterns.
500 If the buffer-local variable `buffer-tag-table' is set, it names a
501 tags table that is searched before all others when `find-tag' is
502 executed from this buffer.
504 If there is a file called `TAGS' in the same directory as the file
505 in question, then that tags file will always be used as well (after the
506 `buffer-tag-table' but before the tables specified by this list).
508 If the variable `tags-file-name' is set, the `TAGS' file it names
509 will apply to all buffers (for backwards compatibility.) It is searched
512 If the value of the variable `tags-always-build-completion-table' is
513 `t', the tags file will always be added to the completion table without
514 asking first, regardless of the size of the tags file.
516 The function `M-x visit-tags-table', is largely made obsolete by the
517 variable `tag-table-alist', tells tags commands to use the tags table
518 file FILE first. The FILE should be the name of a file created with
519 the `etags' program. A directory name is also acceptable; it means the
520 file `TAGS' in that directory. The function only stores the file name
521 you provide in the variable `tags-file-name'. Emacs does not actually
522 read in the tags table contents until you try to use them. You can set
523 the variable explicitly instead of using `visit-tags-table'. The value
524 of the variable `tags-file-name' is the name of the tags table used by
525 all buffers. This is for backward compatibility, and is largely
526 supplanted by the variable `tag-table-alist'.
529 File: xemacs.info, Node: Find Tag, Next: Tags Search, Prev: Select Tags Table, Up: Tags
534 The most important thing that a tags table enables you to do is to
535 find the definition of a specific tag.
537 `M-. TAG &OPTIONAL OTHER-WINDOW'
538 Find first definition of TAG (`find-tag').
541 Find next alternate definition of last tag specified.
544 Find first definition of TAG, but display it in another window
545 (`find-tag-other-window').
547 `M-.' (`find-tag') is the command to find the definition of a
548 specified tag. It searches through the tags table for that tag, as a
549 string, then uses the tags table information to determine the file in
550 which the definition is used and the approximate character position of
551 the definition in the file. Then `find-tag' visits the file, moves
552 point to the approximate character position, and starts searching
553 ever-increasing distances away for the text that should appear at the
554 beginning of the definition.
556 If an empty argument is given (by typing <RET>), the sexp in the
557 buffer before or around point is used as the name of the tag to find.
558 *Note Lists::, for information on sexps.
560 The argument to `find-tag' need not be the whole tag name; it can be
561 a substring of a tag name. However, there can be many tag names
562 containing the substring you specify. Since `find-tag' works by
563 searching the text of the tags table, it finds the first tag in the
564 table that the specified substring appears in. To find other tags that
565 match the substring, give `find-tag' a numeric argument, as in `C-u
566 M-.'. This does not read a tag name, but continues searching the tag
567 table's text for another tag containing the same substring last used.
568 If your keyboard has a real <META> key, `M-0 M-.' is an easier
569 alternative to `C-u M-.'.
571 If the optional second argument OTHER-WINDOW is non-`nil', it uses
572 another window to display the tag. Multiple active tags tables and
573 completion are supported.
575 Variables of note include the following:
578 Controls which tables apply to which buffers.
581 Stores a default tags table.
583 `tags-build-completion-table'
584 Controls completion behavior.
587 Specifies a buffer-local table.
589 `make-tags-files-invisible'
590 Sets whether tags tables should be very hidden.
593 Specifies how many tags-based hops to remember.
595 Like most commands that can switch buffers, `find-tag' has another
596 similar command that displays the new buffer in another window. `C-x 4
597 .' invokes the function `find-tag-other-window'. (This key sequence
600 Emacs comes with a tags table file `TAGS' (in the directory
601 containing Lisp libraries) that includes all the Lisp libraries and all
602 the C sources of Emacs. By specifying this file with `visit-tags-table'
603 and then using `M-.' you can quickly look at the source of any Emacs
607 File: xemacs.info, Node: Tags Search, Next: List Tags, Prev: Find Tag, Up: Tags
609 Searching and Replacing with Tags Tables
610 ----------------------------------------
612 The commands in this section visit and search all the files listed
613 in the selected tags table, one by one. For these commands, the tags
614 table serves only to specify a sequence of files to search. A related
615 command is `M-x grep' (*note Compilation::).
617 `M-x tags-search <RET> REGEXP <RET>'
618 Search for REGEXP through the files in the selected tags table.
620 `M-x tags-query-replace <RET> REGEXP <RET> REPLACEMENT <RET>'
621 Perform a `query-replace-regexp' on each file in the selected tags
625 Restart one of the commands above, from the current location of
626 point (`tags-loop-continue').
628 `M-x tags-search' reads a regexp using the minibuffer, then searches
629 for matches in all the files in the selected tags table, one file at a
630 time. It displays the name of the file being searched so you can
631 follow its progress. As soon as it finds an occurrence, `tags-search'
634 Having found one match, you probably want to find all the rest. To
635 find one more match, type `M-,' (`tags-loop-continue') to resume the
636 `tags-search'. This searches the rest of the current buffer, followed
637 by the remaining files of the tags table.
639 `M-x tags-query-replace' performs a single `query-replace-regexp'
640 through all the files in the tags table. It reads a regexp to search
641 for and a string to replace with, just like ordinary `M-x
642 query-replace-regexp'. It searches much like `M-x tags-search', but
643 repeatedly, processing matches according to your input. *Note
644 Replace::, for more information on query replace.
646 It is possible to get through all the files in the tags table with a
647 single invocation of `M-x tags-query-replace'. But often it is useful
648 to exit temporarily, which you can do with any input event that has no
649 special query replace meaning. You can resume the query replace
650 subsequently by typing `M-,'; this command resumes the last tags search
651 or replace command that you did.
653 The commands in this section carry out much broader searches than the
654 `find-tag' family. The `find-tag' commands search only for definitions
655 of tags that match your substring or regexp. The commands
656 `tags-search' and `tags-query-replace' find every occurrence of the
657 regexp, as ordinary search commands and replace commands do in the
660 These commands create buffers only temporarily for the files that
661 they have to search (those which are not already visited in Emacs
662 buffers). Buffers in which no match is found are quickly killed; the
663 others continue to exist.
665 It may have struck you that `tags-search' is a lot like `grep'. You
666 can also run `grep' itself as an inferior of Emacs and have Emacs show
667 you the matching lines one by one. This works much like running a
668 compilation; finding the source locations of the `grep' matches works
669 like finding the compilation errors. *Note Compilation::.
671 If you wish to process all the files in a selected tags table, but
672 `M-x tags-search' and `M-x tags-query-replace' are not giving you the
673 desired result, you can use `M-x next-file'.
676 With a numeric argument, regardless of its value, visit the first
677 file in the tags table and prepare to advance sequentially by
681 Visit the next file in the selected tags table.
684 File: xemacs.info, Node: List Tags, Prev: Tags Search, Up: Tags
690 Display a list of the tags defined in a specific program file.
693 Display a list of all tags matching a specified regexp.
695 `M-x list-tags' reads the name of one of the files described by the
696 selected tags table, and displays a list of all the tags defined in that
697 file. The "file name" argument is really just a string to compare
698 against the names recorded in the tags table; it is read as a string
699 rather than a file name. Therefore, completion and defaulting are not
700 available, and you must enter the string the same way it appears in the
701 tag table. Do not include a directory as part of the file name unless
702 the file name recorded in the tags table contains that directory.
704 `M-x tags-apropos' is like `apropos' for tags. It reads a regexp,
705 then finds all the tags in the selected tags table whose entries match
706 that regexp, and displays the tag names found.
709 File: xemacs.info, Node: Fortran, Next: Asm Mode, Prev: Tags, Up: Programs
714 Fortran mode provides special motion commands for Fortran statements
715 and subprograms, and indentation commands that understand Fortran
716 conventions of nesting, line numbers, and continuation statements.
718 Special commands for comments are provided because Fortran comments
719 are unlike those of other languages.
721 Built-in abbrevs optionally save typing when you insert Fortran
724 Use `M-x fortran-mode' to switch to this major mode. Doing so calls
725 the value of `fortran-mode-hook' as a function of no arguments if that
726 variable has a non-`nil' value.
730 * Motion: Fortran Motion. Moving point by statements or subprograms.
731 * Indent: Fortran Indent. Indentation commands for Fortran.
732 * Comments: Fortran Comments. Inserting and aligning comments.
733 * Columns: Fortran Columns. Measuring columns for valid Fortran.
734 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
736 Fortran mode was contributed by Michael Prange.
739 File: xemacs.info, Node: Fortran Motion, Next: Fortran Indent, Prev: Fortran, Up: Fortran
744 Fortran mode provides special commands to move by subprograms
745 (functions and subroutines) and by statements. There is also a command
746 to put the region around one subprogram, which is convenient for
747 killing it or moving it.
750 Move to beginning of subprogram
751 (`beginning-of-fortran-subprogram').
754 Move to end of subprogram (`end-of-fortran-subprogram').
757 Put point at beginning of subprogram and mark at end
758 (`mark-fortran-subprogram').
761 Move to beginning of current or next statement (`fortran-next-
765 Move to beginning of current or previous statement (`fortran-
766 previous-statement').
769 File: xemacs.info, Node: Fortran Indent, Next: Fortran Comments, Prev: Fortran Motion, Up: Fortran
774 Special commands and features are available for indenting Fortran
775 code. They make sure various syntactic entities (line numbers, comment
776 line indicators, and continuation line flags) appear in the columns
777 that are required for standard Fortran.
781 * Commands: ForIndent Commands. Commands for indenting Fortran.
782 * Numbers: ForIndent Num. How line numbers auto-indent.
783 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
784 * Vars: ForIndent Vars. Variables controlling Fortran indent style.
787 File: xemacs.info, Node: ForIndent Commands, Next: ForIndent Num, Prev: Fortran Indent, Up: Fortran Indent
789 Fortran Indentation Commands
790 ............................
793 Indent the current line (`fortran-indent-line').
796 Break the current line and set up a continuation line.
799 Indent all the lines of the subprogram point is in
800 (`fortran-indent-subprogram').
802 <TAB> is redefined by Fortran mode to reindent the current line for
803 Fortran (`fortran-indent-line'). Line numbers and continuation markers
804 are indented to their required columns, and the body of the statement
805 is independently indented, based on its nesting in the program.
807 The key `C-M-q' is redefined as `fortran-indent-subprogram', a
808 command that reindents all the lines of the Fortran subprogram
809 (function or subroutine) containing point.
811 The key `M-<LFD>' is redefined as `fortran-split-line', a command to
812 split a line in the appropriate fashion for Fortran. In a non-comment
813 line, the second half becomes a continuation line and is indented
814 accordingly. In a comment line, both halves become separate comment
818 File: xemacs.info, Node: ForIndent Num, Next: ForIndent Conv, Prev: ForIndent Commands, Up: Fortran Indent
820 Line Numbers and Continuation
821 .............................
823 If a number is the first non-whitespace in the line, it is assumed
824 to be a line number and is moved to columns 0 through 4. (Columns are
825 always counted from 0 in XEmacs.) If the text on the line starts with
826 the conventional Fortran continuation marker `$', it is moved to column
827 5. If the text begins with any non whitespace character in column 5,
828 it is assumed to be an unconventional continuation marker and remains
831 Line numbers of four digits or less are normally indented one space.
832 This amount is controlled by the variable `fortran-line-number-indent',
833 which is the maximum indentation a line number can have. Line numbers
834 are indented to right-justify them to end in column 4 unless that would
835 require more than the maximum indentation. The default value of the
838 Simply inserting a line number is enough to indent it according to
839 these rules. As each digit is inserted, the indentation is recomputed.
840 To turn off this feature, set the variable
841 `fortran-electric-line-number' to `nil'. Then inserting line numbers
842 is like inserting anything else.
845 File: xemacs.info, Node: ForIndent Conv, Next: ForIndent Vars, Prev: ForIndent Num, Up: Fortran Indent
847 Syntactic Conventions
848 .....................
850 Fortran mode assumes that you follow certain conventions that
851 simplify the task of understanding a Fortran program well enough to
854 * Two nested `do' loops never share a `continue' statement.
856 * The same character appears in column 5 of all continuation lines.
857 It is the value of the variable `fortran-continuation-char'. By
858 default, this character is `$'.
860 If you fail to follow these conventions, the indentation commands may
861 indent some lines unaesthetically. However, a correct Fortran program
862 will retain its meaning when reindented even if the conventions are not
866 File: xemacs.info, Node: ForIndent Vars, Prev: ForIndent Conv, Up: Fortran Indent
868 Variables for Fortran Indentation
869 .................................
871 Several additional variables control how Fortran indentation works.
874 Extra indentation within each level of `do' statement (the default
878 Extra indentation within each level of `if' statement (the default
881 `fortran-continuation-indent'
882 Extra indentation for bodies of continuation lines (the default is
885 `fortran-check-all-num-for-matching-do'
886 If this is `nil', indentation assumes that each `do' statement
887 ends on a `continue' statement. Therefore, when computing
888 indentation for a statement other than `continue', it can save
889 time by not checking for a `do' statement ending there. If this
890 is non-`nil', indenting any numbered statement must check for a
891 `do' that ends there. The default is `nil'.
893 `fortran-minimum-statement-indent'
894 Minimum indentation for Fortran statements. For standard Fortran,
895 this is 6. Statement bodies are always indented at least this
899 File: xemacs.info, Node: Fortran Comments, Next: Fortran Columns, Prev: Fortran Indent, Up: Fortran
904 The usual Emacs comment commands assume that a comment can follow a
905 line of code. In Fortran, the standard comment syntax requires an
906 entire line to be just a comment. Therefore, Fortran mode replaces the
907 standard Emacs comment commands and defines some new variables.
909 Fortran mode can also handle a non-standard comment syntax where
910 comments start with `!' and can follow other text. Because only some
911 Fortran compilers accept this syntax, Fortran mode will not insert such
912 comments unless you have specified to do so in advance by setting the
913 variable `comment-start' to `"!"' (*note Variables::).
916 Align comment or insert new comment (`fortran-comment-indent').
919 Applies to nonstandard `!' comments only.
922 Turn all lines of the region into comments, or (with arg) turn
923 them back into real code (`fortran-comment-region').
925 `M-;' in Fortran mode is redefined as the command
926 `fortran-comment-indent'. Like the usual `M-;' command, it recognizes
927 an existing comment and aligns its text appropriately. If there is no
928 existing comment, a comment is inserted and aligned.
930 Inserting and aligning comments is not the same in Fortran mode as in
931 other modes. When a new comment must be inserted, a full-line comment
932 is inserted if the current line is blank. On a non-blank line, a
933 non-standard `!' comment is inserted if you previously specified you
934 wanted to use them. Otherwise a full-line comment is inserted on a new
935 line before the current line.
937 Non-standard `!' comments are aligned like comments in other
938 languages, but full-line comments are aligned differently. In a
939 standard full-line comment, the comment delimiter itself must always
940 appear in column zero. What can be aligned is the text within the
941 comment. You can choose from three styles of alignment by setting the
942 variable `fortran-comment-indent-style' to one of these values:
945 The text is aligned at a fixed column, which is the value of
946 `fortran-comment-line-column'. This is the default.
949 The text is aligned as if it were a line of code, but with an
950 additional `fortran-comment-line-column' columns of indentation.
953 Text in full-line columns is not moved automatically.
955 You can also specify the character to be used to indent within
956 full-line comments by setting the variable `fortran-comment-indent-char'
957 to the character you want to use.
959 Fortran mode introduces two variables `comment-line-start' and
960 `comment-line-start-skip', which do for full-line comments what
961 `comment-start' and `comment-start-skip' do for ordinary text-following
962 comments. Normally these are set properly by Fortran mode, so you do
963 not need to change them.
965 The normal Emacs comment command `C-x ;' has not been redefined. It
966 can therefore be used if you use `!' comments, but is useless in
967 Fortran mode otherwise.
969 The command `C-c ;' (`fortran-comment-region') turns all the lines
970 of the region into comments by inserting the string `C$$$' at the front
971 of each one. With a numeric arg, the region is turned back into live
972 code by deleting `C$$$' from the front of each line. You can control
973 the string used for the comments by setting the variable
974 `fortran-comment-region'. Note that here we have an example of a
975 command and a variable with the same name; the two uses of the name
976 never conflict because in Lisp and in Emacs it is always clear from the
977 context which one is referred to.
980 File: xemacs.info, Node: Fortran Columns, Next: Fortran Abbrev, Prev: Fortran Comments, Up: Fortran
986 Displays a "column ruler" momentarily above the current line
987 (`fortran-column-ruler').
990 Splits the current window horizontally so that it is 72 columns
991 wide. This may help you avoid going over that limit
992 (`fortran-window-create').
994 The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
995 above the current line. The comment ruler consists of two lines of
996 text that show you the locations of columns with special significance
997 in Fortran programs. Square brackets show the limits of the columns for
998 line numbers, and curly brackets show the limits of the columns for the
999 statement body. Column numbers appear above them.
1001 Note that the column numbers count from zero, as always in XEmacs.
1002 As a result, the numbers may not be those you are familiar with; but the
1003 actual positions in the line are standard Fortran.
1005 The text used to display the column ruler is the value of the
1006 variable `fortran-comment-ruler'. By changing this variable, you can
1009 For even more help, use `C-c C-w' (`fortran-window-create'), a
1010 command which splits the current window horizontally, resulting in a
1011 window 72 columns wide. When you edit in this window, you can
1012 immediately see when a line gets too wide to be correct Fortran.
1015 File: xemacs.info, Node: Fortran Abbrev, Prev: Fortran Columns, Up: Fortran
1017 Fortran Keyword Abbrevs
1018 -----------------------
1020 Fortran mode provides many built-in abbrevs for common keywords and
1021 declarations. These are the same sort of abbrevs that you can define
1022 yourself. To use them, you must turn on Abbrev mode. *note Abbrevs::.
1024 The built-in abbrevs are unusual in one way: they all start with a
1025 semicolon. You cannot normally use semicolon in an abbrev, but Fortran
1026 mode makes this possible by changing the syntax of semicolon to "word
1029 For example, one built-in Fortran abbrev is `;c' for `continue'. If
1030 you insert `;c' and then insert a punctuation character such as a space
1031 or a newline, the `;c' changes automatically to `continue', provided
1032 Abbrev mode is enabled.
1034 Type `;?' or `;C-h' to display a list of all built-in Fortran
1035 abbrevs and what they stand for.
1038 File: xemacs.info, Node: Asm Mode, Prev: Fortran, Up: Programs
1043 Asm mode is a major mode for editing files of assembler code. It
1044 defines these commands:
1050 Insert a newline and then indent using `tab-to-tab-stop'.
1053 Insert a colon and then remove the indentation from before the
1054 label preceding colon. Then do `tab-to-tab-stop'.
1057 Insert or align a comment.
1059 The variable `asm-comment-char' specifies which character starts
1060 comments in assembler syntax.
1063 File: xemacs.info, Node: Running, Next: Abbrevs, Prev: Programs, Up: Top
1065 Compiling and Testing Programs
1066 ******************************
1068 The previous chapter discusses the Emacs commands that are useful for
1069 making changes in programs. This chapter deals with commands that
1070 assist in the larger process of developing and maintaining programs.
1074 * Compilation:: Compiling programs in languages other than Lisp
1076 * Modes: Lisp Modes. Various modes for editing Lisp programs, with
1077 different facilities for running the Lisp programs.
1078 * Libraries: Lisp Libraries. Creating Lisp programs to run in Emacs.
1079 * Eval: Lisp Eval. Executing a single Lisp expression in Emacs.
1080 * Debug: Lisp Debug. Debugging Lisp programs running in Emacs.
1081 * Interaction: Lisp Interaction. Executing Lisp in an Emacs buffer.
1082 * External Lisp:: Communicating through Emacs with a separate Lisp.
1085 File: xemacs.info, Node: Compilation, Next: Lisp Modes, Prev: Running, Up: Running
1087 Running "make", or Compilers Generally
1088 ======================================
1090 Emacs can run compilers for non-interactive languages like C and
1091 Fortran as inferior processes, feeding the error log into an Emacs
1092 buffer. It can also parse the error messages and visit the files in
1093 which errors are found, moving point to the line where the error
1097 Run a compiler asynchronously under Emacs, with error messages to
1098 `*compilation*' buffer.
1101 Run `grep' asynchronously under Emacs, with matching lines listed
1102 in the buffer named `*compilation*'.
1104 `M-x kill-compilation'
1105 Kill the process made by the `M-x compile' command.
1108 Kill the running compilation or `grep' subprocess.
1111 Visit the next compiler error message or `grep' match.
1113 To run `make' or another compiler, type `M-x compile'. This command
1114 reads a shell command line using the minibuffer, then executes the
1115 specified command line in an inferior shell with output going to the
1116 buffer named `*compilation*'. By default, the current buffer's default
1117 directory is used as the working directory for the execution of the
1118 command; therefore, the makefile comes from this directory.
1120 When the shell command line is read, the minibuffer appears
1121 containing a default command line (the command you used the last time
1122 you typed `M-x compile'). If you type just <RET>, the same command
1123 line is used again. The first `M-x compile' provides `make -k' as the
1124 default. The default is taken from the variable `compile-command'; if
1125 the appropriate compilation command for a file is something other than
1126 `make -k', it can be useful to have the file specify a local value for
1127 `compile-command' (*note File Variables::).
1129 When you start a compilation, the buffer `*compilation*' is
1130 displayed in another window but not selected. Its mode line displays
1131 the word `run' or `exit' in the parentheses to tell you whether
1132 compilation is finished. You do not have to keep this buffer visible;
1133 compilation continues in any case.
1135 To kill the compilation process, type `M-x kill-compilation'. The
1136 mode line of the `*compilation*' buffer changes to say `signal' instead
1137 of `run'. Starting a new compilation also kills any running
1138 compilation, as only one can occur at any time. Starting a new
1139 compilation prompts for confirmation before actually killing a
1140 compilation that is running.
1142 To parse the compiler error messages, type `C-x `' (`next-error').
1143 The character following `C-x' is the grave accent, not the single
1144 quote. The command displays the buffer `*compilation*' in one window
1145 and the buffer in which the next error occurred in another window.
1146 Point in that buffer is moved to the line where the error was found.
1147 The corresponding error message is scrolled to the top of the window in
1148 which `*compilation*' is displayed.
1150 The first time you use `C-x `' after the start of a compilation, it
1151 parses all the error messages, visits all the files that have error
1152 messages, and creates markers pointing at the lines the error messages
1153 refer to. It then moves to the first error message location.
1154 Subsequent uses of `C-x `' advance down the data set up by the first
1155 use. When the preparsed error messages are exhausted, the next `C-x `'
1156 checks for any more error messages that have come in; this is useful if
1157 you start editing compiler errors while compilation is still going on.
1158 If no additional error messages have come in, `C-x `' reports an error.
1160 `C-u C-x `' discards the preparsed error message data and parses the
1161 `*compilation*' buffer again, then displays the first error. This way,
1162 you can process the same set of errors again.
1164 Instead of running a compiler, you can run `grep' and see the lines
1165 on which matches were found. To do this, type `M-x grep' with an
1166 argument line that contains the same arguments you would give to
1167 `grep': a `grep'-style regexp (usually in single quotes to quote the
1168 shell's special characters) followed by filenames, which may use
1169 wildcard characters. The output from `grep' goes in the
1170 `*compilation*' buffer. You can use `C-x `' to find the lines that
1171 match as if they were compilation errors.
1173 Note: a shell is used to run the compile command, but the shell is
1174 not run in interactive mode. In particular, this means that the shell
1175 starts up with no prompt. If you find your usual shell prompt making an
1176 unsightly appearance in the `*compilation*' buffer, it means you have
1177 made a mistake in your shell's initialization file (`.cshrc' or `.shrc'
1178 or ...) by setting the prompt unconditionally. The shell
1179 initialization file should set the prompt only if there already is a
1180 prompt. Here's how to do it in `csh':
1182 if ($?prompt) set prompt = ...
1185 File: xemacs.info, Node: Lisp Modes, Next: Lisp Libraries, Prev: Compilation, Up: Running
1187 Major Modes for Lisp
1188 ====================
1190 Emacs has four different major modes for Lisp. They are the same in
1191 terms of editing commands, but differ in the commands for executing Lisp
1195 The mode for editing source files of programs to run in Emacs Lisp.
1196 This mode defines `C-M-x' to evaluate the current defun. *Note
1199 Lisp Interaction mode
1200 The mode for an interactive session with Emacs Lisp. It defines
1201 <LFD> to evaluate the sexp before point and insert its value in the
1202 buffer. *Note Lisp Interaction::.
1205 The mode for editing source files of programs that run in other
1206 dialects of Lisp than Emacs Lisp. This mode defines `C-M-x' to
1207 send the current defun to an inferior Lisp process. *Note
1211 The mode for an interactive session with an inferior Lisp process.
1212 This mode combines the special features of Lisp mode and Shell mode
1213 (*note Shell Mode::).
1216 Like Lisp mode but for Scheme programs.
1218 Inferior Scheme mode
1219 The mode for an interactive session with an inferior Scheme