1 This is ../info/xemacs.info, produced by makeinfo version 4.0 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: C Indent, Prev: Lisp Indent, Up: Grinding
35 Customizing C Indentation
36 -------------------------
38 Two variables control which commands perform C indentation and when.
40 If `c-auto-newline' is non-`nil', newlines are inserted both before
41 and after braces that you insert and after colons and semicolons.
42 Correct C indentation is done on all the lines that are made this way.
44 If `c-tab-always-indent' is non-`nil', the <TAB> command in C mode
45 does indentation only if point is at the left margin or within the
46 line's indentation. If there is non-whitespace to the left of point,
47 <TAB> just inserts a tab character in the buffer. Normally, this
48 variable is `nil', and <TAB> always reindents the current line.
50 C does not have anything analogous to particular function names for
51 which special forms of indentation are desirable. However, it has a
52 different need for customization facilities: many different styles of C
53 indentation are in common use.
55 There are six variables you can set to control the style that Emacs C
59 Indentation of C statements within surrounding block. The
60 surrounding block's indentation is the indentation of the line on
61 which the open-brace appears.
63 `c-continued-statement-offset'
64 Extra indentation given to a substatement, such as the then-clause
65 of an `if' or body of a `while'.
68 Extra indentation for lines that start with an open brace.
70 `c-brace-imaginary-offset'
71 An open brace following other text is treated as if it were this
72 far to the right of the start of its line.
75 Indentation level of declarations of C function arguments.
78 Extra indentation for a line that is a label, case, or default.
80 The variable `c-indent-level' controls the indentation for C
81 statements with respect to the surrounding block. In the example:
86 the difference in indentation between the lines is `c-indent-level'.
87 Its standard value is 2.
89 If the open-brace beginning the compound statement is not at the
90 beginning of its line, the `c-indent-level' is added to the indentation
91 of the line, not the column of the open-brace. For example,
96 One popular indentation style is that which results from setting
97 `c-indent-level' to 8 and putting open-braces at the end of a line in
98 this way. Another popular style prefers to put the open-brace on a
101 In fact, the value of the variable `c-brace-imaginary-offset' is
102 also added to the indentation of such a statement. Normally this
103 variable is zero. Think of this variable as the imaginary position of
104 the open brace, relative to the first non-blank character on the line.
105 By setting the variable to 4 and `c-indent-level' to 0, you can get
112 When `c-indent-level' is zero, the statements inside most braces
113 line up exactly under the open brace. An exception are braces in column
114 zero, like those surrounding a function's body. The statements inside
115 those braces are not placed at column zero. Instead, `c-brace-offset'
116 and `c-continued-statement-offset' (see below) are added to produce a
117 typical offset between brace levels, and the statements are indented
120 `c-continued-statement-offset' controls the extra indentation for a
121 line that starts within a statement (but not within parentheses or
122 brackets). These lines are usually statements inside other statements,
123 like the then-clauses of `if' statements and the bodies of `while'
124 statements. The `c-continued-statement-offset' parameter determines
125 the difference in indentation between the two lines in:
130 The default value for `c-continued-statement-offset' is 2. Some
131 popular indentation styles correspond to a value of zero for
132 `c-continued-statement-offset'.
134 `c-brace-offset' is the extra indentation given to a line that
135 starts with an open-brace. Its standard value is zero; compare:
145 If you set `c-brace-offset' to 4, the first example becomes:
150 `c-argdecl-indent' controls the indentation of declarations of the
151 arguments of a C function. It is absolute: argument declarations
152 receive exactly `c-argdecl-indent' spaces. The standard value is 5 and
153 results in code like this:
160 `c-label-offset' is the extra indentation given to a line that
161 contains a label, a case statement, or a `default:' statement. Its
162 standard value is -2 and results in code like this:
168 If `c-label-offset' were zero, the same code would be indented as:
174 This example assumes that the other variables above also have their
177 Using the indentation style produced by the default settings of the
178 variables just discussed and putting open braces on separate lines
179 produces clear and readable files. For an example, look at any of the C
180 source files of XEmacs.
183 File: xemacs.info, Node: Matching, Next: Comments, Prev: Grinding, Up: Programs
185 Automatic Display of Matching Parentheses
186 =========================================
188 The Emacs parenthesis-matching feature shows you automatically how
189 parentheses match in the text. Whenever a self-inserting character that
190 is a closing delimiter is typed, the cursor moves momentarily to the
191 location of the matching opening delimiter, provided that is visible on
192 the screen. If it is not on the screen, some text starting with that
193 opening delimiter is displayed in the echo area. Either way, you see
194 the grouping you are closing off.
196 In Lisp, automatic matching applies only to parentheses. In C, it
197 also applies to braces and brackets. Emacs knows which characters to
198 regard as matching delimiters based on the syntax table set by the major
199 mode. *Note Syntax::.
201 If the opening delimiter and closing delimiter are mismatched--as in
202 `[x)'--the echo area displays a warning message. The correct matches
203 are specified in the syntax table.
205 Two variables control parenthesis matching displays.
206 `blink-matching-paren' turns the feature on or off. The default is `t'
207 (match display is on); `nil' turns it off.
208 `blink-matching-paren-distance' specifies how many characters back
209 Emacs searches to find a matching opening delimiter. If the match is
210 not found in the specified region, scanning stops, and nothing is
211 displayed. This prevents wasting lots of time scanning when there is no
212 match. The default is 4000.
215 File: xemacs.info, Node: Comments, Next: Balanced Editing, Prev: Matching, Up: Programs
217 Manipulating Comments
218 =====================
220 The comment commands insert, kill and align comments.
223 Insert or align comment (`indent-for-comment').
226 Set comment column (`set-comment-column').
229 Kill comment on current line (`kill-comment').
232 Like <RET> followed by inserting and aligning a comment
233 (`indent-new-comment-line').
235 The command that creates a comment is `Meta-;'
236 (`indent-for-comment'). If there is no comment already on the line, a
237 new comment is created and aligned at a specific column called the
238 "comment column". Emacs creates the comment by inserting the string at
239 the value of `comment-start'; see below. Point is left after that
240 string. If the text of the line extends past the comment column,
241 indentation is done to a suitable boundary (usually, at least one space
242 is inserted). If the major mode has specified a string to terminate
243 comments, that string is inserted after point, to keep the syntax valid.
245 You can also use `Meta-;' to align an existing comment. If a line
246 already contains the string that starts comments, `M-;' just moves
247 point after it and re-indents it to the conventional place. Exception:
248 comments starting in column 0 are not moved.
250 Some major modes have special rules for indenting certain kinds of
251 comments in certain contexts. For example, in Lisp code, comments which
252 start with two semicolons are indented as if they were lines of code,
253 instead of at the comment column. Comments which start with three
254 semicolons are supposed to start at the left margin. Emacs understands
255 these conventions by indenting a double-semicolon comment using <TAB>
256 and by not changing the indentation of a triple-semicolon comment at
259 ;; This function is just an example.
260 ;;; Here either two or three semicolons are appropriate.
262 ;;; And now, the first part of the function:
263 ;; The following line adds one.
264 (1+ x)) ; This line adds one.
266 In C code, a comment preceded on its line by nothing but whitespace
267 is indented like a line of code.
269 Even when an existing comment is properly aligned, `M-;' is still
270 useful for moving directly to the start of the comment.
272 `C-u - C-x ;' (`kill-comment') kills the comment on the current
273 line, if there is one. The indentation before the start of the comment
274 is killed as well. If there does not appear to be a comment in the
275 line, nothing happens. To reinsert the comment on another line, move
276 to the end of that line, type first `C-y', and then `M-;' to realign
277 the comment. Note that `C-u - C-x ;' is not a distinct key; it is `C-x
278 ;' (`set-comment-column') with a negative argument. That command is
279 programmed to call `kill-comment' when called with a negative argument.
280 However, `kill-comment' is a valid command which you could bind
281 directly to a key if you wanted to.
283 Multiple Lines of Comments
284 --------------------------
286 If you are typing a comment and want to continue it on another line,
287 use the command `Meta-<LFD>' (`indent-new-comment-line'), which
288 terminates the comment you are typing, creates a new blank line
289 afterward, and begins a new comment indented under the old one. If
290 Auto Fill mode is on and you go past the fill column while typing, the
291 comment is continued in just this fashion. If point is not at the end
292 of the line when you type `M-<LFD>', the text on the rest of the line
293 becomes part of the new comment line.
295 Options Controlling Comments
296 ----------------------------
298 The comment column is stored in the variable `comment-column'. You
299 can explicitly set it to a number. Alternatively, the command `C-x ;'
300 (`set-comment-column') sets the comment column to the column point is
301 at. `C-u C-x ;' sets the comment column to match the last comment
302 before point in the buffer, and then calls `Meta-;' to align the
303 current line's comment under the previous one. Note that `C-u - C-x ;'
304 runs the function `kill-comment' as described above.
306 `comment-column' is a per-buffer variable; altering the variable
307 affects only the current buffer. You can also change the default value.
308 *Note Locals::. Many major modes initialize this variable for the
311 The comment commands recognize comments based on the regular
312 expression that is the value of the variable `comment-start-skip'.
313 This regexp should not match the null string. It may match more than
314 the comment starting delimiter in the strictest sense of the word; for
315 example, in C mode the value of the variable is `"/\\*+ *"', which
316 matches extra stars and spaces after the `/*' itself. (Note that `\\'
317 is needed in Lisp syntax to include a `\' in the string, which is needed
318 to deny the first star its special meaning in regexp syntax. *Note
321 When a comment command makes a new comment, it inserts the value of
322 `comment-start' to begin it. The value of `comment-end' is inserted
323 after point and will follow the text you will insert into the comment.
324 In C mode, `comment-start' has the value `"/* "' and `comment-end' has
327 `comment-multi-line' controls how `M-<LFD>'
328 (`indent-new-comment-line') behaves when used inside a comment. If
329 `comment-multi-line' is `nil', as it normally is, then `M-<LFD>'
330 terminates the comment on the starting line and starts a new comment on
331 the new following line. If `comment-multi-line' is not `nil', then
332 `M-<LFD>' sets up the new following line as part of the same comment
333 that was found on the starting line. This is done by not inserting a
334 terminator on the old line and not inserting a starter on the new line.
335 In languages where multi-line comments are legal, the value you choose
336 for this variable is a matter of taste.
338 The variable `comment-indent-hook' should contain a function that is
339 called to compute the indentation for a newly inserted comment or for
340 aligning an existing comment. Major modes set this variable
341 differently. The function is called with no arguments, but with point
342 at the beginning of the comment, or at the end of a line if a new
343 comment is to be inserted. The function should return the column in
344 which the comment ought to start. For example, in Lisp mode, the
345 indent hook function bases its decision on the number of semicolons
346 that begin an existing comment and on the code in the preceding lines.
349 File: xemacs.info, Node: Balanced Editing, Next: Lisp Completion, Prev: Comments, Up: Programs
351 Editing Without Unbalanced Parentheses
352 ======================================
355 Put parentheses around next sexp(s) (`insert-parentheses').
358 Move past next close parenthesis and re-indent
359 (`move-over-close-and-reindent').
361 The commands `M-(' (`insert-parentheses') and `M-)'
362 (`move-over-close-and-reindent') are designed to facilitate a style of
363 editing which keeps parentheses balanced at all times. `M-(' inserts a
364 pair of parentheses, either together as in `()', or, if given an
365 argument, around the next several sexps, and leaves point after the open
366 parenthesis. Instead of typing `( F O O )', you can type `M-( F O O',
367 which has the same effect except for leaving the cursor before the
368 close parenthesis. You can then type `M-)', which moves past the close
369 parenthesis, deletes any indentation preceding it (in this example
370 there is none), and indents with <LFD> after it.
373 File: xemacs.info, Node: Lisp Completion, Next: Documentation, Prev: Balanced Editing, Up: Programs
375 Completion for Lisp Symbols
376 ===========================
378 Completion usually happens in the minibuffer. An exception is
379 completion for Lisp symbol names, which is available in all buffers.
381 The command `M-<TAB>' (`lisp-complete-symbol') takes the partial
382 Lisp symbol before point to be an abbreviation, and compares it against
383 all non-trivial Lisp symbols currently known to Emacs. Any additional
384 characters that they all have in common are inserted at point.
385 Non-trivial symbols are those that have function definitions, values, or
388 If there is an open-parenthesis immediately before the beginning of
389 the partial symbol, only symbols with function definitions are
390 considered as completions.
392 If the partial name in the buffer has more than one possible
393 completion and they have no additional characters in common, a list of
394 all possible completions is displayed in another window.
397 File: xemacs.info, Node: Documentation, Next: Change Log, Prev: Lisp Completion, Up: Programs
399 Documentation Commands
400 ======================
402 As you edit Lisp code to be run in Emacs, you can use the commands
403 `C-h f' (`describe-function') and `C-h v' (`describe-variable') to
404 print documentation of functions and variables you want to call. These
405 commands use the minibuffer to read the name of a function or variable
406 to document, and display the documentation in a window.
408 For extra convenience, these commands provide default arguments
409 based on the code in the neighborhood of point. `C-h f' sets the
410 default to the function called in the innermost list containing point.
411 `C-h v' uses the symbol name around or adjacent to point as its default.
413 The `M-x manual-entry' command gives you access to documentation on
414 Unix commands, system calls, and libraries. The command reads a topic
415 as an argument, and displays the Unix manual page for that topic.
416 `manual-entry' always searches all 8 sections of the manual and
417 concatenates all the entries it finds. For example, the topic
418 `termcap' finds the description of the termcap library from section 3,
419 followed by the description of the termcap data base from section 5.
422 File: xemacs.info, Node: Change Log, Next: Tags, Prev: Documentation, Up: Programs
427 The Emacs command `M-x add-change-log-entry' helps you keep a record
428 of when and why you have changed a program. It assumes that you have a
429 file in which you write a chronological sequence of entries describing
430 individual changes. The default is to store the change entries in a
431 file called `ChangeLog' in the same directory as the file you are
432 editing. The same `ChangeLog' file therefore records changes for all
433 the files in a directory.
435 A change log entry starts with a header line that contains your name
436 and the current date. Except for these header lines, every line in the
437 change log starts with a tab. One entry can describe several changes;
438 each change starts with a line starting with a tab and a star. `M-x
439 add-change-log-entry' visits the change log file and creates a new entry
440 unless the most recent entry is for today's date and your name. In
441 either case, it adds a new line to start the description of another
442 change just after the header line of the entry. When `M-x
443 add-change-log-entry' is finished, all is prepared for you to edit in
444 the description of what you changed and how. You must then save the
445 change log file yourself.
447 The change log file is always visited in Indented Text mode, which
448 means that <LFD> and auto-filling indent each new line like the previous
449 line. This is convenient for entering the contents of an entry, which
450 must be indented. *Note Text Mode::.
452 Here is an example of the formatting conventions used in the change
455 Wed Jun 26 19:29:32 1985 Richard M. Stallman (rms at mit-prep)
457 * xdisp.c (try_window_id):
458 If C-k is done at end of next-to-last line,
459 this fn updates window_end_vpos and cannot leave
460 window_end_pos nonnegative (it is zero, in fact).
461 If display is preempted before lines are output,
462 this is inconsistent. Fix by setting
463 blank_end_of_window to nonzero.
465 Tue Jun 25 05:25:33 1985 Richard M. Stallman (rms at mit-prep)
468 Call the auto fill hook if appropriate.
470 * xdisp.c (try_window_id):
471 If point is found by compute_motion after xp, record that
472 permanently. If display_text_line sets point position wrong
473 (case where line is killed, point is at eob and that line is
474 not displayed), set it again in final compute_motion.
477 File: xemacs.info, Node: Tags, Next: Fortran, Prev: Change Log, Up: Programs
482 A "tags table" is a description of how a multi-file program is
483 broken up into files. It lists the names of the component files and the
484 names and positions of the functions (or other named subunits) in each
485 file. Grouping the related files makes it possible to search or replace
486 through all the files with one command. Recording the function names
487 and positions makes possible the `M-.' command which finds the
488 definition of a function by looking up which of the files it is in.
490 Tags tables are stored in files called "tags table files". The
491 conventional name for a tags table file is `TAGS'.
493 Each entry in the tags table records the name of one tag, the name
494 of the file that the tag is defined in (implicitly), and the position
495 in that file of the tag's definition.
497 Just what names from the described files are recorded in the tags
498 table depends on the programming language of the described file. They
499 normally include all functions and subroutines, and may also include
500 global variables, data types, and anything else convenient. Each name
501 recorded is called a "tag".
505 * Tag Syntax:: Tag syntax for various types of code and text files.
506 * Create Tags Table:: Creating a tags table with `etags'.
507 * Etags Regexps:: Create arbitrary tags using regular expressions.
508 * Select Tags Table:: How to visit a tags table.
509 * Find Tag:: Commands to find the definition of a specific tag.
510 * Tags Search:: Using a tags table for searching and replacing.
511 * List Tags:: Listing and finding tags defined in a file.
514 File: xemacs.info, Node: Tag Syntax, Next: Create Tags Table, Prev: Tags, Up: Tags
516 Source File Tag Syntax
517 ----------------------
519 Here is how tag syntax is defined for the most popular languages:
521 * In C code, any C function or typedef is a tag, and so are
522 definitions of `struct', `union' and `enum'. You can tag function
523 declarations and external variables in addition to function
524 definitions by giving the `--declarations' option to `etags'.
525 `#define' macro definitions and `enum' constants are also tags,
526 unless you specify `--no-defines' when making the tags table.
527 Similarly, global variables are tags, unless you specify
528 `--no-globals'. Use of `--no-globals' and `--no-defines' can make
529 the tags table file much smaller.
531 * In C++ code, in addition to all the tag constructs of C code,
532 member functions are also recognized, and optionally member
533 variables if you use the `--members' option. Tags for variables
534 and functions in classes are named `CLASS::VARIABLE' and
535 `CLASS::FUNCTION'. `operator' functions tags are named, for
538 * In Java code, tags include all the constructs recognized in C++,
539 plus the `interface', `extends' and `implements' constructs. Tags
540 for variables and functions in classes are named `CLASS.VARIABLE'
541 and `CLASS.FUNCTION'.
543 * In LaTeX text, the argument of any of the commands `\chapter',
544 `\section', `\subsection', `\subsubsection', `\eqno', `\label',
545 `\ref', `\cite', `\bibitem', `\part', `\appendix', `\entry', or
548 Other commands can make tags as well, if you specify them in the
549 environment variable `TEXTAGS' before invoking `etags'. The value
550 of this environment variable should be a colon-separated list of
551 command names. For example,
553 TEXTAGS="def:newcommand:newenvironment"
556 specifies (using Bourne shell syntax) that the commands `\def',
557 `\newcommand' and `\newenvironment' also define tags.
559 * In Lisp code, any function defined with `defun', any variable
560 defined with `defvar' or `defconst', and in general the first
561 argument of any expression that starts with `(def' in column zero,
564 * In Scheme code, tags include anything defined with `def' or with a
565 construct whose name starts with `def'. They also include
566 variables set with `set!' at top level in the file.
568 Several other languages are also supported:
570 * In Ada code, functions, procedures, packages, tasks, and types are
571 tags. Use the `--packages-only' option to create tags for packages
574 * In assembler code, labels appearing at the beginning of a line,
575 followed by a colon, are tags.
577 * In Bison or Yacc input files, each rule defines as a tag the
578 nonterminal it constructs. The portions of the file that contain
579 C code are parsed as C code.
581 * In Cobol code, tags are paragraph names; that is, any word
582 starting in column 8 and followed by a period.
584 * In Erlang code, the tags are the functions, records, and macros
587 * In Fortran code, functions, subroutines and blockdata are tags.
589 * In Objective C code, tags include Objective C definitions for
590 classes, class categories, methods, and protocols.
592 * In Pascal code, the tags are the functions and procedures defined
595 * In Perl code, the tags are the procedures defined by the `sub',
596 `my' and `local' keywords. Use `--globals' if you want to tag
599 * In Postscript code, the tags are the functions.
601 * In Prolog code, a tag name appears at the left margin.
603 * In Python code, `def' or `class' at the beginning of a line
606 You can also generate tags based on regexp matching (*note Etags
607 Regexps::) to handle other formats and languages.
610 File: xemacs.info, Node: Create Tags Table, Next: Etags Regexps, Prev: Tag Syntax, Up: Tags
615 The `etags' program is used to create a tags table file. It knows
616 the syntax of several languages, as described in *Note Tag Syntax::.
617 Here is how to run `etags':
621 The `etags' program reads the specified files, and writes a tags table
622 named `TAGS' in the current working directory. You can intermix
623 compressed and plain text source file names. `etags' knows about the
624 most common compression formats, and does the right thing. So you can
625 compress all your source files and have `etags' look for compressed
626 versions of its file name arguments, if it does not find uncompressed
627 versions. Under MS-DOS, `etags' also looks for file names like
628 `mycode.cgz' if it is given `mycode.c' on the command line and
629 `mycode.c' does not exist.
631 `etags' recognizes the language used in an input file based on its
632 file name and contents. You can specify the language with the
633 `--language=NAME' option, described below.
635 If the tags table data become outdated due to changes in the files
636 described in the table, the way to update the tags table is the same
637 way it was made in the first place. It is not necessary to do this
640 If the tags table fails to record a tag, or records it for the wrong
641 file, then Emacs cannot possibly find its definition. However, if the
642 position recorded in the tags table becomes a little bit wrong (due to
643 some editing in the file that the tag definition is in), the only
644 consequence is a slight delay in finding the tag. Even if the stored
645 position is very wrong, Emacs will still find the tag, but it must
646 search the entire file for it.
648 So you should update a tags table when you define new tags that you
649 want to have listed, or when you move tag definitions from one file to
650 another, or when changes become substantial. Normally there is no need
651 to update the tags table after each edit, or even every day.
653 One tags table can effectively include another. Specify the included
654 tags file name with the `--include=FILE' option when creating the file
655 that is to include it. The latter file then acts as if it contained
656 all the files specified in the included file, as well as the files it
659 If you specify the source files with relative file names when you run
660 `etags', the tags file will contain file names relative to the
661 directory where the tags file was initially written. This way, you can
662 move an entire directory tree containing both the tags file and the
663 source files, and the tags file will still refer correctly to the source
666 If you specify absolute file names as arguments to `etags', then the
667 tags file will contain absolute file names. This way, the tags file
668 will still refer to the same files even if you move it, as long as the
669 source files remain in the same place. Absolute file names start with
670 `/', or with `DEVICE:/' on MS-DOS and MS-Windows.
672 When you want to make a tags table from a great number of files, you
673 may have problems listing them on the command line, because some systems
674 have a limit on its length. The simplest way to circumvent this limit
675 is to tell `etags' to read the file names from its standard input, by
676 typing a dash in place of the file names, like this:
678 find . -name "*.[chCH]" -print | etags -
680 Use the option `--language=NAME' to specify the language explicitly.
681 You can intermix these options with file names; each one applies to
682 the file names that follow it. Specify `--language=auto' to tell
683 `etags' to resume guessing the language from the file names and file
684 contents. Specify `--language=none' to turn off language-specific
685 processing entirely; then `etags' recognizes tags by regexp matching
686 alone (*note Etags Regexps::).
688 `etags --help' prints the list of the languages `etags' knows, and
689 the file name rules for guessing the language. It also prints a list of
690 all the available `etags' options, together with a short explanation.
693 File: xemacs.info, Node: Etags Regexps, Next: Select Tags Table, Prev: Create Tags Table, Up: Tags
698 The `--regex' option provides a general way of recognizing tags
699 based on regexp matching. You can freely intermix it with file names.
700 Each `--regex' option adds to the preceding ones, and applies only to
701 the following files. The syntax is:
703 --regex=/TAGREGEXP[/NAMEREGEXP]/
705 where TAGREGEXP is used to match the lines to tag. It is always
706 anchored, that is, it behaves as if preceded by `^'. If you want to
707 account for indentation, just match any initial number of blanks by
708 beginning your regular expression with `[ \t]*'. In the regular
709 expressions, `\' quotes the next character, and `\t' stands for the tab
710 character. Note that `etags' does not handle the other C escape
711 sequences for special characters.
713 The syntax of regular expressions in `etags' is the same as in
714 Emacs, augmented with the "interval operator", which works as in `grep'
715 and `ed'. The syntax of an interval operator is `\{M,N\}', and its
716 meaning is to match the preceding expression at least M times and up to
719 You should not match more characters with TAGREGEXP than that needed
720 to recognize what you want to tag. If the match is such that more
721 characters than needed are unavoidably matched by TAGREGEXP (as will
722 usually be the case), you should add a NAMEREGEXP, to pick out just the
723 tag. This will enable Emacs to find tags more accurately and to do
724 completion on tag names more reliably. You can find some examples
727 The option `--ignore-case-regex' (or `-c') is like `--regex', except
728 that the regular expression provided will be matched without regard to
729 case, which is appropriate for various programming languages.
731 The `-R' option deletes all the regexps defined with `--regex'
732 options. It applies to the file names following it, as you can see
733 from the following example:
735 etags --regex=/REG1/ voo.doo --regex=/REG2/ \
736 bar.ber -R --lang=lisp los.er
738 Here `etags' chooses the parsing language for `voo.doo' and `bar.ber'
739 according to their contents. `etags' also uses REG1 to recognize
740 additional tags in `voo.doo', and both REG1 and REG2 to recognize
741 additional tags in `bar.ber'. `etags' uses the Lisp tags rules, and no
742 regexp matching, to recognize tags in `los.er'.
744 A regular expression can be bound to a given language, by prepending
745 it with `{lang}'. When you do this, `etags' will use the regular
746 expression only for files of that language. `etags --help' prints the
747 list of languages recognised by `etags'. The following example tags
748 the `DEFVAR' macros in the Emacs source files. `etags' applies this
749 regular expression to C files only:
751 --regex='{c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
753 This feature is particularly useful when storing a list of regular
754 expressions in a file. The following option syntax instructs `etags'
755 to read two files of regular expressions. The regular expressions
756 contained in the second file are matched without regard to case.
758 --regex=@first-file --ignore-case-regex=@second-file
760 A regex file contains one regular expressions per line. Empty lines,
761 and lines beginning with space or tab are ignored. When the first
762 character in a line is `@', `etags' assumes that the rest of the line
763 is the name of a file of regular expressions. This means that such
764 files can be nested. All the other lines are taken to be regular
765 expressions. For example, one can create a file called `emacs.tags'
766 with the following contents (the first line in the file is a comment):
768 -- This is for GNU Emacs source files
769 {c}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/
771 and then use it like this:
773 etags --regex=@emacs.tags *.[ch] */*.[ch]
775 Here are some more examples. The regexps are quoted to protect them
776 from shell interpretation.
780 etags --language=none \
781 --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \
782 --regex='/###key \(.*\)/\1/' \
783 --regex='/[ \t]*global[ \t].*/' \
786 Note that tags are not generated for scripts so that you have to
787 add a line by yourself of the form `###key <script-name>' if you
792 etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl
797 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \
798 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
799 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
802 File: xemacs.info, Node: Select Tags Table, Next: Find Tag, Prev: Etags Regexps, Up: Tags
804 Selecting a Tags Table
805 ----------------------
807 At any time Emacs has one "selected" tags table, and all the commands
808 for working with tags tables use the selected one. To select a tags
809 table, use the variable `tag-table-alist'.
811 The value of `tag-table-alist' is a list that determines which
812 `TAGS' files should be active for a given buffer. This is not really
813 an association list, in that all elements are checked. The car of each
814 element of this list is a pattern against which the buffers file name
815 is compared; if it matches, then the cdr of the list should be the name
816 of the tags table to use. If more than one element of this list
817 matches the buffers file name, all of the associated tags tables are
818 used. Earlier ones are searched first.
820 If the car of elements of this list are strings, they are treated as
821 regular-expressions against which the file is compared (like the
822 `auto-mode-alist'). If they are not strings, they are evaluated. If
823 they evaluate to non-`nil', the current buffer is considered to match.
825 If the cdr of the elements of this list are strings, they are
826 assumed to name a tags file. If they name a directory, the string
827 `tags' is appended to them to get the file name. If they are not
828 strings, they are evaluated and must return an appropriate string.
832 (setq tag-table-alist
833 '(("/usr/src/public/perl/" . "/usr/src/public/perl/perl-3.0/")
834 ("\\.el$" . "/usr/local/emacs/src/")
835 ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
836 ("" . "/usr/local/emacs/src/")
839 The example defines the tags table alist in the following way:
841 * Anything in the directory `/usr/src/public/perl/' should use the
842 `TAGS' file `/usr/src/public/perl/perl-3.0/TAGS'.
844 * Files ending in `.el' should use the `TAGS' file
845 `/usr/local/emacs/src/TAGS'.
847 * Anything in or below the directory `/jbw/gnu/' should use the
848 `TAGS' file `/usr15/degree/stud/jbw/gnu/TAGS'.
850 If you had a file called `/usr/jbw/foo.el', it would use both `TAGS'
852 `/usr/local/emacs/src/TAGS' and `/usr15/degree/stud/jbw/gnu/TAGS' (in
853 that order), because it matches both patterns.
855 If the buffer-local variable `buffer-tag-table' is set, it names a
856 tags table that is searched before all others when `find-tag' is
857 executed from this buffer.
859 If there is a file called `TAGS' in the same directory as the file
860 in question, then that tags file will always be used as well (after the
861 `buffer-tag-table' but before the tables specified by this list).
863 If the variable `tags-file-name' is set, the `TAGS' file it names
864 will apply to all buffers (for backwards compatibility.) It is searched
867 If the value of the variable `tags-always-build-completion-table' is
868 `t', the tags file will always be added to the completion table without
869 asking first, regardless of the size of the tags file.
871 The function `M-x visit-tags-table', is largely made obsolete by the
872 variable `tag-table-alist', tells tags commands to use the tags table
873 file FILE first. The FILE should be the name of a file created with
874 the `etags' program. A directory name is also acceptable; it means the
875 file `TAGS' in that directory. The function only stores the file name
876 you provide in the variable `tags-file-name'. Emacs does not actually
877 read in the tags table contents until you try to use them. You can set
878 the variable explicitly instead of using `visit-tags-table'. The value
879 of the variable `tags-file-name' is the name of the tags table used by
880 all buffers. This is for backward compatibility, and is largely
881 supplanted by the variable `tag-table-alist'.
884 File: xemacs.info, Node: Find Tag, Next: Tags Search, Prev: Select Tags Table, Up: Tags
889 The most important thing that a tags table enables you to do is to
890 find the definition of a specific tag.
892 `M-. TAG &OPTIONAL OTHER-WINDOW'
893 Find first definition of TAG (`find-tag').
896 Find next alternate definition of last tag specified.
899 Find first definition of TAG, but display it in another window
900 (`find-tag-other-window').
902 `M-.' (`find-tag') is the command to find the definition of a
903 specified tag. It searches through the tags table for that tag, as a
904 string, then uses the tags table information to determine the file in
905 which the definition is used and the approximate character position of
906 the definition in the file. Then `find-tag' visits the file, moves
907 point to the approximate character position, and starts searching
908 ever-increasing distances away for the text that should appear at the
909 beginning of the definition.
911 If an empty argument is given (by typing <RET>), the sexp in the
912 buffer before or around point is used as the name of the tag to find.
913 *Note Lists::, for information on sexps.
915 The argument to `find-tag' need not be the whole tag name; it can be
916 a substring of a tag name. However, there can be many tag names
917 containing the substring you specify. Since `find-tag' works by
918 searching the text of the tags table, it finds the first tag in the
919 table that the specified substring appears in. To find other tags that
920 match the substring, give `find-tag' a numeric argument, as in `C-u
921 M-.'. This does not read a tag name, but continues searching the tag
922 table's text for another tag containing the same substring last used.
923 If your keyboard has a real <META> key, `M-0 M-.' is an easier
924 alternative to `C-u M-.'.
926 If the optional second argument OTHER-WINDOW is non-`nil', it uses
927 another window to display the tag. Multiple active tags tables and
928 completion are supported.
930 Variables of note include the following:
933 Controls which tables apply to which buffers.
936 Stores a default tags table.
938 `tags-build-completion-table'
939 Controls completion behavior.
942 Specifies a buffer-local table.
944 `make-tags-files-invisible'
945 Sets whether tags tables should be very hidden.
948 Specifies how many tags-based hops to remember.
950 Like most commands that can switch buffers, `find-tag' has another
951 similar command that displays the new buffer in another window. `C-x 4
952 .' invokes the function `find-tag-other-window'. (This key sequence
955 Emacs comes with a tags table file `TAGS' (in the directory
956 containing Lisp libraries) that includes all the Lisp libraries and all
957 the C sources of Emacs. By specifying this file with `visit-tags-table'
958 and then using `M-.' you can quickly look at the source of any Emacs
962 File: xemacs.info, Node: Tags Search, Next: List Tags, Prev: Find Tag, Up: Tags
964 Searching and Replacing with Tags Tables
965 ----------------------------------------
967 The commands in this section visit and search all the files listed
968 in the selected tags table, one by one. For these commands, the tags
969 table serves only to specify a sequence of files to search. A related
970 command is `M-x grep' (*note Compilation::).
972 `M-x tags-search <RET> REGEXP <RET>'
973 Search for REGEXP through the files in the selected tags table.
975 `M-x tags-query-replace <RET> REGEXP <RET> REPLACEMENT <RET>'
976 Perform a `query-replace-regexp' on each file in the selected tags
980 Restart one of the commands above, from the current location of
981 point (`tags-loop-continue').
983 `M-x tags-search' reads a regexp using the minibuffer, then searches
984 for matches in all the files in the selected tags table, one file at a
985 time. It displays the name of the file being searched so you can
986 follow its progress. As soon as it finds an occurrence, `tags-search'
989 Having found one match, you probably want to find all the rest. To
990 find one more match, type `M-,' (`tags-loop-continue') to resume the
991 `tags-search'. This searches the rest of the current buffer, followed
992 by the remaining files of the tags table.
994 `M-x tags-query-replace' performs a single `query-replace-regexp'
995 through all the files in the tags table. It reads a regexp to search
996 for and a string to replace with, just like ordinary `M-x
997 query-replace-regexp'. It searches much like `M-x tags-search', but
998 repeatedly, processing matches according to your input. *Note
999 Replace::, for more information on query replace.
1001 It is possible to get through all the files in the tags table with a
1002 single invocation of `M-x tags-query-replace'. But often it is useful
1003 to exit temporarily, which you can do with any input event that has no
1004 special query replace meaning. You can resume the query replace
1005 subsequently by typing `M-,'; this command resumes the last tags search
1006 or replace command that you did.
1008 The commands in this section carry out much broader searches than the
1009 `find-tag' family. The `find-tag' commands search only for definitions
1010 of tags that match your substring or regexp. The commands
1011 `tags-search' and `tags-query-replace' find every occurrence of the
1012 regexp, as ordinary search commands and replace commands do in the
1015 These commands create buffers only temporarily for the files that
1016 they have to search (those which are not already visited in Emacs
1017 buffers). Buffers in which no match is found are quickly killed; the
1018 others continue to exist.
1020 It may have struck you that `tags-search' is a lot like `grep'. You
1021 can also run `grep' itself as an inferior of Emacs and have Emacs show
1022 you the matching lines one by one. This works much like running a
1023 compilation; finding the source locations of the `grep' matches works
1024 like finding the compilation errors. *Note Compilation::.
1026 If you wish to process all the files in a selected tags table, but
1027 `M-x tags-search' and `M-x tags-query-replace' are not giving you the
1028 desired result, you can use `M-x next-file'.
1031 With a numeric argument, regardless of its value, visit the first
1032 file in the tags table and prepare to advance sequentially by
1036 Visit the next file in the selected tags table.
1039 File: xemacs.info, Node: List Tags, Prev: Tags Search, Up: Tags
1041 Tags Table Inquiries
1042 --------------------
1045 Display a list of the tags defined in a specific program file.
1048 Display a list of all tags matching a specified regexp.
1050 `M-x list-tags' reads the name of one of the files described by the
1051 selected tags table, and displays a list of all the tags defined in that
1052 file. The "file name" argument is really just a string to compare
1053 against the names recorded in the tags table; it is read as a string
1054 rather than a file name. Therefore, completion and defaulting are not
1055 available, and you must enter the string the same way it appears in the
1056 tag table. Do not include a directory as part of the file name unless
1057 the file name recorded in the tags table contains that directory.
1059 `M-x tags-apropos' is like `apropos' for tags. It reads a regexp,
1060 then finds all the tags in the selected tags table whose entries match
1061 that regexp, and displays the tag names found.
1064 File: xemacs.info, Node: Fortran, Next: Asm Mode, Prev: Tags, Up: Programs
1069 Fortran mode provides special motion commands for Fortran statements
1070 and subprograms, and indentation commands that understand Fortran
1071 conventions of nesting, line numbers, and continuation statements.
1073 Special commands for comments are provided because Fortran comments
1074 are unlike those of other languages.
1076 Built-in abbrevs optionally save typing when you insert Fortran
1079 Use `M-x fortran-mode' to switch to this major mode. Doing so calls
1080 the value of `fortran-mode-hook' as a function of no arguments if that
1081 variable has a non-`nil' value.
1085 * Motion: Fortran Motion. Moving point by statements or subprograms.
1086 * Indent: Fortran Indent. Indentation commands for Fortran.
1087 * Comments: Fortran Comments. Inserting and aligning comments.
1088 * Columns: Fortran Columns. Measuring columns for valid Fortran.
1089 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
1091 Fortran mode was contributed by Michael Prange.
1094 File: xemacs.info, Node: Fortran Motion, Next: Fortran Indent, Prev: Fortran, Up: Fortran
1099 Fortran mode provides special commands to move by subprograms
1100 (functions and subroutines) and by statements. There is also a command
1101 to put the region around one subprogram, which is convenient for
1102 killing it or moving it.
1105 Move to beginning of subprogram
1106 (`beginning-of-fortran-subprogram').
1109 Move to end of subprogram (`end-of-fortran-subprogram').
1112 Put point at beginning of subprogram and mark at end
1113 (`mark-fortran-subprogram').
1116 Move to beginning of current or next statement (`fortran-next-
1120 Move to beginning of current or previous statement (`fortran-
1121 previous-statement').
1124 File: xemacs.info, Node: Fortran Indent, Next: Fortran Comments, Prev: Fortran Motion, Up: Fortran
1129 Special commands and features are available for indenting Fortran
1130 code. They make sure various syntactic entities (line numbers, comment
1131 line indicators, and continuation line flags) appear in the columns
1132 that are required for standard Fortran.
1136 * Commands: ForIndent Commands. Commands for indenting Fortran.
1137 * Numbers: ForIndent Num. How line numbers auto-indent.
1138 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
1139 * Vars: ForIndent Vars. Variables controlling Fortran indent style.
1142 File: xemacs.info, Node: ForIndent Commands, Next: ForIndent Num, Prev: Fortran Indent, Up: Fortran Indent
1144 Fortran Indentation Commands
1145 ............................
1148 Indent the current line (`fortran-indent-line').
1151 Break the current line and set up a continuation line.
1154 Indent all the lines of the subprogram point is in
1155 (`fortran-indent-subprogram').
1157 <TAB> is redefined by Fortran mode to reindent the current line for
1158 Fortran (`fortran-indent-line'). Line numbers and continuation markers
1159 are indented to their required columns, and the body of the statement
1160 is independently indented, based on its nesting in the program.
1162 The key `C-M-q' is redefined as `fortran-indent-subprogram', a
1163 command that reindents all the lines of the Fortran subprogram
1164 (function or subroutine) containing point.
1166 The key `M-<LFD>' is redefined as `fortran-split-line', a command to
1167 split a line in the appropriate fashion for Fortran. In a non-comment
1168 line, the second half becomes a continuation line and is indented
1169 accordingly. In a comment line, both halves become separate comment
1173 File: xemacs.info, Node: ForIndent Num, Next: ForIndent Conv, Prev: ForIndent Commands, Up: Fortran Indent
1175 Line Numbers and Continuation
1176 .............................
1178 If a number is the first non-whitespace in the line, it is assumed
1179 to be a line number and is moved to columns 0 through 4. (Columns are
1180 always counted from 0 in XEmacs.) If the text on the line starts with
1181 the conventional Fortran continuation marker `$', it is moved to column
1182 5. If the text begins with any non whitespace character in column 5,
1183 it is assumed to be an unconventional continuation marker and remains
1186 Line numbers of four digits or less are normally indented one space.
1187 This amount is controlled by the variable `fortran-line-number-indent',
1188 which is the maximum indentation a line number can have. Line numbers
1189 are indented to right-justify them to end in column 4 unless that would
1190 require more than the maximum indentation. The default value of the
1193 Simply inserting a line number is enough to indent it according to
1194 these rules. As each digit is inserted, the indentation is recomputed.
1195 To turn off this feature, set the variable
1196 `fortran-electric-line-number' to `nil'. Then inserting line numbers
1197 is like inserting anything else.