home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / emacs.i08 < prev    next >
Encoding:
GNU Info File  |  1993-06-14  |  46.0 KB  |  1,080 lines

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