IDEAS FOR AN HTML EDIT MODE FOR FREEMACS:
It would be great if someone out there wrote an HTML edit mode for
Freemacs. This would be useful for writing web pages and for HTML
Help files. Simon's Help program will be HTML-based. The following
are some ideas that I have for this mode.
First, I would start by modifying text-mode, since that already has
many of the features you are looking for in an HTML mode
("html-mode"). Plus, most users are probably familiar with text-mode,
so this is not a big deal to start using html-mode.
Something that recognized the special characters like &, < and > and
inserted the appropriate HTML code for me. Maybe you could create a
M-& binding for html-mode that worked like this:
(1) prompt for a character
(2) if it is special, you insert the HTML code.
if not special, you insert the raw character.
I think this would keep html-mode out of the way for experienced HTML
authors, but would make HTML easier to write for the rest of us. For
example, let's say I'm writing a new web page, and I want to use the
"less than" symbol. I may not remember that the HTML code for this
symbol is "<" so instead I type M-&, type the '<' character, and
the html-mode inserts the text "<".
Someone who already knew how to insert the "less than" symbol would
have just typed "<" and not missed a beat.
But by itself, this is not enough to make writing a new mode
worth-while. Sure, it's cute and fairly easy to use, but for the
experienced HTML author it is no better than text-mode. So a new
feature might be to add color to an HTML document.
To keep a document from quickly becoming gaudy, which can actually
impair your ability to read the HTML code, we should probably create a
few simple rules:
(1) we will only apply color to the first word in an HTML tag.
(2) a word is delimited by whitespace, '<' and '>'.
(3) our "color" will be set by "html-tag-color". (this allows a
certain flexibility if, later, we choose to add color to the
special characters, or to quoted text within an HTML tag.)
I have no idea if you can apply color to text inside Freemacs, but I
imagine that you can.
So, let's look at an example: The html-mode would recognize < and > as
being delimiters for an HTML tag. So the string "
" would have
"BR" as the tag. And the string "" would have
"A HREF=..." as the tag, but "A" is the first word of the tag. The
simple way that we applied in the rules above says we will only apply
color to the first word of a tag. Looking at a line of sample HTML
code:
the sample page
Then html-mode would only apply color to "A" and "/A", since they are
the first word in their tag. The "HREF=..." portion of the "A" tag
would not have color.
In other words, the html-mode recognizes the '<' as the start of a
tag. Then it applies color to all following text up to but not
including the first whitespace character or the next '>' character.
Note that this simple rule means that html-mode can handle even badly
formed HTML code.