Gri: Emacs editing mode

- Gri Extras 1: Introduction 2: Simple example 3: Fancy example 4: Running Gri 5: Programming Gri 6: General Issues 7: X-Y Plots 8: Contour Plots 9: Image Plots 10: Examples 11: Handling Data 12: Gri Commands 13: Gri Extras 14: Evolution of Gri 15: Installing Gri 16: Gri Bugs 17: System Tools 18: Acknowledgments 19: License 20: Newsgroup 21: Concept Index | ## 13.6: Editing Gri Files in GNU Emacs If you use the GNU Emacs text editor, writing Gri command files is made easier by using the Gri editing mode. The Emacs gri-mode was written by Peter S. Galbraith (at email address ``psg@debian.org`'. Here is an overview of the gri-mode features: It indents if statements, loops, and so on (``gri-indent-line`', ``TAB`'). It can complete partially typed commands (``gri-complete`', ``M-TAB`') and help you edit the syntax that was thus inserted for you (``gri-option-select`', ``C-C C-o`'). It can provide a short help synopsis (``gri-help-this-command`', ``C-C C-h`'), or load the info manual at the location where the command is described (``gri-info-this-command`', ``C-C C-i`'), or help regarding any command (``gri-help`', ``C-C M-h`') and provide completion of command name at the prompt (``TAB`'), or help you find an unknown command by listing all containing a given word (``gri-help-apropos`', ``C-C C-a`'). It can let you run Gri and view its output without leaving the editor (``gri-run`', ``C-C C-r`'). If an error is encountered, Emacs will rearrange the buffer so the cursor is on the bad line of the Gri command-file. If you've already run Gri, and therefore have a PostScript output file, the mode will let you view that file (``gri-view`', ``C-C C-v`') even if that file is compressed. Thus one never has to leave Emacs; type ``C-C C-r`' to run Gri, and if there is no error, the graph comes up automatically. If there was an error, gri-mode will move editing point to the line with the error and display the error message. Given that the mode can complete partially typed commands, this means a substantial saving in development time. Click here to get to Gri FTP site, where the mode is stored as grimode.el To install gri-mode in your emacs, the only emacs variable you need to set in your .emacs file (and this only if your gri installation departs from default parameters) is gri*directory-tree or gri*path. If your ``gri`' and ``gri.cmd`' reside in the same directory (this is the standard Gri installation scheme before version 2.040), then you need to set the variable ``gri*path`' before you load ``gri-mode.el`'. For example, if both files are in ``/usr/local/bin`', you add the following to your ``~/.emacs`' file:
      (setq gri*path "/usr/local/bin/")
- If you use a gri directory tree (as is the standard since Gri version 2.040), then do not set ``gri*path`'. Instead, set ``gri*directory-tree`' to the root of this tree. For example, if your gri files reside in directories like named ``/usr/bin/gri`' and ``/usr/share/gri/lib/gri.cmd`', then you'd use:
      (setq gri*directory-tree "/usr/share/gri/lib/")
To access the Gri editing mode, put the file ``gri-mode.el`' in the appropriate place (e.g., ``/usr/local/share/emacs/19.31/site-lisp`' or some other file named in your Emacs ``load-path''), and then put lines like the following in your ``~/.emacs`' file:
    (setq gri*WWW-page "file:/usr/doc/gri-2.4.4/html/index.html")
    (setq gri*directory-tree "/usr/share/gri/lib/")
    (autoload 'gri-mode "gri-mode" "Enter Gri-mode." t)
    (setq auto-mode-alist
       (cons '("\\.gri$" . gri-mode) auto-mode-alist))
If you have multiple versions of Gri on your system, the directory-tree line will look more like the following
     (setq gri*directory-tree '("/usr/lib/gri/" "/opt/gri/"))
The mode controls indentation in much the same way as other modes do. Emacs will enter the Gri mode whenever you edit a file ending in the characters ``.gri`', or if you run the command ``gri-mode`'. Inside Gri mode, type ``C-h m`' for help on the mode.