home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / misc / e1858src.lha / emacs-18.58 / info / emacs-8 < prev    next >
Encoding:
GNU Info File  |  1992-02-21  |  45.0 KB  |  1,089 lines

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