]> code.delx.au - gnu-emacs/blobdiff - man/programs.texi
(Tags Search): Add index entries for multiple-file search and replace.
[gnu-emacs] / man / programs.texi
index 3fa4e0c29a91c6b59c2b61a0fb000175c52b5586..8ee22358f997bef5ba9812790f03ba37e78161af 100644 (file)
@@ -45,13 +45,11 @@ on.
 structure of a function (@pxref{Selective Display}).  This feature
 causes only the lines that are indented less than a specified amount to
 appear on the screen.  Programming modes often support Outline minor
-mode (@pxref{Outline Mode}).  The Foldout package (@pxref{Foldout}) can
-provide convenient folding-editor features on top of the minor mode.
-The Hideshow package (@pxref{Hideshow}) can also be used to display
-bocks of code selectively.
+mode (@pxref{Outline Mode}).  The Foldout package provides
+folding-editor features (@pxref{Foldout}).
 
   The `automatic typing' features may be useful when writing programs.
-@xref{Top, Autotyping, autotype, Features for Automatic Typing}.
+@xref{,Autotyping,, autotype, Autotyping}.
 
 @menu
 * Program Modes::       Major modes for editing programs.
@@ -66,8 +64,10 @@ bocks of code selectively.
 * Symbol Completion::   Completion on symbol names of your program or language.
 * Which Function::      Which Function mode shows which function you are in.
 * Hideshow::            Displaying blocks selectively.
+* Glasses::             Making identifiersLikeThis more readable.
 * Documentation::       Getting documentation of functions you plan to call.
 * Change Log::         Maintaining a change history for your program.
+* Authors::             Maintaining an @file{AUTHORS} file.
 * Tags::               Go direct to any function in your program in one
                          command.  Tags remembers which file it is in.
 * Imenu::               Making buffer indexes as menus.
@@ -97,22 +97,26 @@ bocks of code selectively.
 @cindex VHDL mode
 @cindex M4 mode
 @cindex Shell-script mode
+@cindex Delphi mode
+@cindex PostScript mode
   Emacs also has major modes for the programming languages Lisp, Scheme
 (a variant of Lisp) and the Scheme-based DSSSL expression language, Ada,
-Awk, C, C++, Fortran (free and fixed format), Icon, IDLWAVE,
+Awk, C, C++, Delphi (Object Pascal), Fortran (free and fixed format),
+Icon, IDLWAVE,
 Java, Metafont (@TeX{}'s companion for font creation), Modula2,
-Objective-C, Octave, Pascal, Perl, Pike, Prolog, Simula, VHDL, CORBA
-IDL, and Tcl.  There is also a major mode for makefiles, called Makefile
+Objective-C, Octave, Pascal, Perl, Pike, PostScript, Prolog, Simula,
+VHDL, CORBA IDL, and Tcl.
+There is also a major mode for makefiles, called Makefile
 mode.  An alternative mode for Perl is called CPerl mode.  Modes
 are available for scripts for the common Unix shells, VMS DCL and
 MS-DOS/MS-Windows `BAT' files.  In a similar fashion to programming
 languages, modes are provided for editing various sorts of configuration
 files.
 
-Separate manuals are available for th modes for Ada (@pxref{Top, , Ada Mode,
-ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL (@pxref{Top, , CC Mode,
-ccmode, CC Mode}) and the IDLWAVE modes (@pxref{Top, , IDLWAVE,
-idlwave, IDLWAVE User Manual}).
+Separate manuals are available for the modes for Ada (@pxref{Top, , Ada
+Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL
+(@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes
+(@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}).
 
   Ideally, a major mode should be implemented for each programming
 language that you might want to edit with Emacs; but often the mode for
@@ -172,8 +176,6 @@ parentheses exist (including human languages).
 @cindex list
 @cindex sexp
 @cindex expression
-@cindex parentheses, moving across
-@cindex matching parenthesis, moving to
   These commands fall into two classes.  Some deal only with @dfn{lists}
 (parenthetical groupings).  They see nothing except parentheses, brackets,
 braces (whichever ones must balance in the language you are working with),
@@ -228,6 +230,9 @@ Transpose expressions (@code{transpose-sexps}).
 Put mark after following expression (@code{mark-sexp}).
 @end table
 
+@cindex parentheses, moving across
+@cindex matching parenthesis and braces, moving to
+@cindex braces, moving across
 @kindex C-M-f
 @kindex C-M-b
 @findex forward-sexp
@@ -249,6 +254,7 @@ were whitespace in most modes.
 specified number of times; with a negative argument, it moves in the
 opposite direction.
 
+@cindex deleting parenthesized expressions
 @kindex C-M-k
 @findex kill-sexp
 @kindex C-M-DEL
@@ -286,7 +292,7 @@ up one or more levels.@refill
 delimiter, this is nearly the same as searching for a @samp{(}.  An
 argument specifies the number of levels of parentheses to go down.
 
-@cindex transposition
+@cindex transposition of parenthesized expressions
 @kindex C-M-t
 @findex transpose-sexps
   A somewhat random-sounding command which is nevertheless handy is
@@ -332,6 +338,8 @@ Move to end of current or following defun (@code{end-of-defun}).
 Put region around whole current or following defun (@code{mark-defun}).
 @end table
 
+@cindex move to beginning or end of function
+@cindex function, move to beginning or end
 @kindex C-M-a
 @kindex C-M-e
 @kindex C-M-h
@@ -1124,11 +1132,9 @@ style for the other C-like modes.
 
   The style @code{gnu} defines the formatting recommend by the GNU
 Project; it is the default, so as to encourage the indentation we
-recommend.  The style @code{user} is the same as @code{gnu} but
-incorporates any changes made in variables such as @code{c-basic-offset}
-and @code{c-offsets-alist} by your @file{~/.emacs} file.  To make them
-take effect, you should select the style @code{user} with
-@code{c-set-style} or @code{c-default-style}.
+recommend. If you make changes in variables such as
+@code{c-basic-offset} and @code{c-offsets-alist} in your @file{~/.emacs}
+file, they will however take precedence.
 
 @findex c-add-style
   To define a new C indentation style, call the function
@@ -1184,17 +1190,24 @@ displayed.  This is to prevent scanning for the matching delimiter from
 wasting lots of time when there is no match.  The default is 12,000.
 
 @cindex Show Paren mode
+@cindex highlighting matching parentheses
 @findex show-paren-mode
-  When using X Windows, you can request a more powerful alternative kind
-of automatic parenthesis matching by enabling Show Paren mode.  This
-mode turns off the usual kind of matching parenthesis display and
-instead uses highlighting to show what matches.  Whenever point is after
-a close parenthesis, the close parenthesis and its matching open
-parenthesis are both highlighted; otherwise, if point is before an open
-parenthesis, the matching close parenthesis is highlighted.  (There is
-no need to highlight the open parenthesis after point because the cursor
-appears on top of that character.)  Use the command @kbd{M-x
-show-paren-mode} to enable or disable this mode.
+  You can also request a more powerful alternative kind of automatic
+parenthesis matching by enabling Show Paren mode.  This mode turns off
+the usual kind of matching parenthesis display and instead uses
+highlighting to show what matches.  Whenever point is after a close
+parenthesis, the close parenthesis and its matching open parenthesis are
+both highlighted; otherwise, if point is before an open parenthesis, the
+matching close parenthesis is highlighted.  (There is no need to
+highlight the open parenthesis after point because the cursor appears on
+top of that character.)  Use the command @kbd{M-x show-paren-mode} to
+enable or disable this mode.
+
+  By default, @code{show-paren-mode} uses colors to highlight the
+parentheses.  However, if your display doesn't support colors, you can
+customize the faces @code{show-paren-match-face} and
+@code{show-paren-mismatch-face} to use other attributes, such as bold or
+underline.  @xref{Face Customization}.
 
 @node Comments
 @section Manipulating Comments
@@ -1215,17 +1228,21 @@ provides special commands for editing and inserting comments.
 @kindex M-;
 @cindex indentation for comments
 @findex indent-for-comment
+@findex comment-dwim
 
   The comment commands insert, kill and align comments.
 
 @c WideCommands
 @table @kbd
 @item M-;
-Insert or align comment (@code{indent-for-comment}).
+Call the comment command that is appropriate for the context
+(@code{comment-dwim}).
+@item M-x indent-for-comment
+Insert or align comment.
 @item C-x ;
 Set comment column (@code{set-comment-column}).
 @item C-u - C-x ;
-Kill comment on current line (@code{kill-comment}).
+Kill comment on current line (@code{comment-kill}).
 @item C-M-j
 Like @key{RET} followed by inserting and aligning a comment
 (@code{indent-new-comment-line}).
@@ -1233,7 +1250,7 @@ Like @key{RET} followed by inserting and aligning a comment
 Add or remove comment delimiters on all the lines in the region.
 @end table
 
-  The command that creates a comment is @kbd{M-;} (@code{indent-for-comment}).
+  The command that creates a comment is @kbd{M-x indent-for-comment}.
 If there is no comment already on the line, a new comment is created,
 aligned at a specific column called the @dfn{comment column}.  The comment
 is created by inserting the string Emacs thinks comments should start with
@@ -1243,10 +1260,24 @@ indentation is done to a suitable boundary (usually, at least one space is
 inserted).  If the major mode has specified a string to terminate comments,
 that is inserted after point, to keep the syntax valid.
 
-  @kbd{M-;} can also be used to align an existing comment.  If a line
-already contains the string that starts comments, then @kbd{M-;} just moves
-point after it and reindents it to the conventional place.  Exception:
-comments starting in column 0 are not moved.
+  @kbd{M-x indent-for-comment} can also be used to align an existing
+comment.  If a line already contains the string that starts comments,
+then @kbd{M-x indent-for-comment} just moves point after it and
+reindents it to the conventional place.  Exception: comments starting in
+column 0 are not moved.
+
+  @kbd{M-;} (@code{comment-dwim}) conveniently combines
+@code{indent-for-comment} with @code{comment-region} and
+@code{uncomment-region}, described below in @ref{Multi-Line Comments},
+as appropriate for the current context.  If the region is active and the
+Transient Mark mode is on (@pxref{Transient Mark}), @kbd{M-;} invokes
+@code{comment-region}, unless the region consists only of comments, in
+which case it invokes @code{uncomment-region}.  Otherwise, if the
+current line is empty, @kbd{M-;} inserts a comment and indents it.  If
+the current line is not empty, @kbd{M-;} invokes @code{comment-kill} if
+a numeric argument was given, else it reindents the comment on the
+current line.  (The @dfn{dwim} in @code{comment-dwim} is an acronym for
+``Do What I Mean''.)
 
   Some major modes have special rules for indenting certain kinds of
 comments in certain contexts.  For example, in Lisp code, comments which
@@ -1273,16 +1304,18 @@ useful for moving directly to the start of the comment.
 
 @kindex C-u - C-x ;
 @findex kill-comment
-  @kbd{C-u - C-x ;} (@code{kill-comment}) kills the comment on the current line,
+@findex comment-kill
+  @kbd{C-u - C-x ;} (@code{comment-kill}) kills the comment on the current line,
 if there is one.  The indentation before the start of the comment is killed
 as well.  If there does not appear to be a comment in the line, nothing is
 done.  To reinsert the comment on another line, move to the end of that
 line, do @kbd{C-y}, and then do @kbd{M-;} to realign it.  Note that
 @kbd{C-u - C-x ;} is not a distinct key; it is @kbd{C-x ;} (@code{set-comment-column})
 with a negative argument.  That command is programmed so that when it
-receives a negative argument it calls @code{kill-comment}.  However,
-@code{kill-comment} is a valid command which you could bind directly to a
-key if you wanted to.
+receives a negative argument it calls @code{comment-kill}.  However,
+@code{comment-kill} is a valid command which you could bind directly to a
+key if you wanted to.  (For compatibility with previous versions,
+@code{kill-comment} is provided as an alias to @code{comment-kill}.)
 
 @node Multi-Line Comments
 @subsection Multiple Lines of Comments
@@ -1332,7 +1365,7 @@ can set it to a number explicitly.  Alternatively, the command @kbd{C-x ;}
 at.  @kbd{C-u C-x ;} sets the comment column to match the last comment
 before point in the buffer, and then does a @kbd{M-;} to align the
 current line's comment under the previous one.  Note that @kbd{C-u - C-x ;}
-runs the function @code{kill-comment} as described above.
+runs the function @code{comment-kill} as described above.
 
   The variable @code{comment-column} is per-buffer: setting the variable
 in the normal fashion affects only the current buffer, but there is a
@@ -1417,8 +1450,9 @@ the syntax class of the preceding character.  Set
 this.
 
 @findex check-parens
-You can use @kbd{M-x check-parens} to find any unbalanced parentheses in
-a buffer.
+@cindex unbalanced parentheses and quotes
+You can use @kbd{M-x check-parens} to find any unbalanced parentheses
+and unbalanced quotes in strings in a buffer.
 
 @node Symbol Completion
 @section Completion for Symbol Names
@@ -1531,7 +1565,24 @@ Specifies what kind of hidden blocks to open in Isearch mode.
 Initializes Hideshow variables for different modes.
 @end table
 
-@node Documentation, Change Log, Hideshow, Programs
+@node Glasses
+@section Glasses minor mode
+@cindex Glasses mode
+@cindex identifiers, unreadable
+@cindex StudlyCaps
+@findex glasses-mode
+
+Glasses minor mode makes @samp{unreadableIdentifiersLikeThis} readable
+by displaying underscores between all the pairs of lower and upper
+English letters or by emboldening the capitals.  The text is not
+altered, only the display, so that you can use this mode on code written
+with such a convention for separating words in identifiers without
+modifying the code.  It can be customized under the group
+@samp{glasses}.  You can use it by adding @code{glasses-mode} to the
+mode hook of appropriate programming modes.
+
+
+@node Documentation
 @section Documentation Commands
 
   As you edit Lisp code to be run in Emacs, the commands @kbd{C-h f}
@@ -1670,6 +1721,10 @@ file.  You can disable this by setting the variable
 Tar-mode @kbd{w} key is bound to @code{woman-find-file} on the current
 line's archive member.
 
+  For more information about setting up and using @kbd{M-x woman}, see
+@ref{Top, WoMan, Browse UN*X Manual Pages WithOut Man, woman, The WoMan
+Manual}.
+
   Eventually the GNU project hopes to replace most man pages with
 better-organized manuals that you can browse with Info.  @xref{Misc
 Help}.  Since this process is only partially completed, it is still
@@ -1683,7 +1738,10 @@ useful to read manual pages.
 @findex add-change-log-entry-other-window
   The Emacs command @kbd{C-x 4 a} adds a new entry to the change log
 file for the file you are editing
-(@code{add-change-log-entry-other-window}).
+(@code{add-change-log-entry-other-window}).  If that file is actually a
+backup file, it makes an entry appropriate for the file's parent.  This
+is useful for making log entries by comparing a version with deleted
+functions.
 
   A change log file contains a chronological record of when and why you
 have changed a program, consisting of a sequence of entries describing
@@ -1719,9 +1777,6 @@ with whitespace and a star.  Here are two entries, both dated in May
         (vc-cancel-version): Doc fix.
 @end smallexample
 
-@noindent
-(Previous Emacs versions used a different format for the date.)
-
   One entry can describe several changes; each change should have its
 own item.  Normally there should be a blank line between items.  When
 items are related (parts of the same change, in different places), group
@@ -1737,6 +1792,17 @@ When the option @code{add-log-keep-changes-together} is set, @kbd{C-x 4
 a} adds to any existing entry for the file rather than starting a new
 entry.
 
+@vindex change-log-version-info-enabled
+@vindex change-log-version-number-regexp-list
+@cindex file version in change log entries
+  If the value of the variable @code{change-log-version-info-enabled} is
+non-nil, the file's version number is automatically added to change log
+entries.  The search for the file's version number is performed based on
+regular expressions from the variable
+@code{change-log-version-number-regexp-list}, which can be customized
+(versions of files that are under version control systems are known to
+Emacs through the version-control interface).
+
 @cindex Change Log mode
 @findex change-log-mode
   The change log file is visited in Change Log mode.  In this major
@@ -1750,9 +1816,43 @@ The command @kbd{M-x change-log-merge} can be used to merge other log
 files into a buffer in Change Log Mode, preserving the date ordering
 of entries with either the current or old-style date formats.
 
+@findex change-log-redate
+@cindex converting change log date style
+  Versions of Emacs before 20.1 used a different format for the time of
+the change log entry:
+
+@smallexample
+Fri May 25 11:23:23 1993 Richard Stallman  <rms@@gnu.org>
+@end smallexample
+
+@noindent
+The @kbd{M-x change-log-redate} command converts all the old-style date
+entries in the change log file visited in the current buffer to the new
+format, so that all entries are kept in unified format.  This is handy
+when the entries are contributed by many different people some of whom
+still use old versions of Emacs.
+
   Version control systems are another way to keep track of changes in your
 program and keep a change log.  @xref{Log Buffer}.
 
+@node Authors
+@section @file{AUTHORS} files
+@cindex @file{AUTHORS} file
+
+  Programs which have many contributors usually include a file named
+@file{AUTHORS} in their distribution, which lists the individual
+contributions.  Emacs has a special command for maintaining the
+@file{AUTHORS} file that is part of the Emacs distribution.
+
+@findex authors
+  The @kbd{M-x authors} command prompts for the name of the root of the
+Emacs source directory.  It then scans @file{ChageLog} files and Lisp
+source files under that directory for information about authors of
+individual packages and people who made changes in source files, and
+puts the information it gleans into a buffer named @samp{*Authors*}.
+You can then edit the contents of that buffer and merge it with the
+exisiting @file{AUTHORS} file.
+
 @node Tags
 @section Tags Tables
 @cindex tags table
@@ -1778,6 +1878,13 @@ normally include all functions and subroutines, and may also include
 global variables, data types, and anything else convenient.  Each name
 recorded is called a @dfn{tag}.
 
+@cindex C++ class browser, tags
+@cindex tags, C++
+@cindex class browser, C++
+@cindex Ebrowse
+The Ebrowse is a separate facility tailored for C++, with tags and a
+class browser.  @xref{,,, ebrowse, Ebrowse User's Manual}.
+
 @menu
 * Tag Syntax::         Tag syntax for various types of code and text files.
 * Create Tags Table::  Creating a tags table with @code{etags}.
@@ -2278,6 +2385,8 @@ that it does regexp matching instead of substring matching.
 
 @node Tags Search
 @subsection Searching and Replacing with Tags Tables
+@cindex search and replace in several program files
+@cindex multiple-file search and replace (with tag tables)
 
   The commands in this section visit and search all the files listed in the
 selected tags table, one by one.  For these commands, the tags table serves
@@ -2316,6 +2425,13 @@ ordinary @kbd{M-x query-replace-regexp}.  It searches much like @kbd{M-x
 tags-search}, but repeatedly, processing matches according to your
 input.  @xref{Replace}, for more information on query replace.
 
+@vindex tags-case-fold-search
+@cindex case-sensitivity, and tags search
+  You can control the case-sensitivity of tags search commands by
+customizing the value of the variable @code{tags-case-fold-search}.  The
+default is to use the same setting as the value of
+@code{case-fold-search} (@pxref{Search Case}).
+
   It is possible to get through all the files in the tags table with a
 single invocation of @kbd{M-x tags-query-replace}.  But often it is
 useful to exit temporarily, which you can do with any input event that
@@ -2372,6 +2488,13 @@ tag names found.
 You can display additional output with @kbd{M-x tags-apropos} by customizing
 the variable @code{tags-apropos-additional-actions}.  See its
 documentation for details.
+@vindex tags-apropos-verbose
+Setting the variable @code{tags-apropos-verbose} to a non-nil value
+causes @kbd{M-x tags-apropos} to display the names of the tags files
+together with the tag names.
+@vindex tags-tag-face
+The face @code{tags-tag-face} can be used to customize the appearance of
+tags in the output of @kbd{M-x tags-apropos}.
 
   You can also perform completion in the buffer on the name space of tag
 names in the current tags tables.  @xref{Symbol Completion}.
@@ -2382,7 +2505,7 @@ names in the current tags tables.  @xref{Symbol Completion}.
 @cindex buffer content indexes
 @cindex tags
 
-The Imenu package provides mode-specific indexes of the contents of
+The Imenu facility provides mode-specific indexes of the contents of
 single buffers and provides selection from a menu.  Selecting a menu
 item takes you to the indexed point in the buffer, in a similar way to
 the Tags facility.  Indexing is typically by names of program routines
@@ -2401,7 +2524,7 @@ with @kbd{imenu-add-menu-bar-index}.
 Some major modes provide facilities for invoking Imenu; otherwise you
 could add @code{imenu-add-menu-bar-index} to a major mode's hook to
 generate an index for each buffer created in that mode.  (If you do
-that, it takes sime time to generate the index when finding a file,
+that, it takes some time to generate the index when finding a file,
 depending on the file's size and the complexity of the indexing function
 for that mode.)
 
@@ -2430,7 +2553,7 @@ It's not unusual for programmers to get their signals crossed and modify
 the same program in two different directions.  To recover from this
 confusion, you need to merge the two versions.  Emerge makes this
 easier.  See also @ref{Comparing Files}, for commands to compare
-in a more manual fashion, and @ref{Emerge,,, ediff, The Ediff Manual}.
+in a more manual fashion, and @ref{,Ediff,, ediff, The Ediff Manual}.
 
 @menu
 * Overview of Emerge:: How to start Emerge.  Basic concepts.
@@ -3117,6 +3240,37 @@ click on @samp{[A]pply these settings} (or go to that buffer and type
 Display the syntactic information about the current source line
 (@code{c-show-syntactic-information}).  This is the information that
 directs how the line is indented.
+
+@item M-x cwarn-mode
+@itemx M-x global-cwarn-mode
+@findex cwarn-mode
+@findex global-cwarn-mode
+@cindex CWarn mode
+@cindex suspicious constructions in C, C++
+CWarn minor mode highlights suspicious C and C++ constructions:
+
+@itemize @bullet{}
+@item
+Assignments inside expressions, including variations like @samp{+=};
+@item
+Semicolon following immediately after @samp{if}, @samp{for}, and @samp{while}
+(except after a @samp{do @dots{} while} statement);
+@item
+C++ functions with reference parameters.
+@end itemize
+
+@noindent
+You can activate the mode either by customizing @code{global-cwarn-mode}
+or by adding @code{cwarn-mode} to @code{c-mode-common-hook}.  It
+requires Font Lock mode to be active.
+
+@item M-x hide-ifdef-mode
+@findex hide-ifdef-mode
+@cindex Hide-ifdef mode
+Hide-ifdef minor mode hides selected code within @samp{#if} and
+@samp{#ifdef} preprocessor blocks.  You can activate it by adding
+@code{hide-ifdef-mode} to @code{c-mode-common-hook}.  See the mode's
+help for more information.
 @end table
 
 @node Comments in C
@@ -3155,6 +3309,7 @@ value is @code{t}, which puts the comment-start delimiter @samp{/*} at
 the beginning of the first line of the comment text.
 @end table
 
+
 @node Fortran
 @section Fortran Mode
 @cindex Fortran mode