home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / modes / math / math-mode < prev    next >
Encoding:
Text File  |  1990-03-20  |  33.5 KB  |  912 lines

  1. Info file: math-mode,    -*-Text-*-
  2. produced by texinfo-format-buffer
  3. from file: math-mode.texinfo
  4.  
  5.  
  6.  
  7. 
  8. File: math-mode  Node: Top, Prev: (dir), Up: (dir), Next: Math-mode
  9.  
  10.  
  11. This documents version 1.0 of math-mode.
  12.  
  13. Math-mode is a GNU Emacs major mode that serves as an interface to
  14. Mathematica.  It has commands to send expressions to Mathematica for
  15. evaluation.  Math-mode is an outline editor as well, similar to the
  16. Macintosh interface to Mathematica.  The buffer that one edits in
  17. math-mode is called a "notebook".  Mathematica notebooks created on the
  18. Macintosh can be translated automatically into Emacs math-mode
  19. notebooks, and vice versa.
  20.  
  21. This document assumes familiarity with GNU Emacs terminology.  You
  22. should first become familiar with it by reading from the beginning of
  23. the GNU Emacs Manual and trying the GNU Emacs tutorial (`C-h t').
  24.  
  25. This document also assumes familiarity with Mathematica concepts.
  26.  
  27. * Menu:
  28.  
  29. * Math-mode::    
  30. * Tutorial::    
  31. * Installing math-mode::    
  32. * Setting up math-mode::    
  33. * Notebook Structure::    
  34.  
  35. * Using math-mode::    
  36. * Starting math-mode::  
  37. * Commands to Move Between Cells.::     
  38. * Commands to Modify Cell Attributes.:: 
  39. * Commands to Create and Delete cells.::        
  40. * Commands to Communicate with Mathematica.::   
  41. * Indentation:: 
  42. * Evaluation::  
  43. * Math-mode syntax::    
  44. * Variables::   
  45.  
  46. 
  47. File: math-mode  Node: Math-mode, Up: Top, Next: Using math-mode
  48.  
  49. Math-mode
  50. *********
  51.  
  52. * Menu:
  53.  
  54. * Tutorial::    
  55. * Installing math-mode::        
  56. * Setting up math-mode::        
  57. * Notebook Structure::  
  58.  
  59. 
  60. File: math-mode  Node: Tutorial, Up: Math-mode, Next: Installing math-mode
  61.  
  62. Tutorial
  63. ========
  64.  
  65. First, start GNU Emacs and arrange that the math-mode library is loaded
  66. (see following sections if this is confusing).  Now execute `math' with
  67. `M-x `math''.  A buffer called `math' is created and the point should be
  68. positioned after the first cell label (`->').  At this point, you can
  69. simply type in an expression that you wish Mathematica to evaluate.
  70. When you are ready to evaluate the expression, enter `C-j' or `LFD'.
  71. Math-mode will then insert cells that represent the result of the
  72. evaluation.  In the example below, the expression `2 + 2' is entered.
  73. The result and another input prompt are inserted.
  74.  
  75.      In[1]:= 2 + 2
  76.  
  77.      Out[1]= 4
  78.  
  79.      In[2]:= 
  80.  
  81. Although the above example does not show it, the input and output cells
  82. are grouped with the input cell as the head of the group.  You can see
  83. the group structure by using the command `C-cC-l'.  Do this now.  Cell
  84. names (e.g., `In[1]:= ') will be preceded by either a start of group
  85. indicator of the form `=>' or a regular cell indicator of the form `->'.
  86. The `>' is repeated to correspond to the depth of the cell in the group
  87. hierarchy.
  88.  
  89. In the following example, the group structure is displayed (by using the
  90. command `C-cC-l'), and the expressions listed on input cells 2 and 3 are
  91. entered.  Notice that *messages* that result from the evaluation also
  92. occupy cells in the group.
  93.  
  94.      => In[1]:= 2 + 2
  95.  
  96.      ->> Out[1]= 4
  97.  
  98.      => In[2]:= f::overflow = "Factorial too large."
  99.  
  100.      ->> Out[2]= Factorial too large.
  101.  
  102.      -> In[3]:= f[x_Integer] :=
  103.                   If[x>10, Message[f::overflow]; Infinity, x!]
  104.  
  105.      => In[3]:= f[20]
  106.  
  107.      ->> f::overflow: Factorial too large.
  108.  
  109.      ->> Out[3]= Infinity
  110.  
  111.      -> In[4]:= 
  112.  
  113. If you follow this example, you should be positioned after the cell
  114. labeled `In[4]'.  Move back up to `In[3]' (notice it has the same label
  115. as the previous input cell - this is a Mathematica bug) by using the
  116. command `C-cC-b' then hide the group contents with `C-cC-c'.  Show the
  117. contents again with another `C-cC-c'.  Then move to the `f::overflow'
  118. cell with `C-cC-n' and hide that cell with `C-cC-c'.  Notice that
  119. `f::overflow' is part of the label that remains displayed.
  120.  
  121. Next move back to the cell labeled `In[3]' with `C-cC-u' and change `20'
  122. to `5'.  Reevaluate this cell with `C-j' (you may be positioned anywhere
  123. within the cell) and notice that the previous output cells in the group
  124. are replaced with the result of evaluating this new expression as shown
  125. in the following.
  126.  
  127.      => In[4]:= f[5]
  128.  
  129.      ->> Out[4]= 120
  130.  
  131.      -> In[5]:= 
  132.  
  133.  
  134. 
  135. File: math-mode  Node: Installing math-mode, Prev: Tutorial, Up: Math-mode, Next: Setting up math-mode
  136.  
  137. Installing math-mode
  138. ====================
  139.  
  140. The math-mode code actually consists of two Emacs Lisp files and three
  141. executable files.  The Emacs Lisp files, `math-mode.el' and
  142. `mathtalk.el', should be installed and byte-compiled in a directory that
  143. is listed in Emacs users' `load-path' variable.  The executable files,
  144. `emacsfrontend', `macnb2nbl', and `mathremote.emacs', should be
  145. installed in a directory that is listed in the users' shell environment
  146. variable PATH.
  147.  
  148. Note: The Emacs Lisp code should be byte-compiled (by using
  149. `byte-recompile-directory').  It is important to byte-compile
  150. `math-mode.el' because the code makes heavy use of macros and would be
  151. very slow without byte-compilation.
  152.  
  153.  
  154. 
  155. File: math-mode  Node: Setting up math-mode, Prev: Installing math-mode, Up: Math-mode, Next: Notebook Structure
  156.  
  157. Setting up math-mode
  158. ====================
  159.  
  160. To use math-mode conveniently, include the following in your .emacs
  161. file:
  162.  
  163.      (setq load-path (cons <math-mode.el directory>
  164.                        load-path))
  165.  
  166.      (setq auto-mode-alist (append
  167.                             (list
  168.                              (cons "\\.m$" 'math-mode)  ; packages
  169.                              (cons "\\.nb$" 'math-mode) ; mac notebooks
  170.                              (cons "\\.nbl$" 'math-mode)) ; math-mode notebooks
  171.                              auto-mode-alist))
  172.  
  173.      (autoload 'math "math-mode" "Create a new math-mode buffer." t)
  174.      (autoload 'math-mode "math-mode" "Start up math-mode for a file.")
  175.  
  176. You can also include a `math-mode-hook' such as the following:
  177.  
  178.      (setq math-mode-hook
  179.            (function (lambda ()
  180.                        (setq math-show-debug t)
  181.                        (define-key math-mode-map "\C-c\C-g" 'math-group-region)
  182.                        ;; more key bindings or other variable settings
  183.                        )))
  184.  
  185.  
  186.  
  187. 
  188. File: math-mode  Node: Notebook Structure, Prev: Setting up math-mode, Up: Math-mode
  189.  
  190. Notebook Structure
  191. ==================
  192.  
  193. Each component of a math-mode notebook is called a "cell".  Two or more
  194. cells may be grouped hierarchically.  The first cell in a "group" is
  195. called the start of the group or the "head" cell and all other cells are
  196. called "group members".  Note that each cell can be the start of only
  197. one group, but a cell that does not start a group may be the last cell
  198. of several groups.  Here is an example of a group with another group
  199. nested inside it.
  200.  
  201.      => Start of outer group
  202.  
  203.      ->> first member of outer group
  204.  
  205.      =>> Start of inner group
  206.  
  207.      ->>> first member of inner group and end of both groups
  208.  
  209.      -> cell after groups
  210.  
  211. In addition to the group structure, each cell has a number of other
  212. "attributes" associated with it that constrain which commands can be
  213. applied to the cell and what they do.  These attributes include whether
  214. a cell is displayed, whether it may be modified, and whether it may be
  215. evaluated.
  216.  
  217. * Menu:
  218.  
  219. * Cell Labels:: 
  220. * Open and Closed Cells::       
  221. * The Current Cell::    
  222.  
  223.  
  224. 
  225. File: math-mode  Node: Cell Labels, Up: Notebook Structure, Next: Open and Closed Cells
  226.  
  227. Cell Labels
  228. -----------
  229.  
  230. Every cell has a "label".  If a name for the cell is provided by
  231. Mathematica, such as an input prompt or output prompt, that is used as
  232. the label.  Otherwise, a default label is created that indicates whether
  233. a cell is the start of a group and how deeply nested the cell is in the
  234. group structure.
  235.  
  236. The default label for a start of group cell is of the form `=>'.  Other
  237. cells have a default label of the form `->'. The `>' is repeated to
  238. indicate the depth the cell is at.  Look at the example above again to
  239. see how the cells are labeled.  Notice that the members of a group are
  240. one level deeper than the starting cell.
  241.  
  242. Warning: You should never edit the cell label directly, especially the
  243. second character of the label (where a mark points).  Math-mode attempts
  244. to prevent user modification of cell labels by watching most text
  245. insertions and deletions.  But replacements and some other commands are
  246. not similarly watched.  If you accidently modify the text of a label,
  247. however, you should be able to safely undo the action, provided you do
  248. it before using a math-mode command.  Since the undo command can undo
  249. changes to the text of labels, legitimate or not, the undo record is
  250. cleared after each math-mode command that modifies cell labels.
  251.  
  252. Another Warning: Also, don't put text at the beginning of any line that
  253. looks like a cell label because math-mode will become confused by the
  254. apparent existence of a cell that it doesn't know about.  One way this
  255. might occur is if you copy a text region that includes cell labels and
  256. yank it into the contents of a cell.
  257.  
  258.  
  259. 
  260. File: math-mode  Node: Open and Closed Cells, Prev: Cell Labels, Up: Notebook Structure, Next: The Current Cell
  261.  
  262. Open and Closed Cells
  263. ---------------------
  264.  
  265. Since notebooks may be become rather large and complex, it is useful to
  266. be able to hide portions of it.  Each cell may be open or closed.  An
  267. "open" cell (that is not the start of a group) is displayed, whereas a
  268. "closed" cell is hidden except for its label.  The text that is hidden
  269. is replaced by the string `...'.  (Warning: The `...' characters
  270. themselves may not be edited, but the text that they represent *may* be
  271. edited, so be careful around `...'.)
  272.  
  273. An open group is displayed by showing the start of the group and showing
  274. or hiding each of its group members depending on whether each is open or
  275. closed.  A closed group is displayed by also showing the cell that
  276. starts the group, but all of the group members are replaced with a
  277. single `...' regardless of whether they are open or closed.  The
  278. following example shows the same group as the earlier example but with
  279. the first member of the outer group closed and the inner group also
  280. closed.
  281.  
  282.      => Start of outer group
  283.  
  284.      ->>  ...
  285.  
  286.      =>> Start of inner group
  287.       ...
  288.  
  289.      -> cell after groups
  290.  
  291.  
  292. 
  293. File: math-mode  Node: The Current Cell, Prev: Open and Closed Cells, Up: Notebook Structure
  294.  
  295. The Current Cell
  296. ----------------
  297.  
  298. The "current cell" is the cell that contains the point.  Some commands
  299. behave differently depending on whether the current cell is the start of
  300. a group or a normal cell.  The boundaries of a cell extend from the
  301. beginning of its label to just before the beginning of the next label.
  302.  
  303. If the point is positioned within a cell that is not the start of a
  304. group, then the command applies to just that cell.  If the point is
  305. positioned within a cell that *is* the start of a group, then the
  306. command applies to the whole group.  If the point is positioned within a
  307. closed group, the cell that starts the closed group is the current cell
  308. rather than whatever hidden cell the point may actually be positioned
  309. within.  (Currently, no editing is allowed *before* the first cell.)
  310.  
  311.  
  312. 
  313. File: math-mode  Node: Using math-mode, Prev: Math-mode, Up: Top
  314.  
  315. Using math-mode
  316. ***************
  317.  
  318.  
  319. Several interactive commands are provided in math-mode, most with
  320. default key bindings.  The full set of commands described here is also
  321. displayed with the `describe-mode' command (`C-h m').
  322.  
  323. In the following sections, commands are described that start up
  324. math-mode, create and modify cells, move between cells, and interact
  325. with Mathematica.
  326.  
  327. * Menu:
  328.  
  329. * Starting math-mode::  
  330. * Commands to Move Between Cells.::     
  331. * Commands to Modify Cell Attributes.:: 
  332. * Commands to Create and Delete cells.::        
  333. * Commands to Communicate with Mathematica.::   
  334. * Indentation:: 
  335. * Evaluation::  
  336. * Math-mode syntax::    
  337. * Variables::   
  338.  
  339.  
  340. 
  341. File: math-mode  Node: Starting math-mode, Up: Using math-mode, Next: Commands to Move Between Cells.
  342.  
  343. Starting math-mode
  344. ==================
  345.  
  346. Once you have set up math-mode as described in the previous chapter
  347. (*Note Setting up math-mode::), execute ``M-x' `math'' to start up
  348. math-mode in a buffer called `math'.  Subsequent calls to `math' will
  349. find that same buffer.  This buffer does not have a file associated with
  350. it, so when you quit from emacs, you will not be asked to save it.
  351.  
  352. You can also start up math-mode simply by visiting a file that has a
  353. `.m', `.nb' or `.nbl' suffix.  Whichever one you initially visit, if
  354. there is a newer file with the same basename that has a different
  355. suffix, you will be asked if you would rather use the newer file.
  356.  
  357. If you edit a file with `.m' suffix, it is assumed that the file is a
  358. Mathematica package file that should be converted; this is done for you
  359. and a buffer for editing the corresponding `.nbl' file is created for
  360. you.  Similarly, if you edit a file with `.nb' suffix, it is assumed
  361. that the file is a Macintosh notebook that should be converted; this is
  362. done for you (using `macnb2nbl') and a buffer for editing the `.nbl'
  363. file is created for you.  Because of this conversion, you never actually
  364. edit a `.m' or `.nb' file.  No matter which of the three kinds of files
  365. you initially edit, you will instead edit a file with `.nbl' suffix.
  366.  
  367. Notice, you never call the function `math-mode' yourself, unlike other
  368. major modes.  A math-mode notebook file (one with `.nbl' suffix)
  369. contains extra information at the end of the file which is used to
  370. remember the structure of the notebook and attributes of cells.  This
  371. extra information must be processed and striped off; this is done by
  372. math-mode when you first visit the file.
  373.  
  374. Warning: Never directly edit a math-mode file (one that has `.nbl'
  375. suffix) with another editor or try to defeat the math-mode conversion
  376. because the position of every character in the file is critical.
  377. Although it is a text file, treat it as a binary file.  However, you may
  378. safely edit a `.m' or `.nb' file as plain text.
  379.  
  380. Only one Mathematica process can be associated with each Emacs process.
  381. But more than one math-mode buffer may be active at a time.  Mathematica
  382. does not know which buffer you are editing, so cell numbers are provided
  383. consecutively across all buffers.
  384.  
  385. The following commands are associated with starting up math-mode, saving
  386. notebooks, and terminating Mathematica.
  387.  
  388. `M-x `math''
  389.      Start up math-mode in a buffer without a file.  Currently, only one
  390.      of these buffers is supported.  If you call `math' again, you will
  391.      be popped to that buffer.  However, if you rename this buffer, you
  392.      can start another math buffer with another call to `math'.
  393.  
  394. `C-x C-f'
  395.      Find a file (with this or another Emacs find-file command) that has
  396.      `.m', `.nb' or `.nbl' suffix.  Any necessary conversion will be
  397.      done and math-mode will be started on the buffer.
  398.  
  399. `C-x C-s'
  400.      Save a buffer (with this or other Emacs save command) that is in
  401.      math-mode.  The file is saved in math-mode notebook format.  Use
  402.      `C-c W' to save the file in Macintosh notebook format.
  403.  
  404. `C-c M'
  405.      `write-math-mac-notebook' saves a buffer that is in math-mode as a
  406.      Macintosh notebook file with a `.nb' suffix.  This file may be
  407.      transfered to a Macintosh for use there, or read into Mathematica
  408.      using the `<<' command.
  409.  
  410. `C-c P'
  411.      `write-math-package' saves a buffer that is in math-mode as a
  412.      Mathematica package format file with a `.m' suffix.  Every cell
  413.      that is not an input cell is enclosed in comments (`(* ... *)').
  414.  
  415. `C-c K'
  416.      `kill-math' kills the Mathematica process.  You will be asked if
  417.      you really wish to do this.  Any math-mode buffers will remain
  418.      active, and any evaluation of Mathematica expressions will cause a
  419.      new Mathematica process to start up automatically.  It is not
  420.      necessary to kill Mathematica before terminating your Emacs
  421.      session.  But it may be convenient if you wish to start up a new
  422.      Mathematica process from scratch.
  423.  
  424.  
  425.  
  426. 
  427. File: math-mode  Node: Commands to Move Between Cells., Prev: Starting math-mode, Up: Using math-mode, Next: Commands to Modify Cell Attributes.
  428.  
  429. Commands to Move Between Cells.
  430. ===============================
  431.  
  432. Each of the movement commands first determines which cell the point is
  433. positioned within.  *Note The Current Cell:: for a description of how
  434. the current cell is determined.  The movement commands then move
  435. relative to the current cell.
  436.  
  437. `C-c C-n'
  438.      `math-next-cell' moves to the next cell irrespective of the group
  439.      structure.  If the next cell is not visible (hidden) then try to
  440.      move to the forward cell.
  441.  
  442. `C-c C-p'
  443.      `math-previous-cell' moves to the previous cell irrespective of the
  444.      group structure.
  445.  
  446. `C-c C-u'
  447.      `math-parent-cell' moves to the parent cell.  Every cell has a
  448.      parent except top level cells.
  449.  
  450. `C-c C-f'
  451.      `math-forward-cell' moves to the next cell at the same level as the
  452.      current cell and within the same group.  The last cell in a group
  453.      has no forward-cell.
  454.  
  455. `C-c C-b'
  456.      `math-backward-cell' moves to the previous cell at the same level
  457.      as the current cell and within the same group.  The first cell in a
  458.      group after the startgroup cell has no backward-cell.
  459.  
  460.  
  461.  
  462.  
  463.  
  464. 
  465. File: math-mode  Node: Commands to Modify Cell Attributes., Prev: Commands to Move Between Cells., Up: Using math-mode, Next: Commands to Create and Delete cells.
  466.  
  467. Commands to Modify Cell Attributes.
  468. ===================================
  469.  
  470. The following commands modify the attributes of cells.  Some of the
  471. attributes show up visibly in the display of the cells, such as whether
  472. a cell is the start of a group, and whether it is open or closed.  Other
  473. attributes are hidden.
  474.  
  475.  
  476. `C-c C-c'
  477.      `math-toggle-close-cell' toggles whether the current cell or group
  478.      is open or closed.  If the current cell is closed, it will be
  479.      opened, and vice versa.  *Note Notebook Structure:: for a
  480.      description of how closed cells and groups are displayed.
  481.  
  482. `C-c A'
  483.      `math-toggle-active' asks whether to toggle active attribute of
  484.      current cell.  This attribute determines whether a cell can be
  485.      evaluated.  Ordinarily, cells containing text meant to be evaluated
  486.      as Mathematica expressions are active, and cells containing
  487.      explanatory text or titles are inactive.  Output from Mathematica
  488.      is usually inactive.
  489.  
  490. `C-c I'
  491.      `math-toggle-initialization' asks whether to toggle the
  492.      initialization attribute of the current cell.  Ordinarily, when you
  493.      visit a notebook, math-mode asks if you want to automatically
  494.      evaluate all the initialization cells.  If you want the initial
  495.      evaluation to occur without asking, set the variable
  496.      `math-eval-init-cells' to `t'.
  497.         
  498.      When you use the Mathematica command `<<filename' to read in and
  499.      evaluate a notebook file, only cells marked as active
  500.      initialization cells are evaluated.
  501.  
  502. `C-c F'
  503.      `math-set-style' asks for the style of the current cell.  Only
  504.      cells with style `input' are indented automatically by math-mode.
  505.      The input cells inserted automatically after an evaluation have the
  506.      `input' style.  Many more style attributes are possible than are
  507.      useful.  This is to support attributes used in the Macintosh
  508.      interface to Mathematica.
  509.  
  510. `C-c U'
  511.      `math-toggle-autoActive' asks whether to toggle autoActive
  512.      attribute of current cell.  The current cell must be an active cell
  513.      that is the start of a group.  This attribute determines whether a
  514.      cell is automatically evaluated everytime some cell in its group is
  515.      evaluated.  It is only evaluted once for evaluation pass.  This
  516.      might be useful to perform some initialization before a cell is
  517.      evaluated.
  518.  
  519. `C-c C-o'
  520.      `math-toggle-cell-output' toggles whether the current cell displays
  521.      the input or output form.  By default, the output form of an
  522.      evaluation result is used.  The input form may be edited and
  523.      evaluated.
  524.  
  525. `C-c C-l'
  526.      `math-toggle-structure-labels' toggles whether the group structure
  527.      is shown in cell labels, even for cells that have a name provided
  528.      by Mathematica.  When this command is used, all cell labels will be
  529.      updated.  *Note Notebook Structure::for a description of how the
  530.      group structure is displayed.
  531.  
  532. `C-c g'
  533.      `math-group-region' groups the cells within the region between mark
  534.      and point.  The region is expanded so that all cells that are
  535.      within the enclosing group common between mark and point are
  536.      grouped.  The first cell in the expanded region becomes the group
  537.      head, if it is not already a group head.  But if the first cell is
  538.      already a group head, a new cell is inserted before that to serve
  539.      as the group head.
  540.  
  541. `C-c G'
  542.      `math-ungroup-current-group' ungroups the cells of the smallest
  543.      group that contains point.  As a result, the head cell of that
  544.      group and all cells at the top level become group members of the
  545.      parent of the group.
  546.  
  547. `C-c C-s'
  548.      `math-split-group' splits the current group by dropping the current
  549.      cell and all following cells in the group to the next lower level.
  550.      If you split off the last remaining member of a group, the head of
  551.      the group becomes a normal cell.  You cannot split at the top
  552.      level.
  553.  
  554. `C-c C-j'
  555.      `math-join-cell' joins the current cell with the previous group, or
  556.      if the previous cell is not the end of a group, create a group from
  557.      the previous cell and the current cell.  Note that cells following
  558.      the current cell are not included in the join.  You cannot join
  559.      with a previous cell that is the start of a group.
  560.  
  561. `C-c C-@'
  562.      `math-mark-current-cell' puts mark at the end of the current cell
  563.      contents and point at the beginning.  Use this followed by `M-w'
  564.      (`copy-region-as-kill') to later yank the text back with `C-y'.
  565.      Your terminal may send `C-@' for `C-SHIFT'.
  566.  
  567. `C-c c'
  568.      `math-copy-backward-cell' inserts a copy of the contents of the
  569.      previous cell at the same level as this cell into the current cell.
  570.      This is often the previous input cell.
  571.  
  572.  
  573.  
  574. 
  575. File: math-mode  Node: Commands to Create and Delete cells., Prev: Commands to Modify Cell Attributes., Up: Using math-mode, Next: Commands to Communicate with Mathematica.
  576.  
  577. Commands to Create and Delete cells.
  578. ====================================
  579.  
  580. The following commands that create or delete cells.  In addition,
  581. commands that evaluate cells, described in the next section, use these
  582. commands to create or delete cells.
  583.  
  584.  
  585. `C-c C-i'
  586.      `math-insert-new-text-cell' creates and inserts a text cell after
  587.      the cell at point.  If you insert after the head cell in a group,
  588.      the cell is inserted before the first member of the group - and it
  589.      then becomes the new first member of the group.  If you insert
  590.      after the last cell in a group, the new cell becomes the new last
  591.      cell of the group.  (Use `C-c C-s' to split this cell off the
  592.      group.)  With prefix argument, insert before the current cell
  593.      instead of after.  This command is not used often if you simply
  594.      evaluate cells in succession since each evaluation creates a new
  595.      input cell.
  596.  
  597. `C-c C-k'
  598.      `math-kill-current-cell' kills the current cell or group.  The
  599.      killed cell or group of cells is removed from the notebook and may
  600.      be yanked back in the same place or a different place with
  601.      `math-yank-killed-cells'.  If you kill the head cell of a group,
  602.      the whole group is killed.  If you kill the last remaining member
  603.      of a group, the head cell of the group becomes a normal cell.
  604.  
  605. `C-c C-w'
  606.      `math-set-current-cell-as-kill' does not kill a cell, but allows
  607.      you to yank a copy of it somewhere else.
  608.  
  609. `C-c C-y'
  610.      `math-yank-killed-cells' yanks the last killed cell or group as an
  611.      insertion before or after the current cell.  See
  612.      `math-insert-new-text-cell' for a description of how insertions are
  613.      done. With prefix argument, insert before.  An implementation
  614.      restriction is that killed cells can only be yanked once.  Thus, no
  615.      way is provided to duplicate cells other than by copying the text
  616.      of cell contents.
  617.  
  618.  
  619.  
  620. 
  621. File: math-mode  Node: Commands to Communicate with Mathematica., Prev: Commands to Create and Delete cells., Up: Using math-mode, Next: Indentation
  622.  
  623. Commands to Communicate with Mathematica.
  624. =========================================
  625.  
  626. `C-j'
  627.      (`math-eval-current-cell') Evaluate the current cell by sending it
  628.      to Mathematica.  Any `autoActive' cells are also evaluated.  For
  629.      each evaluated cell, the result of the evaluation is inserted
  630.      following the cell and the input and all output cells are grouped.
  631.      If the input cell was already the start of a group, then all
  632.      following output cells of that group are replaced by the evaluation
  633.      results.  Several other things can happen while Mathematica is
  634.      evaluating expressions such as requests for input, and interrupt
  635.      and debug modes.  These are described below (*Note Evaluation::).
  636.  
  637. `C-c c'
  638.      (`math-complete-symbol') Perform completion on the symbol preceding
  639.      point.  That symbol is sent to Mathematica where it is compared
  640.      against all symbols that are currently defined.  If there is only
  641.      one possible extension of the symbol, even if it does not complete
  642.      the symbol, then that extension is applied by inserting the
  643.      additional characters.  If there is more than one possible
  644.      extension, then all possible completion symbols are temporarily
  645.      displayed in a *Completions* buffer.
  646.  
  647.  
  648.  
  649. 
  650. File: math-mode  Node: Indentation, Prev: Commands to Communicate with Mathematica., Up: Using math-mode, Next: Evaluation
  651.  
  652. Indentation
  653. ===========
  654.  
  655. When the following indenting commands are used within cells that use the
  656. input font (as active cells do), context sensative indenting is
  657. performed.  In other cells, `C-m' merely starts a new line and `TAB'
  658. inserts a tab.
  659.  
  660. The indenting philosophy followed by math-mode, as well as most other
  661. Emacs major modes that do indenting, is that the user should be allowed
  662. to break lines wherever desired, but each broken line may be
  663. automatically indented relative to previous lines.
  664.  
  665. A line that is a continuation of an expression is indented two columns
  666. past the start of the expression.  A line that is preceded by an
  667. expression ending with `;' is indented to the start of the first
  668. expression in the semi-colon separate list plus two (not yet!!).  A line
  669. that is preceded by an expression ending with `,' is indented to the
  670. start of the first expression in the comma separated list, unless it is
  671. a `[]' list.
  672.  
  673. Comma separated lists within square brackets are handled specially
  674. because another indenting style is desirable for this common case.  For
  675. most such lists, each top-level expression in the list is indented two
  676. columns past the start of the head of the list (the name before the
  677. square brackets).
  678.  
  679. The head of the list may be recognized as the name of a contruct with
  680. special indenting requirements.  For such a name, the Emacs Lisp symbol
  681. with the same name will have a `math-indent-hook' property in its
  682. property list with the number of distinguished expressions.  Each
  683. expression in the list numbered less than or equal to this number of
  684. distinguished expressions (starting with 1) is indented four columns
  685. past the start of the head instead.  The rest are indented two columns
  686. past the start of the head.  This is similar to Lisp style indenting in
  687. Emacs.
  688.  
  689.      -> Median[list_List] :=
  690.           Block[{s1,len},
  691.             len = Length[list];
  692.               s1 = Sort[list];
  693.             If[OddQ[Length[s1]],
  694.                 s1[[len/2]],
  695.               (s1[[len/2]]
  696.                  + s1[[len/2+1]]) / 2
  697.                 ]]
  698.  
  699. Mathematica comments are indented to the same column as the next
  700. non-comment line would be.  An exception is if the comment starts with
  701. an extra `*'; in this case the comment is shifted to the beginning of
  702. line.
  703.  
  704. `C-m'
  705.      `math-newline-and-indent' breaks the line and indents the remainder
  706.      of the line as appropriate.
  707.  
  708. `\t'
  709.      `math-maybe-indent-command' reindents the current line, no matter
  710.      where the point is in the line.
  711.  
  712. `M-C-q'
  713.      `math-indent-exp' reindents every line of the expression starting
  714.      on the current line relative to this line.  Use TAB first to ensure
  715.      that the first line is indented properly.
  716.  
  717.  
  718.  
  719. 
  720. File: math-mode  Node: Evaluation, Prev: Indentation, Up: Using math-mode, Next: Math-mode syntax
  721.  
  722. Evaluation
  723. ==========
  724.  
  725. When Mathematica is evaluating expressions, it may evaluate one of the
  726. functions that cause special actions.  These functions are Input,
  727. InputString, and Debug.  You may also interrupt the evaluation in
  728. progress with the `C-g' command.  The interaction that occurs for each
  729. of these is described in the following sections.
  730.  
  731. * Menu:
  732.  
  733. * Input::       
  734. * Debug::       
  735. * Interrupts::  
  736.  
  737. 
  738. File: math-mode  Node: Input, Up: Evaluation, Next: Debug
  739.  
  740. Input
  741. -----
  742.  
  743. When either the Input or InputString function is evaluated by
  744. Mathematica, you are requested to enter an expression or string in the
  745. minibuffer.  You can simply type in the expression, or switch to another
  746. buffer to copy the desired string and switch back to yank it in.
  747. Warning: Be careful while visiting other buffers not to exit to the
  748. top-level of Emacs since this will cause the input request to be
  749. aborted.  (This could happen, for example, by entering the debugger and
  750. using the "q" command to quit debugging and return to the top-level.)
  751.  
  752. If the expression that you enter in response to the Input function call
  753. contains a syntax error, a message to that effect will be flashed for
  754. one second and the input request is repeated with the erroneous text as
  755. the initial value of your input.
  756.  
  757.  
  758. 
  759. File: math-mode  Node: Debug, Prev: Input, Up: Evaluation, Next: Interrupts
  760.  
  761. Debug
  762. -----
  763.  
  764. When the Debug function is evaluated by Mathematica, the first argument
  765. in the Debug call is displayed in a buffer and a menu of choices appears
  766. in the minibuffer.  The choices are Step, Next, Continue, Finish, and
  767. Abort.  The meanings of these are described in the Mathematica book.
  768. You should enter the first letter of one of the choices in lower case.
  769. When Mathematica receives your response, if another expression is to be
  770. displayed, it is appended to the previous display.  While in the Debug
  771. menu, you are not permitted to do any other editing.
  772.  
  773.  
  774. 
  775. File: math-mode  Node: Interrupts, Prev: Debug, Up: Evaluation
  776.  
  777. Interrupts
  778. ----------
  779.  
  780. While Mathematica is evaluating something, the message "Waiting for
  781. Mathematica..." will appear in the minibuffer.  You may interrupt the
  782. evaluation by entering `C-g' (or whatever your `quit-char' is).  A menu
  783. of choices appears in the minibuffer.  The choices are Abort, Continue,
  784. One-step, or Quit.  As for Debug, you should enter the first letter of
  785. one of these choices.
  786.  
  787. Abort will abort the evaluation immediately, but any subsequent
  788. evaluations will still be started (is this a bug??).  Continue will
  789. continue the evaluation as if the interrupt had not occurred.  For
  790. One-step, the next expression to be evaluated is displayed in a buffer
  791. called `*math-output*' and then the menu of choices will be displayed
  792. again.  Subsequent One-step output will be appended to this buffer.  For
  793. Quit, you will be asked if you want to quit from Mathematica entirely.
  794. This does not quit from the Emacs session, however.
  795.  
  796.  
  797. 
  798. File: math-mode  Node: Math-mode syntax, Prev: Evaluation, Up: Using math-mode, Next: Variables
  799.  
  800. Math-mode syntax
  801. ================
  802.  
  803. All characters except those listed below are symbol characters.
  804.  
  805. space tab and newline
  806.      are whitespace
  807.  
  808. `[' 
  809.      matches `]'
  810.  
  811. `{' 
  812.      matches `}'
  813.  
  814. `(' 
  815.      matches `)' and starts a comment
  816.  
  817. `)' 
  818.      matches `(' and ends a comment
  819.  
  820. `*'
  821.      is punctuation and is part of a comment start or end
  822.  
  823. `+ - = < > | ' , . ; : ? @ ^ &'
  824.      are punctuation characters
  825.  
  826. `"' 
  827.      is a quote character
  828.  
  829. `~'
  830.      is a symbol character
  831.  
  832. `` _ # $ %'
  833.      are prefix characters
  834.  
  835. `\'
  836.      is an escape character within strings, but is ignored unless
  837.      followed by b, e, f, n, r, t, or three octal digits.
  838.  
  839.  
  840.  
  841. 
  842. File: math-mode  Node: Variables, Prev: Math-mode syntax, Up: Using math-mode
  843.  
  844. Variables
  845. =========
  846.  
  847. Several variables and constants are provided for customization.
  848.  
  849.  
  850. `math-path'
  851.      The absolute or relative path to the mathremote.emacs shell script
  852.      that runs Mathematica via Mathtalk.  Set it in your
  853.      `math-mode-hook'.  (This constant will be changed it to a var.)
  854.      Default is `"mathremote.emacs"'.
  855.  
  856. `math-macnb2nbl'
  857.      This constant holds the name of the program to convert macintosh
  858.      notebooks to nbl form.  Default is `"macnb2nbl"'.
  859.  
  860. `math-eval-init-cells'
  861.      The value is `nil' if math-mode should never evaluate
  862.      initialization cells; `t' if it should always evaluate without
  863.      asking.  Otherwise ask.  Default is `ask'.
  864.  
  865. `math-use-structure-labels'
  866.      If non-`nil', then include in the label the cell structure
  867.      indicator.  Default is `nil'.
  868.  
  869. `math-mode-map'
  870.      This is the keymap used by math-mode.  You can set entries with
  871.      `(define-key math-mode-map "key" 'function)'.
  872.  
  873. `math-mode-syntax-table'
  874.      This is the syntax table used by math-mode.  There is probably no
  875.      need for you to modify it.
  876.  
  877. `math-buffer-name'
  878.      This constant holds the name of the buffer for doing math in when
  879.      not associated with a file.  Default is "math".
  880.  
  881. `math-show-debug '
  882.      If non-`nil', show the communication between math-mode and
  883.      Mathematica.  Default is `nil'.
  884.  
  885.  
  886. 
  887. Tag table:
  888. Node: Top105
  889. Node: Math-mode1341
  890. Node: Tutorial1548
  891. Node: Installing math-mode4183
  892. Node: Setting up math-mode4990
  893. Node: Notebook Structure6141
  894. Node: Cell Labels7277
  895. Node: Open and Closed Cells8966
  896. Node: The Current Cell10192
  897. Node: Using math-mode11095
  898. Node: Starting math-mode11833
  899. Node: Commands to Move Between Cells.15946
  900. Node: Commands to Modify Cell Attributes.17199
  901. Node: Commands to Create and Delete cells.22105
  902. Node: Commands to Communicate with Mathematica.24181
  903. Node: Indentation25590
  904. Node: Evaluation28414
  905. Node: Input28923
  906. Node: Debug29793
  907. Node: Interrupts30438
  908. Node: Math-mode syntax31441
  909. Node: Variables32178
  910. 
  911. End tag table
  912.