home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / emacs.i08 (.txt) < prev    next >
GNU Info File  |  1993-06-14  |  47KB  |  815 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.47 from the
  2. input file emacs.tex.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  11. General Public License" are included exactly as in the original, and
  12. provided that the entire resulting derived work is distributed under the
  13. terms of a permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "The GNU Manifesto",
  17. "Distribution" and "GNU General Public License" may be included in a
  18. translation approved by the author instead of in the original English.
  19. File: emacs,  Node: Lisp Completion,  Next: Documentation,  Prev: Balanced Editing,  Up: Programs
  20. Completion for Lisp Symbols
  21. ===========================
  22.    Usually completion happens in the minibuffer.  But one kind of
  23. completion is available in all buffers: completion for Lisp symbol
  24. names.
  25.    The command `M-TAB' (`lisp-complete-symbol') takes the partial Lisp
  26. symbol before point to be an abbreviation, and compares it against all
  27. nontrivial Lisp symbols currently known to Emacs.  Any additional
  28. characters that they all have in common are inserted at point.
  29. Nontrivial symbols are those that have function definitions, values or
  30. properties.
  31.    If there is an open-parenthesis immediately before the beginning of
  32. the partial symbol, only symbols with function definitions are
  33. considered as completions.
  34.    If the partial name in the buffer has more than one possible
  35. completion and they have no additional characters in common, a list of
  36. all possible completions is displayed in another window.
  37. File: emacs,  Node: Documentation,  Next: Change Log,  Prev: Lisp Completion,  Up: Programs
  38. Documentation Commands
  39. ======================
  40.    As you edit Lisp code to be run in Emacs, the commands `C-h f'
  41. (`describe-function') and `C-h v' (`describe-variable') can be used to
  42. print documentation of functions and variables that you want to call. 
  43. These commands use the minibuffer to read the name of a function or
  44. variable to document, and display the documentation in a window.
  45.    For extra convenience, these commands provide default arguments
  46. based on the code in the neighborhood of point.  `C-h f' sets the
  47. default to the function called in the innermost list containing point. 
  48. `C-h v' uses the symbol name around or adjacent to point as its default.
  49.    Documentation on Unix commands, system calls and libraries can be
  50. obtained with the `M-x manual-entry' command.  This reads a topic as an
  51. argument, and displays the text on that topic from the Unix manual.
  52. `manual-entry' always searches all 8 sections of the manual, and
  53. concatenates all the entries that are found.  For example, the topic
  54. `termcap' finds the description of the termcap library from section 3,
  55. followed by the description of the termcap data base from section 5.
  56. File: emacs,  Node: Change Log,  Next: Tags,  Prev: Documentation,  Up: Programs
  57. Change Logs
  58. ===========
  59.    The Emacs command `M-x add-change-log-entry' helps you keep a record
  60. of when and why you have changed a program.  It assumes that you have a
  61. file in which you write a chronological sequence of entries describing
  62. individual changes.  The default is to store the change entries in a
  63. file called `ChangeLog' in the same directory as the file you are
  64. editing. The same `ChangeLog' file therefore records changes for all
  65. the files in the directory.
  66.    A change log entry starts with a header line that contains your name
  67. and the current date.  Aside from these header lines, every line in the
  68. change log starts with a tab.  One entry can describe several changes;
  69. each change starts with a line starting with a tab and a star.  `M-x
  70. add-change-log-entry' visits the change log file and creates a new
  71. entry unless the most recent entry is for today's date and your name. 
  72. In either case, it adds a new line to start the description of another
  73. change just after the header line of the entry.  When `M-x
  74. add-change-log-entry' is finished, all is prepared for you to edit in
  75. the description of what you changed and how. You must then save the
  76. change log file yourself.
  77.    The change log file is always visited in Indented Text mode, which
  78. means that LFD and auto-filling indent each new line like the previous
  79. line.  This is convenient for entering the contents of an entry, which
  80. must all be indented.  *Note Text Mode::.
  81.    Here is an example of the formatting conventions used in the change
  82. log for Emacs:
  83.      Wed Jun 26 19:29:32 1985  Richard M. Stallman  (rms at mit-prep)
  84.      
  85.              * xdisp.c (try_window_id):
  86.              If C-k is done at end of next-to-last line,
  87.              this fn updates window_end_vpos and cannot leave
  88.              window_end_pos nonnegative (it is zero, in fact).
  89.              If display is preempted before lines are output,
  90.              this is inconsistent.  Fix by setting
  91.              blank_end_of_window to nonzero.
  92.      
  93.      Tue Jun 25 05:25:33 1985  Richard M. Stallman  (rms at mit-prep)
  94.      
  95.              * cmds.c (Fnewline):
  96.              Call the auto fill hook if appropriate.
  97.      
  98.              * xdisp.c (try_window_id):
  99.              If point is found by compute_motion after xp, record that
  100.              permanently.  If display_text_line sets point position wrong
  101.              (case where line is killed, point is at eob and that line is
  102.              not displayed), set it again in final compute_motion.
  103. File: emacs,  Node: Tags,  Next: Fortran,  Prev: Change Log,  Up: Programs
  104. Tag Tables
  105. ==========
  106.    A "tag table" is a description of how a multi-file program is broken
  107. up into files.  It lists the names of the component files and the names
  108. and positions of the functions in each file.  Grouping the related
  109. files makes it possible to search or replace through all the files with
  110. one command. Recording the function names and positions makes possible
  111. the `Meta-.' command which you can use to find the definition of a
  112. function without having to know which of the files it is in.
  113.    Tag tables are stored in files called "tag table files".  The
  114. conventional name for a tag table file is `TAGS'.
  115.    Each entry in the tag table records the name of one tag, the name of
  116. the file that the tag is defined in (implicitly), and the position in
  117. that file of the tag's definition.
  118.    Just what names from the described files are recorded in the tag
  119. table depends on the programming language of the described file.  They
  120. normally include all functions and subroutines, and may also include
  121. global variables, data types, and anything else convenient.  In any
  122. case, each name recorded is called a "tag".
  123. * Menu:
  124. * Tag Syntax::
  125. * Create Tag Table::
  126. * Select Tag Table::
  127. * Find Tag::
  128. * Tags Search::
  129. * Tags Stepping::
  130. * List Tags::
  131. File: emacs,  Node: Tag Syntax,  Next: Create Tag Table,  Prev: Tags,  Up: Tags
  132. Source File Tag Syntax
  133. ----------------------
  134.    In Lisp code, any function defined with `defun', any variable
  135. defined with `defvar' or `defconst', and in general the first argument
  136. of any expression that starts with `(def' in column zero, is a tag.
  137.    In C code, any C function is a tag, and so is any typedef if `-t' is
  138. specified when the tag table is constructed.
  139.    In Fortran code, functions and subroutines are tags.
  140.    In LaTeX text, the argument of any of the commands `\chapter',
  141. `\section', `\subsection', `\subsubsection', `\eqno', `\label', `\ref',
  142. `\cite', `\bibitem' and `\typeout' is a tag.
  143. File: emacs,  Node: Create Tag Table,  Next: Select Tag Table,  Prev: Tag Syntax,  Up: Tags
  144. Creating Tag Tables
  145. -------------------
  146.    The `etags' program is used to create a tag table file.  It knows
  147. the syntax of C, Fortran, LaTeX, Scheme and Emacs Lisp/Common Lisp.  To
  148. use `etags', type
  149.      etags INPUTFILES...
  150. as a shell command.  It reads the specified files and writes a tag table
  151. named `TAGS' in the current working directory.  `etags' recognizes the
  152. language used in an input file based on its file name and contents;
  153. there are no switches for specifying the language.  The `-t' switch
  154. tells `etags' to record typedefs in C code as tags.
  155.    If the tag table data become outdated due to changes in the files
  156. described in the table, the way to update the tag table is the same way
  157. it was made in the first place.  It is not necessary to do this often.
  158.    If the tag table fails to record a tag, or records it for the wrong
  159. file, then Emacs cannot possibly find its definition.  However, if the
  160. position recorded in the tag table becomes a little bit wrong (due to
  161. some editing in the file that the tag definition is in), the only
  162. consequence is to slow down finding the tag slightly.  Even if the
  163. stored position is very wrong, Emacs will still find the tag, but it
  164. must search the entire file for it.
  165.    So you should update a tag table when you define new tags that you
  166. want to have listed, or when you move tag definitions from one file to
  167. another, or when changes become substantial.  Normally there is no need
  168. to update the tag table after each edit, or even every day.
  169. File: emacs,  Node: Select Tag Table,  Next: Find Tag,  Prev: Create Tag Table,  Up: Tags
  170. Selecting a Tag Table
  171. ---------------------
  172.    Emacs has at any time one "selected" tag table, and all the commands
  173. for working with tag tables use the selected one.  To select a tag
  174. table, type `M-x visit-tags-table', which reads the tag table file name
  175. as an argument.  The name `TAGS' in the default directory is used as the
  176. default file name.
  177.    All this command does is store the file name in the variable
  178. `tags-file-name'.  Emacs does not actually read in the tag table
  179. contents until you try to use them.  Setting this variable yourself is
  180. just as good as using `visit-tags-table'.  The variable's initial value
  181. is `nil'; this value tells all the commands for working with tag tables
  182. that they must ask for a tag table file name to use.
  183. File: emacs,  Node: Find Tag,  Next: Tags Search,  Prev: Select Tag Table,  Up: Tags
  184. Finding a Tag
  185. -------------
  186.    The most important thing that a tag table enables you to do is to
  187. find the definition of a specific tag.
  188. `M-. TAG'
  189.      Find first definition of TAG (`find-tag').
  190. `C-u M-.'
  191.      Find next alternate definition of last tag specified.
  192. `C-x 4 . TAG'
  193.      Find first definition of TAG, but display it in another window
  194.      (`find-tag-other-window').
  195.    `M-.' (`find-tag') is the command to find the definition of a
  196. specified tag.  It searches through the tag table for that tag, as a
  197. string, and then uses the tag table info to determine the file that the
  198. definition is in and the approximate character position in the file of
  199. the definition.  Then `find-tag' visits that file, moves point to the
  200. approximate character position, and starts searching ever-increasing
  201. distances away for the the text that should appear at the beginning of
  202. the definition.
  203.    If an empty argument is given (just type RET), the sexp in the
  204. buffer before or around point is used as the name of the tag to find.
  205. *Note Lists::, for info on sexps.
  206.    The argument to `find-tag' need not be the whole tag name; it can be
  207. a substring of a tag name.  However, there can be many tag names
  208. containing the substring you specify.  Since `find-tag' works by
  209. searching the text of the tag table, it finds the first tag in the
  210. table that the specified substring appears in.  The way to find other
  211. tags that match the substring is to give `find-tag' a numeric argument,
  212. as in `C-u M-.'; this does not read a tag name, but continues searching
  213. the tag table's text for another tag containing the same substring last
  214. used.  If you have a real META key, `M-0 M-.' is an easier alternative
  215. to `C-u M-.'.
  216.    Like most commands that can switch buffers, `find-tag' has another
  217. similar command that displays the new buffer in another window.  `C-x 4
  218. .' invokes the function `find-tag-other-window'.  (This key sequence
  219. ends with a period.)
  220.    Emacs comes with a tag table file `TAGS', in the directory
  221. containing Lisp libraries, which includes all the Lisp libraries and all
  222. the C sources of Emacs.  By specifying this file with `visit-tags-table'
  223. and then using `M-.' you can quickly look at the source of any Emacs
  224. function.
  225. File: emacs,  Node: Tags Search,  Next: Tags Stepping,  Prev: Find Tag,  Up: Tags
  226. Searching and Replacing with Tag Tables
  227. ---------------------------------------
  228.    The commands in this section visit and search all the files listed
  229. in the selected tag table, one by one.  For these commands, the tag
  230. table serves only to specify a sequence of files to search.  A related
  231. command is `M-x grep' (*note Compilation::.).
  232. `M-x tags-search'
  233.      Search for the specified regexp through the files in the selected
  234.      tag table.
  235. `M-x tags-query-replace'
  236.      Perform a `query-replace' on each file in the selected tag table.
  237. `M-,'
  238.      Restart one of the commands above, from the current location of
  239.      point (`tags-loop-continue').
  240.    `M-x tags-search' reads a regexp using the minibuffer, then visits
  241. the files of the selected tag table one by one, and searches through
  242. each one for that regexp.  It displays the name of the file being
  243. searched so you can follow its progress.  As soon as an occurrence is
  244. found, `tags-search' returns.
  245.    Having found one match, you probably want to find all the rest.  To
  246. find one more match, type `M-,' (`tags-loop-continue') to resume the
  247. `tags-search'.  This searches the rest of the current buffer, followed
  248. by the remaining files of the tag table.
  249.    `M-x tags-query-replace' performs a single `query-replace' through
  250. all the files in the tag table.  It reads a string to search for and a
  251. string to replace with, just like ordinary `M-x query-replace'. It
  252. searches much like `M-x tags-search' but repeatedly, processing matches
  253. according to your input.  *Note Replace::, for more information on
  254. `query-replace'.
  255.    It is possible to get through all the files in the tag table with a
  256. single invocation of `M-x tags-query-replace'.  But since any
  257. unrecognized character causes the command to exit, you may need to
  258. continue where you left off.  `M-,' can be used for this.  It resumes
  259. the last tags search or replace command that you did.
  260.    It may have struck you that `tags-search' is a lot like `grep'. You
  261. can also run `grep' itself as an inferior of Emacs and have Emacs show
  262. you the matching lines one by one.  This works mostly the same as
  263. running a compilation and having Emacs show you where the errors were.
  264. *Note Compilation::.
  265. File: emacs,  Node: Tags Stepping,  Next: List Tags,  Prev: Tags Search,  Up: Tags
  266. Stepping Through a Tag Table
  267. ----------------------------
  268.    If you wish to process all the files in the selected tag table, but
  269. `M-x tags-search' and `M-x tags-query-replace' in particular are not
  270. what you want, you can use `M-x next-file'.
  271. `C-u M-x next-file'
  272.      With a numeric argument, regardless of its value, visit the first
  273.      file in the tag table, and prepare to advance sequentially by
  274.      files.
  275. `M-x next-file'
  276.      Visit the next file in the selected tag table.
  277. File: emacs,  Node: List Tags,  Prev: Tags Stepping,  Up: Tags
  278. Tag Table Inquiries
  279. -------------------
  280. `M-x list-tags'
  281.      Display a list of the tags defined in a specific program file.
  282. `M-x tags-apropos'
  283.      Display a list of all tags matching a specified regexp.
  284.    `M-x list-tags' reads the name of one of the files described by the
  285. selected tag table, and displays a list of all the tags defined in that
  286. file.  The "file name" argument is really just a string to compare
  287. against the names recorded in the tag table; it is read as a string
  288. rather than as a file name.  Therefore, completion and defaulting are
  289. not available, and you must enter the string the same way it appears in
  290. the tag table.  Do not include a directory as part of the file name
  291. unless the file name recorded in the tag table includes a directory.
  292.    `M-x tags-apropos' is like `apropos' for tags.  It reads a regexp,
  293. then finds all the tags in the selected tag table whose entries match
  294. that regexp, and displays the tag names found.
  295. File: emacs,  Node: Fortran,  Prev: Tags,  Up: Programs
  296. Fortran Mode
  297. ============
  298.    Fortran mode provides special motion commands for Fortran statements
  299. and subprograms, and indentation commands that understand Fortran
  300. conventions of nesting, line numbers and continuation statements.
  301.    Special commands for comments are provided because Fortran comments
  302. are unlike those of other languages.
  303.    Built-in abbrevs optionally save typing when you insert Fortran
  304. keywords.
  305.    Use `M-x fortran-mode' to switch to this major mode.  Doing so calls
  306. the value of `fortran-mode-hook' as a function of no arguments if that
  307. variable has a value that is not `nil'.
  308. * Menu:
  309. * Motion: Fortran Motion.     Moving point by statements or subprograms.
  310. * Indent: Fortran Indent.     Indentation commands for Fortran.
  311. * Comments: Fortran Comments. Inserting and aligning comments.
  312. * Columns: Fortran Columns.   Measuring columns for valid Fortran.
  313. * Abbrev: Fortran Abbrev.     Built-in abbrevs for Fortran keywords.
  314.    Fortran mode was contributed by Michael Prange.
  315. File: emacs,  Node: Fortran Motion,  Next: Fortran Indent,  Prev: Fortran,  Up: Fortran
  316. Motion Commands
  317. ---------------
  318.    Fortran mode provides special commands to move by subprograms
  319. (functions and subroutines) and by statements.  There is also a command
  320. to put the region around one subprogram, convenient for killing it or
  321. moving it.
  322. `C-M-a'
  323.      Move to beginning of subprogram
  324.      (`beginning-of-fortran-subprogram').
  325. `C-M-e'
  326.      Move to end of subprogram (`end-of-fortran-subprogram').
  327. `C-M-h'
  328.      Put point at beginning of subprogram and mark at end
  329.      (`mark-fortran-subprogram').
  330. `C-c C-n'
  331.      Move to beginning of current or next statement
  332.      (`fortran-next-statement').
  333. `C-c C-p'
  334.      Move to beginning of current or previous statement
  335.      (`fortran-previous-statement').
  336. File: emacs,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
  337. Fortran Indentation
  338. -------------------
  339.    Special commands and features are needed for indenting Fortran code
  340. in order to make sure various syntactic entities (line numbers, comment
  341. line indicators and continuation line flags) appear in the columns that
  342. are required for standard Fortran.
  343. * Menu:
  344. * Commands: ForIndent Commands. Commands for indenting Fortran.
  345. * Numbers:  ForIndent Num.      How line numbers auto-indent.
  346. * Conv:     ForIndent Conv.     Conventions you must obey to avoid trouble.
  347. * Vars:     ForIndent Vars.     Variables controlling Fortran indent style.
  348. File: emacs,  Node: ForIndent Commands,  Next: ForIndent Num,  Prev: Fortran Indent,  Up: Fortran Indent
  349. Fortran Indentation Commands
  350. ............................
  351. `TAB'
  352.      Indent the current line (`fortran-indent-line').
  353. `M-LFD'
  354.      Break the current line and set up a continuation line.
  355. `C-M-q'
  356.      Indent all the lines of the subprogram point is in
  357.      (`fortran-indent-subprogram').
  358.    TAB is redefined by Fortran mode to reindent the current line for
  359. Fortran (`fortran-indent-line').  Line numbers and continuation markers
  360. are indented to their required columns, and the body of the statement
  361. is independently indented based on its nesting in the program.
  362.    The key `C-M-q' is redefined as `fortran-indent-subprogram', a
  363. command to reindent all the lines of the Fortran subprogram (function or
  364. subroutine) containing point.
  365.    The key `M-LFD' is redefined as `fortran-split-line', a command to
  366. split a line in the appropriate fashion for Fortran.  In a non-comment
  367. line, the second half becomes a continuation line and is indented
  368. accordingly.  In a comment line, both halves become separate comment
  369. lines.
  370. File: emacs,  Node: ForIndent Num,  Next: ForIndent Conv,  Prev: ForIndent Commands,  Up: Fortran Indent
  371. Line Numbers and Continuation
  372. .............................
  373.    If a number is the first non-whitespace in the line, it is assumed
  374. to be a line number and is moved to columns 0 through 4.  (Columns are
  375. always counted from 0 in GNU Emacs.)  If the text on the line starts
  376. with the conventional Fortran continuation marker `$', it is moved to
  377. column 5. If the text begins with any non whitespace character in
  378. column 5, it is assumed to be an unconventional continuation marker and
  379. remains in column 5.
  380.    Line numbers of four digits or less are normally indented one space.
  381. This amount is controlled by the variable `fortran-line-number-indent'
  382. which is the maximum indentation a line number can have.  Line numbers
  383. are indented to right-justify them to end in column 4 unless that would
  384. require more than this maximum indentation.  The default value of the
  385. variable is 1.
  386.    Simply inserting a line number is enough to indent it according to
  387. these rules.  As each digit is inserted, the indentation is recomputed.
  388.  To turn off this feature, set the variable
  389. `fortran-electric-line-number' to `nil'.  Then inserting line numbers
  390. is like inserting anything else.
  391. File: emacs,  Node: ForIndent Conv,  Next: ForIndent Vars,  Prev: ForIndent Num,  Up: Fortran Indent
  392. Syntactic Conventions
  393. .....................
  394.    Fortran mode assumes that you follow certain conventions that
  395. simplify the task of understanding a Fortran program well enough to
  396. indent it properly:
  397.    * Two nested `do' loops never share a `continue' statement.
  398.    * The same character appears in column 5 of all continuation lines,
  399.      and this character is the value of the variable
  400.      `fortran-continuation-char'. By default, this character is `$'.
  401. If you fail to follow these conventions, the indentation commands may
  402. indent some lines unaesthetically.  However, a correct Fortran program
  403. will retain its meaning when reindented even if the conventions are not
  404. followed.
  405. File: emacs,  Node: ForIndent Vars,  Prev: ForIndent Conv,  Up: Fortran Indent
  406. Variables for Fortran Indentation
  407. .................................
  408.    Several additional variables control how Fortran indentation works.
  409. `fortran-do-indent'
  410.      Extra indentation within each level of `do' statement (default 3).
  411. `fortran-if-indent'
  412.      Extra indentation within each level of `if' statement (default 3).
  413. `fortran-continuation-indent'
  414.      Extra indentation for bodies of continuation lines (default 5).
  415. `fortran-check-all-num-for-matching-do'
  416.      If this is `nil', indentation assumes that each `do' statement
  417.      ends on a `continue' statement.  Therefore, when computing
  418.      indentation for a statement other than `continue', it can save
  419.      time by not checking for a `do' statement ending there. If this is
  420.      non-`nil', indenting any numbered statement must check for a `do'
  421.      that ends there.  The default is `nil'.
  422. `fortran-minimum-statement-indent'
  423.      Minimum indentation for fortran statements.  For standard Fortran,
  424.      this is 6.  Statement bodies will never be indented less than this
  425.      much.
  426. File: emacs,  Node: Fortran Comments,  Next: Fortran Columns,  Prev: Fortran Indent,  Up: Fortran
  427. Comments
  428. --------
  429.    The usual Emacs comment commands assume that a comment can follow a
  430. line of code.  In Fortran, the standard comment syntax requires an
  431. entire line to be just a comment.  Therefore, Fortran mode replaces the
  432. standard Emacs comment commands and defines some new variables.
  433.    Fortran mode can also handle a nonstandard comment syntax where
  434. comments start with `!' and can follow other text.  Because only some
  435. Fortran compilers accept this syntax, Fortran mode will not insert such
  436. comments unless you have said in advance to do so.  To do this, set the
  437. variable `comment-start' to `"!"' (*note Variables::.).
  438. `M-;'
  439.      Align comment or insert new comment (`fortran-comment-indent').
  440. `C-x ;'
  441.      Applies to nonstandard `!' comments only.
  442. `C-c ;'
  443.      Turn all lines of the region into comments, or (with arg) turn
  444.      them back into real code (`fortran-comment-region').
  445.    `M-;' in Fortran mode is redefined as the command
  446. `fortran-comment-indent'.  Like the usual `M-;' command, this
  447. recognizes any kind of existing comment and aligns its text
  448. appropriately; if there is no existing comment, a comment is inserted
  449. and aligned.  But inserting and aligning comments are not the same in
  450. Fortran mode as in other modes.
  451.    When a new comment must be inserted, if the current line is blank, a
  452. full-line comment is inserted.  On a non-blank line, a nonstandard `!'
  453. comment is inserted if you have said you want to use them.  Otherwise a
  454. full-line comment is inserted on a new line before the current line.
  455.    Nonstandard `!' comments are aligned like comments in other
  456. languages, but full-line comments are different.  In a standard
  457. full-line comment, the comment delimiter itself must always appear in
  458. column zero. What can be aligned is the text within the comment.  You
  459. can choose from three styles of alignment by setting the variable
  460. `fortran-comment-indent-style' to one of these values:
  461. `fixed'
  462.      The text is aligned at a fixed column, which is the value of
  463.      `fortran-comment-line-column'.  This is the default.
  464. `relative'
  465.      The text is aligned as if it were a line of code, but with an
  466.      additional `fortran-comment-line-column' columns of indentation.
  467. `nil'
  468.      Text in full-line columns is not moved automatically.
  469.    In addition, you can specify the character to be used to indent
  470. within full-line comments by setting the variable
  471. `fortran-comment-indent-char' to the character you want to use.
  472.    Fortran mode introduces two variables `comment-line-start' and
  473. `comment-line-start-skip' which play for full-line comments the same
  474. roles played by `comment-start' and `comment-start-skip' for ordinary
  475. text-following comments.  Normally these are set properly by Fortran
  476. mode so you do not need to change them.
  477.    The normal Emacs comment command `C-x ;' has not been redefined. If
  478. you use `!' comments, this command can be used with them.  Otherwise it
  479. is useless in Fortran mode.
  480.    The command `C-c ;' (`fortran-comment-region') turns all the lines
  481. of the region into comments by inserting the string `C$$$' at the front
  482. of each one.  With a numeric arg, the region is turned back into live
  483. code by deleting `C$$$' from the front of each line in it.  The string
  484. used for these comments can be controlled by setting the variable
  485. `fortran-comment-region'.  Note that here we have an example of a
  486. command and a variable with the same name; these two uses of the name
  487. never conflict because in Lisp and in Emacs it is always clear from the
  488. context which one is meant.
  489. File: emacs,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Comments,  Up: Fortran
  490. Columns
  491. -------
  492. `C-c C-r'
  493.      Displays a "column ruler" momentarily above the current line
  494.      (`fortran-column-ruler').
  495. `C-c C-w'
  496.      Splits the current window horizontally so that it is 72 columns
  497.      wide. This may help you avoid going over that limit
  498.      (`fortran-window-create').
  499.    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
  500. momentarily above the current line.  The comment ruler is two lines of
  501. text that show you the locations of columns with special significance
  502. in Fortran programs.  Square brackets show the limits of the columns for
  503. line numbers, and curly brackets show the limits of the columns for the
  504. statement body.  Column numbers appear above them.
  505.    Note that the column numbers count from zero, as always in GNU
  506. Emacs.  As a result, the numbers may not be those you are familiar
  507. with; but the actual positions in the line are standard Fortran.
  508.    The text used to display the column ruler is the value of the
  509. variable `fortran-comment-ruler'.  By changing this variable, you can
  510. change the display.
  511.    For even more help, use `C-c C-w' (`fortran-window-create'), a
  512. command which splits the current window horizontally, making a window 72
  513. columns wide.  By editing in this window you can immediately see when
  514. you make a line too wide to be correct Fortran.
  515. File: emacs,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
  516. Fortran Keyword Abbrevs
  517. -----------------------
  518.    Fortran mode provides many built-in abbrevs for common keywords and
  519. declarations.  These are the same sort of abbrev that you can define
  520. yourself.  To use them, you must turn on Abbrev mode.  *note Abbrevs::..
  521.    The built-in abbrevs are unusual in one way: they all start with a
  522. semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
  523. mode makes this possible by changing the syntax of semicolon to "word
  524. constituent".
  525.    For example, one built-in Fortran abbrev is `;c' for `continue'.  If
  526. you insert `;c' and then insert a punctuation character such as a space
  527. or a newline, the `;c' will change automatically to `continue',
  528. provided Abbrev mode is enabled.
  529.    Type `;?' or `;C-h' to display a list of all the built-in Fortran
  530. abbrevs and what they stand for.
  531. File: emacs,  Node: Running,  Next: Abbrevs,  Prev: Programs,  Up: Top
  532. Compiling and Testing Programs
  533. ******************************
  534.    The previous chapter discusses the Emacs commands that are useful for
  535. making changes in programs.  This chapter deals with commands that
  536. assist in the larger process of developing and maintaining programs.
  537. * Menu:
  538. * Compilation::        Compiling programs in languages other than Lisp
  539.                         (C, Pascal, etc.)
  540. * Modes: Lisp Modes.   Various modes for editing Lisp programs, with
  541.                        different facilities for running the Lisp programs.
  542. * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
  543. * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
  544. * Eval: Lisp Eval.     Executing a single Lisp expression in Emacs.
  545. * Debug: Lisp Debug.   Debugging Lisp programs running in Emacs.
  546. * External Lisp::      Communicating through Emacs with a separate Lisp.
  547. File: emacs,  Node: Compilation,  Next: Lisp Modes,  Prev: Running,  Up: Running
  548. Running `make', or Compilers Generally
  549. ======================================
  550.    Emacs can run compilers for noninteractive languages such as C and
  551. Fortran as inferior processes, feeding the error log into an Emacs
  552. buffer. It can also parse the error messages and visit the files in
  553. which errors are found, moving point right to the line where the error
  554. occurred.
  555. `M-x compile'
  556.      Run a compiler asynchronously under Emacs, with error messages to
  557.      `*compilation*' buffer.
  558. `M-x grep'
  559.      Run `grep' asynchronously under Emacs, with matching lines listed
  560.      in the buffer named `*compilation*'.
  561. `M-x kill-compiler'
  562. `M-x kill-grep'
  563.      Kill the running compilation or `grep' subprocess.
  564. `C-x `'
  565.      Visit the locus of the next compiler error message or `grep' match.
  566.    To run `make' or another compiler, do `M-x compile'.  This command
  567. reads a shell command line using the minibuffer, and then executes the
  568. specified command line in an inferior shell with output going to the
  569. buffer named `*compilation*'.  The current buffer's default directory
  570. is used as the working directory for the execution of the command;
  571. normally, therefore, the makefile comes from this directory.
  572.    When the shell command line is read, the minibuffer appears
  573. containing a default command line, which is the command you used the
  574. last time you did `M-x compile'.  If you type just RET, the same
  575. command line is used again.  The first `M-x compile' provides `make -k'
  576. as the default. The default is taken from the variable
  577. `compile-command'; if the appropriate compilation command for a file is
  578. something other than `make -k', it can be useful to have the file
  579. specify a local value for `compile-command' (*note File Variables::.).
  580.    Starting a compilation causes the buffer `*compilation*' to be
  581. displayed in another window but not selected.  Its mode line tells you
  582. whether compilation is finished, with the word `run' or `exit' inside
  583. the parentheses.  You do not have to keep this buffer visible;
  584. compilation continues in any case.
  585.    To kill the compilation process, do `M-x kill-compilation'.  You will
  586. see that the mode line of the `*compilation*' buffer changes to say
  587. `signal' instead of `run'.  Starting a new compilation also kills any
  588. running compilation, as only one can exist at any time.  However, this
  589. requires confirmation before actually killing a compilation that is
  590. running.
  591.    To parse the compiler error messages, type `C-x `' (`next-error'). 
  592. The character following the `C-x' is the grave accent, not the single
  593. quote.  This command displays the buffer `*compilation*' in one window
  594. and the buffer in which the next error occurred in another window. 
  595. Point in that buffer is moved to the line where the error was found. 
  596. The corresponding error message is scrolled to the top of the window in
  597. which `*compilation*' is displayed.
  598.    The first time `C-x `' is used after the start of a compilation, it
  599. parses all the error messages, visits all the files that have error
  600. messages, and makes markers pointing at the lines that the error
  601. messages refer to.  Then it moves to the first error message location. 
  602. Subsequent uses of `C-x `' advance down the data set up by the first
  603. use.  When the preparsed error messages are exhausted, the next `C-x `'
  604. checks for any more error messages that have come in; this is useful if
  605. you start editing the compiler errors while the compilation is still
  606. going on.  If no more error messages have come in, `C-x `' reports an
  607. error.
  608.    `C-u C-x `' discards the preparsed error message data and parses the
  609. `*compilation*' buffer over again, then displaying the first error.
  610. This way, you can process the same set of errors again.
  611.    Instead of running a compiler, you can run `grep' and see the lines
  612. on which matches were found.  To do this, type `M-x grep' with an
  613. argument line that contains the same arguments you would give `grep'
  614. when running it normally: a `grep'-style regexp (usually in
  615. singlequotes to quote the shell's special characters) followed by
  616. filenames which may use wildcards. The output from `grep' goes in the
  617. `*compilation*' buffer and the lines that matched can be found with
  618. `C-x `' as if they were compilation errors.
  619.    Note: a shell is used to run the compile command, but the shell is
  620. told that it should be noninteractive.  This means in particular that
  621. the shell starts up with no prompt.  If you find your usual shell
  622. prompt making an unsightly appearance in the `*compilation*' buffer, it
  623. means you have made a mistake in your shell's init file (`.cshrc' or
  624. `.shrc' or ...) by setting the prompt unconditionally.  The shell init
  625. file should set the prompt only if there already is a prompt.  In
  626. `csh', here is how to do it:
  627.      if ($?prompt) set prompt = ...
  628. File: emacs,  Node: Lisp Modes,  Next: Lisp Libraries,  Prev: Compilation,  Up: Running
  629. Major Modes for Lisp
  630. ====================
  631.    Emacs has four different major modes for Lisp.  They are the same in
  632. terms of editing commands, but differ in the commands for executing Lisp
  633. expressions.
  634. Emacs-Lisp mode
  635.      The mode for editing source files of programs to run in Emacs Lisp.
  636.      This mode defines `C-M-x' to evaluate the current defun. *Note
  637.      Lisp Libraries::.
  638. Lisp Interaction mode
  639.      The mode for an interactive session with Emacs Lisp.  It defines
  640.      LFD to evaluate the sexp before point and insert its value in the
  641.      buffer.  *Note Lisp Interaction::.
  642. Lisp mode
  643.      The mode for editing source files of programs that run in Lisps
  644.      other than Emacs Lisp.  This mode defines `C-M-x' to send the
  645.      current defun to an inferior Lisp process.  *Note External Lisp::.
  646. Inferior Lisp mode
  647.      The mode for an interactive session with an inferior Lisp process.
  648.      This mode combines the special features of Lisp mode and Shell mode
  649.      (*note Shell Mode::.).
  650. Scheme mode
  651.      Like Lisp mode but for Scheme programs.
  652. Inferior Scheme mode
  653.      The mode for an interactive session with an inferior Scheme
  654.      process.
  655. File: emacs,  Node: Lisp Libraries,  Next: Lisp Eval,  Prev: Lisp Modes,  Up: Running
  656. Libraries of Lisp Code for Emacs
  657. ================================
  658.    Lisp code for Emacs editing commands is stored in files whose names
  659. conventionally end in `.el'.  This ending tells Emacs to edit them in
  660. Emacs-Lisp mode (*note Lisp Modes::.).
  661. * Menu:
  662. * Loading::        Loading libraries of Lisp code into Emacs for use.
  663. * Compiling Libraries:: Compiling a library makes it load and run faster.
  664. * Mocklisp::        Converting Mocklisp to Lisp so GNU Emacs can run it.
  665. File: emacs,  Node: Loading,  Next: Compiling Libraries,  Prev: Lisp Libraries,  Up: Lisp Libraries
  666. Loading Libraries
  667. -----------------
  668.    To execute a file of Emacs Lisp, use `M-x load-file'.  This command
  669. reads a file name using the minibuffer and then executes the contents of
  670. that file as Lisp code.  It is not necessary to visit the file first;
  671. in any case, this command reads the file as found on disk, not text in
  672. an Emacs buffer.
  673.    Once a file of Lisp code is installed in the Emacs Lisp library
  674. directories, users can load it using `M-x load-library'.  Programs can
  675. load it by calling `load-library', or with `load', a more primitive
  676. function that is similar but accepts some additional arguments.
  677.    `M-x load-library' differs from `M-x load-file' in that it searches
  678. a sequence of directories and tries three file names in each directory.
  679.  The three names are, first, the specified name with `.elc' appended;
  680. second, with `.el' appended; third, the specified name alone.  A `.elc'
  681. file would be the result of compiling the Lisp file into byte code; it
  682. is loaded if possible in preference to the Lisp file itself because the
  683. compiled file will load and run faster.
  684.    Because the argument to `load-library' is usually not in itself a
  685. valid file name, file name completion is not available.  Indeed, when
  686. using this command, you usually do not know exactly what file name will
  687. be used.
  688.    The sequence of directories searched by `M-x load-library' is
  689. specified by the variable `load-path', a list of strings that are
  690. directory names.  The default value of the list contains the directory
  691. where the Lisp code for Emacs itself is stored.  If you have libraries
  692. of your own, put them in a single directory and add that directory to
  693. `load-path'.  `nil' in this list stands for the current default
  694. directory, but it is probably not a good idea to put `nil' in the list.
  695.  If you find yourself wishing that `nil' were in the list, most likely
  696. what you really want to do is use `M-x load-file' this once.
  697.    Often you do not have to give any command to load a library, because
  698. the commands defined in the library are set up to "autoload" that
  699. library. Running any of those commands causes `load' to be called to
  700. load the library; this replaces the autoload definitions with the real
  701. ones from the library.
  702.    If autoloading a file does not finish, either because of an error or
  703. because of a `C-g' quit, all function definitions made by the file are
  704. undone automatically.  So are any calls to `provide'.  As a consequence,
  705. if you use one of the autoloadable commands again, the entire file will
  706. be loaded a second time.  This prevents problems where the command is no
  707. longer autoloading but it works wrong because not all the file was
  708. loaded. Function definitions are undone only for autoloading; explicit
  709. calls to `load' do not undo anything if loading is not completed.
  710. File: emacs,  Node: Compiling Libraries,  Next: Mocklisp,  Prev: Loading,  Up: Lisp Libraries
  711. Compiling Libraries
  712. -------------------
  713.    Emacs Lisp code can be compiled into byte-code which loads faster,
  714. takes up less space when loaded, and executes faster.
  715.    The way to make a byte-code compiled file from an Emacs-Lisp source
  716. file is with `M-x byte-compile-file'.  The default argument for this
  717. function is the file visited in the current buffer.  It reads the
  718. specified file, compiles it into byte code, and writes an output file
  719. whose name is made by appending `c' to the input file name.  Thus, the
  720. file `rmail.el' would be compiled into `rmail.elc'.
  721.    To recompile the changed Lisp files in a directory, use `M-x
  722. byte-recompile-directory'.  Specify just the directory name as an
  723. argument. Each `.el' file that has been byte-compiled before is
  724. byte-compiled again if it has changed since the previous compilation. 
  725. A numeric argument to this command tells it to offer to compile each
  726. `.el' file that has not already been compiled.  You must answer `y' or
  727. `n' to each offer.
  728.    Emacs can be invoked noninteractively from the shell to do byte
  729. compilation with the aid of the function `batch-byte-compile'.  In this
  730. case, the files to be compiled are specified with command-line
  731. arguments. Use a shell command of the form
  732.      emacs -batch -f batch-byte-compile FILES...
  733.    Directory names may also be given as arguments;
  734. `byte-recompile-directory' is invoked (in effect) on each such
  735. directory. `batch-byte-compile' uses all the remaining command-line
  736. arguments as file or directory names, then kills the Emacs process.
  737.    `M-x disassemble' explains the result of byte compilation.  Its
  738. argument is a function name.  It displays the byte-compiled code in a
  739. help window in symbolic form, one instruction per line.  If the
  740. instruction refers to a variable or constant, that is shown too.
  741. File: emacs,  Node: Mocklisp,  Prev: Compiling Libraries,  Up: Lisp Libraries
  742. Converting Mocklisp to Lisp
  743. ---------------------------
  744.    GNU Emacs can run Mocklisp files by converting them to Emacs Lisp
  745. first. To convert a Mocklisp file, visit it and then type `M-x
  746. convert-mocklisp-buffer'.  Then save the resulting buffer of Lisp file
  747. in a file whose name ends in `.el' and use the new file as a Lisp
  748. library.
  749.    It does not currently work to byte-compile converted Mocklisp code.
  750. This is because converted Mocklisp code uses some special Lisp features
  751. to deal with Mocklisp's incompatible ideas of how arguments are
  752. evaluated and which values signify "true" or "false".
  753. File: emacs,  Node: Lisp Eval,  Next: Lisp Debug,  Prev: Lisp Libraries,  Up: Running
  754. Evaluating Emacs-Lisp Expressions
  755. =================================
  756.    Lisp programs intended to be run in Emacs should be edited in
  757. Emacs-Lisp mode; this will happen automatically for file names ending
  758. in `.el'. By contrast, Lisp mode itself is used for editing Lisp
  759. programs intended for other Lisp systems.  Emacs-Lisp mode can be
  760. selected with the command `M-x emacs-lisp-mode'.
  761.    For testing of Lisp programs to run in Emacs, it is useful to be
  762. able to evaluate part of the program as it is found in the Emacs
  763. buffer.  For example, after changing the text of a Lisp function
  764. definition, evaluating the definition installs the change for future
  765. calls to the function. Evaluation of Lisp expressions is also useful in
  766. any kind of editing task for invoking noninteractive functions
  767. (functions that are not commands).
  768. `M-ESC'
  769.      Read a Lisp expression in the minibuffer, evaluate it, and print
  770.      the value in the minibuffer (`eval-expression').
  771. `C-x C-e'
  772.      Evaluate the Lisp expression before point, and print the value in
  773.      the minibuffer (`eval-last-sexp').
  774. `C-M-x'
  775.      Evaluate the defun containing or after point, and print the value
  776.      in the minibuffer (`eval-defun').
  777. `M-x eval-region'
  778.      Evaluate all the Lisp expressions in the region.
  779. `M-x eval-current-buffer'
  780.      Evaluate all the Lisp expressions in the buffer.
  781.    `M-ESC' (`eval-expression') is the most basic command for evaluating
  782. a Lisp expression interactively.  It reads the expression using the
  783. minibuffer, so you can execute any expression on a buffer regardless of
  784. what the buffer contains.  When the expression is evaluated, the current
  785. buffer is once again the buffer that was current when `M-ESC' was typed.
  786.    `M-ESC' can easily confuse users who do not understand it,
  787. especially on keyboards with autorepeat where it can result from holding
  788. down the ESC key for too long.  Therefore, `eval-expression' is
  789. normally a disabled command.  Attempting to use this command asks for
  790. confirmation and gives you the option of enabling it; once you enable
  791. the command, confirmation will no longer be required for it. *Note
  792. Disabling::.
  793.    In Emacs-Lisp mode, the key `C-M-x' is bound to the function
  794. `eval-defun', which parses the defun containing or following point as a
  795. Lisp expression and evaluates it.  The value is printed in the echo
  796. area.  This command is convenient for installing in the Lisp
  797. environment changes that you have just made in the text of a function
  798. definition.
  799.    The command `C-x C-e' (`eval-last-sexp') performs a similar job but
  800. is available in all major modes, not just Emacs-Lisp mode.  It finds
  801. the sexp before point, reads it as a Lisp expression, evaluates it, and
  802. prints the value in the echo area.  It is sometimes useful to type in an
  803. expression and then, with point still after it, type `C-x C-e'.
  804.    If `C-M-x' or `C-x C-e' is given a numeric argument, it prints the
  805. value by insertion into the current buffer at point, rather than in the
  806. echo area.  The argument value does not matter.
  807.    The most general command for evaluating Lisp expressions from a
  808. buffer is `eval-region'.  `M-x eval-region' parses the text of the
  809. region as one or more Lisp expressions, evaluating them one by one. 
  810. `M-x eval-current-buffer' is similar but evaluates the entire buffer. 
  811. This is a reasonable way to install the contents of a file of Lisp code
  812. that you are just ready to test.  After finding and fixing a bug, use
  813. `C-M-x' on each function that you change, to keep the Lisp world in
  814. step with the source file.
  815.