[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6. Add New Elements

If you'd like to add new HTML elements to this package, you should first take a look at the file `hm--html-not-standard.el', which already contains some non-standard elements. If you find your tags there, you should uncomment the line (require 'hm--html-not-standard) in the file `hm--html-mode.el'. There are also menu entries for these elements in the file `hm--html-menu.el', which are commented out. Don't forget to recompile the changed lisp files after that!

If you don't find your new elements there, you should do the following steps to add them:

  1. Locate a tag which is similar to the one you want to add. "Similar" means that it is inserted in the way you want to insert the new tags. Now let's assume, that you chose `<strong></strong>'.
  2. Look at the file `hm--html.el' and search the function(s) which inserts the similar tag(s). If the HTML element consists of only one tag, then there should be only one function for inserting the tag. If the element consists of a start and an end tag, there are at least two functions. Only in some special cases, if it is possible to insert elements with different attribute values, are there more than two functions. In the case of `<strong></strong>', there are the two functions hm--html-add-strong and hm--html-add-strong-to-region. The first one is used if no region is active, and the second if a region is active. The naming scheme of these functions is always hm--html-add-<tagname> and hm--html-add-<tagname>-to-region. <tagname> is not in all cases the tagname. Sometimes a more human readable name is used (e.g. bold instead of b).
  3. To get the right indentation for the new tags you should add an entry for them to the alist of the variable hm--html-tag-name-alist, which is defined in the file `hm--html-configuration.el'. Let's assume that the new tagname is `foo'. The entry in hm--html-tag-name-alist should be
         ("foo" (:hm--html-one-element-tag t))
    if the new element consists only of one tag (`img' is such an element) or
         ("foo" (:hm--html-two-element-tag t))
    if the new element consists of two tags (`strong' is such an element) or
         ("foo" (:hm--html-one-or-two-element-tag t))
    if the new element consists of two tags, but it is permissible to use the start tag without its end tag (`p' is such an element).

Now you are ready and able to insert the new tags with

	M-x hm--html-add-foo
	M-x hm--html-add-foo-to-region

If you want to add the new commands also to the popup menu, then you have to take a look at `hm--html-menu.el', where all the menus are defined. Look at hm--html-menu-noregion-expert and hm--html-menu-region-expert. The first one is used if no region is active, and the second if a region is active (both are only available if the "expert menus" are used; this is an option in the pulldown menu). You should now add an entry like

	["Foo" hm--html-add-foo t]
to the hm--html-menu-noregion-expert variable and an entry
	["Foo" hm--html-add-foo-to-region t]
to the hm--html-menu-region-expert variable (only if hm--html-add-foo-to-region exists). You can do this by setting the whole variable to a new value or by using the function add-menu-button. I recommend the last method.

If you'd like to have a key sequence for inserting the new tag as well, take a look at `hm--html-keys.el'. There are different key tables defined for region and no region cases and for different sorts of elements, like anchors, frame elements (doesn't mean the Netscape element frame) and so on. These "groups" are the same as the submenu groups.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on October, 2 2007 using texi2html