Editing Shapes files
This page gives a brief overview of the available tools that support the editing of Shapes files. At the moment, there is only one such tool, read on!
With Emacs running the minor mode
shapes-mode, you get both excellent support for editing your files (including nifty syntax highlighting), and a very convenient way of previewing your result. The mode also has some support for running the Shapes compiler
interactively, but this is not described here.
Here is a brief overview of the features provided by
shapes-mode. Readers are referred to the on-line help in Emacs for additional information, as the information on this page is kept to a minimum for ease of maintenance.
- Compiling and viewing. Among the commands and key bindings related to compiling and viewing, C-c C-v is particularly useful; it compiles your file and displays the result in an Emacs buffer. Check it out! (It only works if doc-view.el is installed.)
- Typing unusual characters.
Key sequence | Provided by | Inserts |
C-x 8 o | iso-transl | ° (degree sign) |
C-x 8 ' ' | iso-transl | ´ (acute accent) |
C-x 8 # | shapes-mode | • (bullet) |
C-x 8 <right> | shapes-mode | → (right arrow) |
By typing C-x 8 C-h you get a list of all key bindings starting with C-x 8.
- Skeletons for faster writing. With skeleton pairs activated (see below), some opening delimiters will automatically append the corresponding closing delimiter and position the insertion point in between.
Installation instructions can be found in the file shapes-mode.el itself, but in case you don't like to read Emacs lisp files, instructions are given here as well.
Current versions of Shapes come with
shapes-mode.el, but one still has to inform Emacs where to find the file, and then activate it. You need to add the two lines of code that do this to your
.emacs.el (or equivalent file). (If you do not know what or where the file
.emacs.el is, you need to learn some Emacs basics before returning to these instructions.) The two lines of code are availble in a separate file, which can be located using the Shapes compiler in the following way (using
cat to show the contents of the file):
cat `shapes --which-share`/edit/emacs/50shapes-mode.el
Just copy and paste, and the basic install is complete!
Note that although the filename 50shapes-mode.el reminds of automatic install of Emacs packages under Debian (by means of placing the file in the appropriate site-start.d directory), there is currently no Shapes package for Debian.
Some features of
shapes-mode require additional things to be installed:
- doc-view.el is required for viewing Shapes output graphically in a separate buffer — highly recommended! This minor mode is included with Emacs from version 23.1, so you just need to make sure that your Emacs is up to date. Then, just add
(require 'doc-view)
to .emacs.el.
- Ghostscript (with the program gs somewhere in your PATH) is required for display of inline drawable values in interactive mode.
Follow these instructions if you want to upgrade your
shapes-mode without upgrading your entire Shapes installation. Since
shapes-mode consists of a single file, we find it more convenient to refer users to the
Git repository than to keep adding new versions to the
SourceForge downloads all the time.
If you are upgrading from the basic install of shapes-mode, remove the line in your .emacs.el that adds to load-path the directory where the shapes-mode.el bundled with Shapes is located.
Put the new
shapes-mode.el in a directory on your Emacs load path. If you don't know what this means, create a new directory (say,
emacs-addons) somewhere (say,
~/Library), add the line
(setq load-path (cons "~/Library/emacs-addons" load-path))
near the top of your
.emacs.el (or equivalent file), and place
shapes-mode.el in your newly created directory.
Make sure that your
.emacs.el contains the line
(require 'shapes-mode)
and the upgrade is complete.
The main source of information about shapes-mode is the on-line help that the mode provides inside Emacs. Type C-h m to display the online help.
When shapes-mode is loaded, it runs the hook 'shapes-mode-hook.
Turn skeleton pairs on and off using
M-x set-variable <enter> skeleton-pair <enter>, followed by either
t to turn on or
nil to turn off. To automatically turn on skeleton pairs for buffers running
shapes-mode, you can use the hook;
(add-hook 'shapes-mode-hook
(lambda ()
(make-local-variable 'skeleton-pair)
(setq skeleton-pair t)))