Emacs hacks for bootcamp

Home : Emacs tips : rgr-hacks


This is a subset of my personal collection of hacks and tweaks; by default, not all of it is enabled.

Table of Contents

  1. Emacs hacks for bootcamp
    1. Table of Contents
    2. Installation
    3. Using rgr-abbrev-completion to save typing
    4. Mouse commands
    5. Useful commands in html-helper-mode
      1. Additional rgr-html-hacks commands
      2. More html-helper-mode documentation

Installation

These installation instructions are for setting up your bootcamp machine with the extra emacs stuff documented below.
  1. Download the file rgr-hacks-1.3.tar.gz into your home directory. (Clicking on the link should be sufficient to accomplish this.)

  2. Untar this into your ~/emacs directory. In a shell, do the following:
           cd
           gunzip < rgr-hacks-1.3.tar.gz | tar xf -
           
    This creates an ~/emacs directory, if one does not already exist.

  3. Install the sample .emacs file in your home directory.
           mv emacs/dot-emacs.el .emacs
           
    (Don't forget the dot in ".emacs"!)
    -- Or --
    If you already have a .emacs file, you may prefer to append the new stuff:
           cat emacs/dot-emacs.el >> .emacs
           

  4. Start a new emacs, and you should have it. Find a .html file using C-x C-f to test it (an empty file is fine); the mode line (in inverse video near the bottom) should say
           --:** foo.html              (HTML helper Fill)--L3--All--------
           
    or something similar.
Enjoy, and let me know if you encounter any bugs.

Using rgr-abbrev-completion to save typing

emacs has an "abbrev" concept whereby you can save typing by using abbreviations, which emacs will automatically expand as they are typed. This has the disadvantage that the abbreviations must predefined, and furthermore they must be unique. There is also a notion of definition name completion (e.g. M-TAB in the minibuffer when M-. prompts you for a tag name) that uses the same style of completion as for file names, but this is limited to names of definitions found in
tags tables, and runs into the problem that definitions usually have common prefixes.

In the mean time, I got used to a package on the Symbolics Lisp Machine that had the best features of both, plus some extras. When I stopped being able to use Lisp Machines, I hacked a version (from memory) for emacs that I called rgr-abbrev-completion. It currently has the following features:

Commands:

[finish. -- rgr, 7-Oct-99.]

Mouse commands

Because I have been seriously and permanently handicapped by using the powerful Lisp Machine user interface, I was driven to recreate some of its mouse commands within emacs after being forced back into the Unix world. There is a Symbolics-like cut-and-paste interface, but the real win is a mouse interface to M-.. (Though you may have to disable your window manager's interception of the "meta" modifier on the mouse buttons in order to get it to work.)

These are not enabled by default, since they override standard emacs mouse command bindings.

Setting up:

[finish. -- rgr, 8-Nov-99.]

Useful commands in html-helper-mode

HTML helper mode is a mode for editing HTML documents which I prefer to the default HTML mode distributed with emacs. For more documentation and the newest version, see http://www.santafe.edu/~nelson/tools/.

The main function html-helper-mode provides is a menu and keybindings for the HTML tags one inserts when writing HTML documents. Selecting the menu item or typing the key sequence for a command inserts the corresponding tag and places point in the right place. If a prefix argument is supplied, the tags is instead wrapped around the region. Alternately, one can type in part of the tag and complete it with M-TAB. (Personally, I don't use either, much; I type it all the hard way because I find going back and forth to fill in the template to be annoying.)

There is also code for indentation, timestamps, skeletons for new documents, and lots of other neat features.

Commands:

Additional rgr-html-hacks commands

These are installed by the rgr-html-define-commands hook function; the
rgr-hacks sample .emacs file does the following to install html-helper-mode and rgr-html-hacks:
;; Install html-helper-mode.
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
;; Add my HTML code hacks: check tag nesting (C-c n), make table of contents
;; (C-c t), check href's (C-c h c), paragraph motion, markup motion (C-c C-f,
;; C-c C-b, C-c C-k), and much more.  (Only need to do this once, so these are
;; on html-helper-load-hook.)
(add-hook 'html-helper-load-hook 'rgr-html-define-commands)
(add-hook 'html-helper-load-hook 'rgr-html-fix-regexps)
;; This has some per-buffer stuff (and is therefore on html-helper-mode-hook).
;; -- rgr, 19-Mar-96.
(add-hook 'html-helper-mode-hook 'rgr-html-helper-mode-hook)
If you are using emacs at BMERC, then these are all pre-installed (at no extra charge).

Markup commands: These operate on nested <foo>..</foo> constructs.

Anchor checking commands:

Heading commands:

Miscellaneous commands:

More html-helper-mode documentation

See the html-helper-mode documentation at http://host16.bootcamp.arsdigita.com/html-helper-mode/ (dead link).

If you don't mind shelling out the money (or already have a copy), the O'Reilly emacs offerings describe html-helper-mode, albeit briefly.


Bob Rogers <rogers@darwin.bu.edu>
Last modified: Fri Apr 30 22:41:16 EDT 2004