HTML Helper Mode

Html helper mode is an Emacs Lisp major mode for editing HTML files witten by Nelson Minar and now mantained by me :). It now includes support for JSP(it seems it works :) and uses JDE), PHP and ASP server scripting languages (For a full support of ASP you should have visual-basic-mode in your load-path, too).

Nelson's greatest job was the inclusion of templates supports via tempo.el that speed up a lot writing new documents.


Nelson Minar Major mode author
Stan Lanning defadvice code that prevents indenting of <PRE></PRE>, for the defadvice code that leaves the cursor where it is during narrowing to script code, enhancments to the scripting narrowing
Peter Neergaard
XEmacs Developers
Solutions to better support XEmacs (see version bravo and charlie)
Jari Aalto Code to automatically set html-helper-mode-uses-JDE for use JDE (if available)
Karel Sprenger Fixing indentation engine (by spotting some replicated code hidden by misplaced folding tags...)
Jack Vinson Fixing handling of browse-url-browser-function when it is bound to a list and not to a function

html-helper-mode A major mode for editing HTML sourcecode with Emacs. Added some support for PHP, JSP (it seems it works :)) and ASP server scripting, that is script fontification with font-lock-mode and narrowing with mode switch:

while editing the whole HTML document the [PJA][HS]P script is painted in a different color and, upon request, the mode narrows the editing to the script block around the point changing fontification accordingly to the expected script language. You can choose explicitly the appropriate scripting mode or just press F4 and let Emacs try to guess the kind of script the cursor is on (many thanks to Stan Lanning).

This mode was borne under Windows when I first faced ASP. More information about Emacs running on Micro$oft angbands in the NTEmacs site (NTEmacs is the port of Emacs to Micro$oft angbands). Here are two HTML documents from Nelson Minar, the original author (thanks!) with some documentation and hints about configuring this mode.


The original website at has gone 404. Therefore this is the only website for this project.

You can visit the project page here and the download area where you can find the released files.

Beta test!

A beta version with:

is now available in the download area

NEW IN VERSION 3.0.4jolly

Bug fix: html-helper-buffers doesn't bloat anymore.

In Emacs 21 fontification is broken and could even hang Emacs!

NEW IN VERSION 3.0.4india

Bug fix (XEmacs specific): hopefully Graham Gough found the way to fix face problems with XEmacs. Requires psgml-html.el!

Changed html-helper-insert-or-wipe so that it insert empty tag attributes if html-helper-mode-insert-attributes-always is non nil

string-bytes re-entered the game due a file loss and restore :(

Fixed indentation engine (handles <link> tags correctly)

NEW IN VERSION 3.0.4hotel

Warning: the package released on Thursday, February 22nd, 2001 is broken (a capitalized symbol slipped in the code and the *Messages* overrunning prop was still there). My apologies.

Bug fix: comment-region now works (comment-end must contain a simple string)

Bug fix: fontifying messages don't overrun *Messages* anymore (the spinning prop is gone, replaced by a pulsating strip of dots)

NEW IN VERSION 3.0.4golf

Bug fix: string-bytes doesn't exist in XEmacs (Bug reported by Rashid Butte)

NEW IN VERSION 3.0.4fox-trot

Jack Vinson supplies this code to handle the case when browse-url-browser-function is a list and not a function (it can be a list, says its documentation)

Fixed version number (it was still to 3.0.4delta)

NEW IN VERSION 3.0.4echo

Karel Sprenger fixed the indentation engine : Just downloaded v3.0.4delta and discovered that it still doesn't indent table stuff as expected despite your fixes. Looking at the code I discovered that the relevant code appears twice (hidden by misplaced folding-mode tags).

NEW IN VERSION 3.0.4delta

html-helper-release-setup did use C-f12 instead of f4, now I set it to html-script-toggle-key. Corrected modes docstring. Now if you don't like f4 as special key for jumping back and forth, just define html-script-toggle-key in your .emacs

NEW IN VERSION 3.0.4charlie

Reworked indenting engine. Now indentation is uniform (2 character default). It recognizes indentation sensible tags with attributes and needs that they tags stay on separate lines (C mode needs curly braces on separate lines too, so this is acceptable :) )

NEW IN VERSION 3.0.4bravo

Changed the way html-helper-mode-uses-JDE is set in the mode source, so that it automatically detects JDE.

Added (require 'psgml-html) for XEmacs users (kind suggestion by XEmacs developer

Changed ASP and comment blocks fontifying message

Created a changelog file (source is big enought by itself :))

Reworked syntax higlighting. Cut some regexp and now all tags, except anchors, are higlighted the same way:

<tag attribute="value" attribute=value>

where the colors are my choices for:

Progress message during highlighting are a bit lighter, no more growing strips of dots, now it uses a small "spinning prop"


The mode switch uses a brand new code working with alists. Each buffer is associated with the flavour of html-helper-mode used when it was loaded. That solves problems introduced with JSP support.

JDE support now works. Many thanks to Paul Kinnucan for his kind (kind is not enought) help in finding the right hook to use. No more File mode specification error: (void-variable jde-entering-java-buffer-hooks).


charlie subrelease: Managed a difference in Emacs 20.x, Emacs 19.x and Xemacs about the font-lock-builtin-face. Now Emacs 19.x uses a scratch built font-lock-builtin-face (orchid) wile Xemacs uses font-lock-preprocessor-face. Thanks to Peter Neergaard for the solution

bravo subrelease: Corrected some regexps where there was a \\s instead of a \\w (Xemacs barfs on the previous one). Thanks to Peter Neergaard for the bug report and help in the solution

Changed default value for html-helper-mode-uses-visual-basic: the default distribution does not offer visual-basic-mode. WARNING!!.THIS CHANGES PREVIOUS DEFAULT!!

Changed comment matching. Used a function instead of a regexp. Comments are used to hide script code from browsers that can't handle them, and long comments can overflow the regexp stack. Geeeeeeeeeeeee, now it works even better than sgml/html mode :)

Added a small file (that you can load-file from your .emacs) that enables the customization even before loading the mode

Added JDE support. I used the

JDE hook for the mode switching, it could be broken so consider it experimental. It seems that this made the whole stuff a little flaky. As reported in NTEmacs mailing list I experienced a ABORT-RETRY-IGNORE dialogs using this new mode (but I had it once with a °shell° buffer active trying to kill a find with C-c). Finally I had report of slowness when using JDE for JSP blocks, but I didn't experience it - I load JDE on startup -

The mode is now distributed as a tar.gz file (WinZip handles, so no problems for those marooned on Win32...).

There are some bug fixes and some new features. For Emacsen prior to 20.4.1 you can tell the mode that your frame background is dark or light with either font-lock-background-mode or frame-background-mode while later Emacsen use background member of class color to select teh colors for custom faces. For Emacsen prior to 20.4.1 you have to change the face colors using set-face functions after loading the mode (or making the faces by yourself before loading the mode). From Emacs 20.4.1 you can customize the colors. The mode defaults (This has been changed in to use visual-basic-mode and default java support from cc-mode. You can inhibit the use of the VB stuff by setting html-helper-mode-uses-visual-basic to nil before the mode is loaded. You can customize :) this variable. You can also customize the variable that tells Emacs that you do not have an italic bold font available, so that the mode does not error attempting to build it (html-helper-mode-uses-bold-italic, you can customize this one too). There are 3 modes now:
  1. html-helper-mode
  2. asp-html-helper-mode
  3. php-html-helper-mode
that differ only in the template they use. You can change them setting the appropriate variable
  1. html-helper-new-buffer-template
  2. html-helper-new-ASP-buffer-template
  3. html-helper-new-PHP-buffer-template
before loading the mode. Can someone suggest a JSP template ?

GOING ON: Improve a javascript-mode I found around and use it for client side javascript (JDE is too heavy and slow for that, at least on my Pentium 166.:) )


Support modes

Visual-basic-mode.el A major mode for editing visual basic source code, with some little changes from the original (some code to narrow the editing to the source code, excluding controls definition, fixed some things in syntax higlighting). Available at the NTEmacs site but included here because it is required by Html-helper-mode.el
tempo.el a version of the package coming from the site of the original html-helper-mode original author included here because works with html-helper-mode.el. Try to set tempo-interactive to a non nil value to have Emacs prompting for the variable parts of a tag.
The mighty JDE, the powerful Java Development Environment for Emacs.
Contributions for the mode.
Last modified: Fri Jan 9 14:10:24 CET 2004

                     Made in  Free Software