jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

html mode with mode-menu


Dear Jedies,

after starting to write some html code (for jedmodes.sf.net) I realized that
the html mode is still missing the mode menus. Remembering Guido's "roll up
your sleves" call some months ago, I decided to fix this.

Please find attached the diff against the html.sl from jed 0.99.16.

Changes:
%    new doctypes html 4.1 strict/transitional, xhtml transitional
%    close all tags
%    mode menu
%    
%  TODO: html preview: internal with html2text/lyx --dump
%  	      	       external (call browser)
%  	 toggle mode html <-> php     	       

With the mode menu, a new question arises:

Currently, keybindings use keymap_something functions that result in a 
"poor mans menu" but prevent the keybindings from showing up in the proper
menu.

Also, the help line telling 
   For a complete list of keybindings, use `describe_bindings'.
is misleading, as the only html-specific binding shown are

ESC ^M 			html_par_insert
^E 			html_keymap
` 			html_quoted_insert

while the html_keymap remains a mystery.

So we have to weight the advantages of the current scheme with the advantage
of keybindings showing up in the mode menu as in other modes.

Günter

-- 
G.Milde at web.de

--- /home/milde/.jed/stdlib/html.sl	2003-06-27 14:13:26.000000000 +0200
+++ /home/milde/.jed/lib/html.sl	2003-11-27 15:42:54.000000000 +0100
@@ -1,20 +1,45 @@
-%
 %  file : html.sl
 %
 %  Original Author : Raikanta Sahu, rsahu@xxxxxxxxxxxx
 %  Substantial additions by Jim Knoble.
-
+%  
 %  Modified by John E. Davis for incorporation into JED.
-%% 
-%% Modified by Michael D Johnson to conform with the standards recommendation 
-%% on capitalization.
-%% 
+% 
+%  Modified by Michael D Johnson to conform with the standards recommendation 
+%  on capitalization.
+%  
 %  Modified by Kees Serier
 %  All lower case except for DOCTYPE (like all W3C code), html: 2 3.2 4 XHTML
 %  Definition lists complete, tables, euro symbol and more.
+%  
+%  Modified by G. Milde
+%    new doctypes html 4.1 strict/transitional, xhtml transitional
+%    close all tags
+%    mode menu
+%    
+%  TODO: html preview: internal with html2text/lyx --dump
+%  	      	       external (call browser)
+%  	 toggle mode html <-> php
+%  	 indentation (cuastomizable)
+
+% --- Custom Variables
+% The sprinf template for inserting blocktags
+% default: just one newline
+% other variants 
+%    "<%s>\n@\n</%s>\n" beg and end tag on separate lines 
+%    "<%s>\n   @\n</%s>\n" indented block
+custom_variable("Html_insert_with_newline_string", "<%s>\n@</%s>\n");
+
+% --- Requirements
+% comments using comment.sl
+require("comments");
+set_comment_info ("html", "<!-- ", " -->", 0);
+
 
-% 1 => html_mode wraps, like text_mode
-% 0 => html_mode doesn't wrap, like no_mode
+
+
+% the modename
+static variable mode = "html";
 
 define html_paragraph_separator ()
 {
@@ -25,9 +50,9 @@
 % Movement function (JM)
 %!%+
 %\function{html_skip_tag}
-%\synopsis{html_skip_tag}
+%\synopsis{Skip past html tag}
 %\description
-% skip forward past html tag
+% skip past html tag
 %!%-
 define html_skip_tag()
 {
@@ -37,7 +62,7 @@
 
 %!%+
 %\function{html_bskip_tag}
-%\synopsis{html_bskip_tag}
+%\synopsis{Skip backward past html tag}
 %\description
 % skip backward past html tag
 %!%-
@@ -48,14 +73,14 @@
 
 %!%+
 %\function{html_mark_next_tag}
-%\synopsis{html_mark_next_tag}
+%\synopsis{Mark the next html tag}
 %\description
 % mark the next html tag forward
 %!%-
 define html_mark_next_tag()
 {
    variable taglng = 1;
-   
+
    !if (fsearch_char ('>')) return;
    go_right(taglng);
    set_mark_cmd ();
@@ -65,7 +90,7 @@
 
 %!%+
 %\function{html_mark_prev_tag}
-%\synopsis{html_mark_prev_tag}
+%\synopsis{Mark the previous html tag}
 %\description
 % mark the previous html tag
 %!%-
@@ -88,13 +113,12 @@
    % make sure mark is before point;
    % 1 => push spot first
    check_region(1);
-   
+        
    % put tags on appropriate sides of region,
    % then return to where we were
+   insert(rgttag);
    exchange_point_and_mark();
    insert(lfttag);
-   exchange_point_and_mark();
-   insert(rgttag);
    pop_spot();
    pop_mark_0 ();
 }
@@ -127,64 +151,60 @@
    html_insert_move (sprintf ("<%s>@</%s>", str, str));
 }
 
+% customizable via Html_insert_with_newline_string custom variable
 define html_insert_with_newline (str)
 {
-   html_insert_move (sprintf ("<%s>\n@</%s>\n", str, str));
-}
-
-define html_insert_with_2newlines (str)
-{
-   html_insert_move (sprintf ("<%s>\n@\n</%s>\n", str, str));
+   html_insert_move (sprintf (Html_insert_with_newline_string, str, str));
 }
 
 define html_form ()
 {
-   html_insert_move ("<form action=\"\" method=\"\">\n@\n</form>");   
+   html_insert_move ("<form action=\"\" method=\"\">\n@\n</form>");
 }
 
 define html_input ()
 {
-   insert ("<input type=\"\" name=\"\" value=\"\">");
+   insert ("<input type=\"\" name=\"\" value=\"\" />");
 }
 
 define html_input_text ()
 {
-   insert ("<input type=\"text\" name=\"\" value=\"\">");
+   insert ("<input type=\"text\" name=\"\" value=\"\" />");
 }
 
 define html_input_password ()
 {
-   insert ("<input type=\"password\" name=\"\" value=\"\">");
+   insert ("<input type=\"password\" name=\"\" value=\"\" />");
 }
 
 define html_input_checkbox ()
 {
-   insert ("<input type=\"checkbox\" name=\"\" value=\"\">");
+   insert ("<input type=\"checkbox\" name=\"\" value=\"\" />");
 }
 
 define html_input_radio ()
 {
-   insert ("<input type=\"radio\" name=\"\" value=\"\">");
+   insert ("<input type=\"radio\" name=\"\" value=\"\" />");
 }
 
 define html_input_submit ()
 {
-   insert ("<input type=\"submit\" value=\"OK\">");
+   insert ("<input type=\"submit\" value=\"OK\" />");
 }
 
 define html_input_reset ()
 {
-   insert ("<input type=\"reset\"  value=\"Clear\">");
+   insert ("<input type=\"reset\"  value=\"Clear\" />");
 }
 
 define html_input_hidden ()
 {
-   insert ("<input type=\"hidden\" name=\"\" value=\"\">");
+   insert ("<input type=\"hidden\" name=\"\" value=\"\" />");
 }
 
 define html_select ()
 {
-   html_insert_move ("<select name=\"@\" size=\"\">\n@\n</select>");
+   html_insert_move ("<select name=\"@\" size=\"\">\n\n</select>");
 }
 
 define html_text_area ()
@@ -192,20 +212,11 @@
    html_insert_move ("<textarea name=\"@\"></textarea>");
 }
 
-%
-%  Make comment
-%
-define html_comment ()
-{
-   html_insert_move ("<!-- @ -->");
-}
 
-%
 % insert Horizontal rule  TJO
-%
 define html_horiz_rule ()
 {
-   insert("\n<hr>\n") ;
+   insert("\n<hr />\n") ;
 }
 
 define html_heading (c)
@@ -236,7 +247,7 @@
 %
 define html_image ()
 {
-   html_insert_move ("<img src=\"@\" alt=\"\">");
+   html_insert_move ("<img src=\"@\" alt=\"\" />");
 }
 
 %
@@ -247,44 +258,24 @@
 define html_quoted_insert ()
 {
    variable ch;
-   
+
    !if (input_pending (5)) flush ("`-");
    ch = getkey ();
    switch (ch)
-     {
-      case '\r':
-	insert ("<br>\n");
-     }
-     {
-      case '&':
-	insert ("&amp;");
-     }
-     {
-      case '>':
-	insert ("&gt;");
-     }
-     {
-      case '<':
-	insert ("&lt;");
-     }
-     {
-      case ' ':
-	insert ("&nbsp;");
-     }
-     {
-      case 'e':
-	insert ("&euro;");
-     }
-     {
-	% default:  The other special characters should be added.
-	insert_char (ch);		       
-     }
+     { case '\r': insert ("<br />\n"); }
+     { case '&' : insert ("&amp;"); }
+     { case '>' : insert ("&gt;"); }
+     { case '<' : insert ("&lt;"); }
+     { case ' ' : insert ("&nbsp;"); }
+     { case 'e' : insert ("&euro;"); }
+     % TODO: other special characters
+     { insert_char (ch); } % default
 }
 
 % Support for HTML paragraphs.  MDJ 04/06/98
 define html_par_insert()
 {
-   insert("\n\n<p>\n");
+    html_insert_with_2newlines("p");
 }
 
 define html_read_key (hlp)
@@ -296,17 +287,29 @@
 
 define html_doctype ()
 {
-   variable key2;
-   key2 = html_read_key ("HTML version: 2  3.2  4  Xhtml");
-   switch (key2)
+   variable key,
+     doctype = "<!DOCTYPE html PUBLIC \"-//W3C//DTD ";
+   key = html_read_key ("HTML version: 2  3.2  4  4.1-Trans 4.1-Strict  xhtml-tRans Xhtml-strict");
+   switch (key)
      {case '2': 
 	insert ("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n");}
      {case '3': 
-	insert ("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2 FINAL//EN\">\n");}
+	insert (doctype + "HTML 3.2 FINAL//EN\">\n");}
      {case '4': 
-	insert ("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 FINAL//EN\">\n");}
+	insert (doctype + "HTML 4.0 FINAL//EN\">\n");}
+     {case 't' or case 'T': 
+	insert (doctype + "HTML 4.01 Transitional//EN\"\n" 
+	   + "\"http://www.w3.org/TR/html4/loose.dtd\";>\n");}
+     {case 's' or case 'S':
+	insert (doctype + "HTML 4.01//EN\"\n" 
+	   + "\"http://www.w3.org/TR/html4/strict.dtd\";>\n");}
+     {case 'r' or case 'R': 
+	insert (doctype + "XHTML 1.0 Transitional//EN\"\n"
+	   + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\";)>\n");}
      {case 'x' or case 'X': 
-	insert ("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\">\n");}
+	insert (doctype + "XHTML 1.0 Strict//EN\"\n"
+	   + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\";)>\n");}
+	% TODO: add 4.1 and XHTML Frameset variants
      { beep (); }
 }
 
@@ -316,7 +319,6 @@
    html_insert_move ("<html>\n\n<head>\n<title>@</title>\n</head>\n\n<body>\n</body>\n\n</html>") ;
 }
 
-
 define html_keymap_a ()
 {
    variable name = "<a name=\"@\"></a>";
@@ -326,7 +328,7 @@
      { case 'h': href; }
      { case 'n': name; }
      {
-	beep (); return;
+       beep (); return;
      }
    html_insert_move (());
 }
@@ -336,15 +338,16 @@
    variable key;
    key = html_read_key ("dL  dT  dD");
    switch (key)
-     { case 'l': html_insert_with_newline ("dl"); }
-     { case 't': insert ("<dt>"); }
-     { case 'd': insert ("<dd>"); }
+     { case 'l': html_insert_with_2newlines ("dl"); }
+     { case 't': insert ("<dt />"); }
+     { case 'd': insert ("<dd />"); }
      { beep (); }
+  
 }
 
 define html_keymap_f ()
 {
-   
+
    switch (html_read_key ("txtArea Chkbox Form Hidden Input Option Passw Radio Select Text Xreset Ysubmit"))
      {case 'a': html_text_area (); }
      {case 'c': html_input_checkbox (); }
@@ -367,14 +370,14 @@
 define html_keymap_h ()
 {
    variable key;
-   key = html_read_key ("h1  h2  h3  h4  h5  h6  templAte Doctype  Head  Body  htmL  Title");
+   key = html_read_key ("h1  h2  h3  h4  h5  h6  templAte Doc  Head  Body  htmL  Title");
    switch (key)
      % { case 'd': html_insert_bol ("doc"); }
      { case 'd': html_doctype (); }
-     { case 'h': html_insert_with_newline ("head"); }
-     { case 'b': html_insert_with_newline ("body"); }
-     { case 'l': html_insert_with_newline ("html"); }
-     { case 't': html_insert_with_newline ("title"); }
+     { case 'h': html_insert_with_2newlines ("head"); }
+     { case 'b': html_insert_with_2newlines ("body"); }
+     { case 'l': html_insert_with_2newlines ("html"); }
+     { case 't': html_insert_with_2newlines ("title"); }
      { case 'a': html_template (); }
      { (key <= '6') and (key >= '1') : html_heading (key);}
      { beep (); }
@@ -388,11 +391,11 @@
 define html_keymap_l ()
 {
    switch (html_read_key ("Dir Li Menu Ordered Un-ordered"))
-     { case 'd': html_insert_with_newline ("dir"); }
+     { case 'd': html_insert_with_2newlines ("dir"); }
      { case 'l': html_insert_here ("li"); }
-     { case 'm': html_insert_with_newline ("menu"); }
-     { case 'o': html_insert_with_newline ("ol"); }
-     { case 'u': html_insert_with_newline ("ul"); }
+     { case 'm': html_insert_with_2newlines ("menu"); }
+     { case 'o': html_insert_with_2newlines ("ol"); }
+     { case 'u': html_insert_with_2newlines ("ul"); }
      {
 	% default 
 	beep ();
@@ -402,11 +405,11 @@
 define html_keymap_p ()
 {
    switch (html_read_key ("Break Hrule Par blockQuote pRe"))
-     { case 'b': html_insert_eol ("br"); }
+     { case 'b': html_insert_eol ("br /"); newline();}
      { case 'h': html_horiz_rule (); }
-     { case 'p': insert ("<p>\n"); }
-     { case 'q': html_insert_with_newline ("blockquote"); }
-     { case 'r': html_insert_with_newline ("pre"); }
+     { case 'p': html_insert_with_2newlines ("p"); }
+     { case 'q': html_insert_with_2newlines ("blockquote"); }
+     { case 'r': html_insert_with_2newlines ("pre"); }
      {
 	beep ();
      }
@@ -436,8 +439,8 @@
 define html_keymap_t ()
 {
    switch (html_read_key ("Table Row Header Data"))
-     { case 't': html_insert_with_newline ("table"); }
-     { case 'r': html_insert_with_newline ("tr"); }
+     { case 't': html_insert_with_2newlines ("table"); }
+     { case 'r': html_insert_with_2newlines ("tr"); }
      { case 'h': html_simple_insert ("th"); }
      { case 'd': html_simple_insert ("td"); }
      {
@@ -449,11 +452,11 @@
 {
    variable key = html_read_key ("Anchors  Dfnlists  Forms  Headings  Images  Lists  Pstyles  cStyles Tables");
    switch (key)
-     { case 2: html_bskip_tag (); }	   %  ^B
-     { case 6: html_skip_tag (); }	   %  ^F
+     { case 2: html_bskip_tag (); }		       %  ^B
+     { case 6: html_skip_tag (); }		       %  ^F
      { case 14: html_mark_next_tag (); }   %  ^N
      { case 16: html_mark_prev_tag (); }   %  ^P
-     { case 'c': html_comment (); }
+     { case 'c': comment_region_or_line (); }
      { case 'a': html_keymap_a (); }
      { case 'd': html_keymap_d (); }
      { case 'f': html_keymap_f (); }
@@ -470,23 +473,149 @@
    flush ("");
 }
 
-$1 = "html";
-!if (keymap_p ($1)) make_keymap ($1);
-undefinekey (_Reserved_Key_Prefix, $1);
-definekey("html_keymap", _Reserved_Key_Prefix, $1);
-undefinekey ("\e;", $1);
-definekey ("html_comment",   "\e;",  $1);
-definekey ("html_quoted_insert",   "`",  $1);
-
-definekey("html_par_insert", "\e^M", $1); % Neater paragraph insert (MDJ 04/06/98)
-
-
-create_syntax_table ($1);
-define_syntax ("<", ">", '(', $1);     %  make these guys blink match
-define_syntax ("<>", '<', $1);
-define_syntax ("<!-", "-->", '%', $1);
-define_syntax ("A-Za-z&", 'w', $1);
-define_syntax ('#', '#', $1);
+!if (keymap_p (mode)) make_keymap (mode);
+undefinekey (_Reserved_Key_Prefix, mode);
+definekey("html_keymap", _Reserved_Key_Prefix, mode);
+definekey ("html_quoted_insert",   "`",  mode);
+
+definekey("html_par_insert", "\e^M", mode); % Neater paragraph insert (MDJ 04/06/98)
+
+% --- the mode dependend menu
+
+% append a new popup to menu and return the handle
+static define new_popup(menu, popup)
+{
+   menu_append_popup (menu, popup);
+   return strcat(menu, ".", popup);
+}
+
+static define html_menu (menu)
+{
+   variable popup, popup2, i;
+   
+   % ^CH...  document type, etc.
+   popup = new_popup(menu, "Layout &Document");
+   popup2 = new_popup(popup, "Templ&ate");
+   menu_append_item(popup2, "HTML &2", "ungetkey('2'); html_template");
+   menu_append_item(popup2, "HTML &3.2", "ungetkey('3'); html_template");
+   menu_append_item(popup2, "HTML &4", "ungetkey('4'); html_template");
+   menu_append_item(popup2, "HTML 4.1 &Transitional", "ungetkey('l'); html_template");
+   menu_append_item(popup2, "HTML 4.1 &Strict", "ungetkey('s'); html_template");
+   menu_append_item(popup2, "XHTML T&ransitional", "ungetkey('r'); html_template");
+   menu_append_item(popup2, "&XHTML Strict", "ungetkey('x'); html_template");
+
+   popup2 = new_popup(popup, "&Doctype");
+   menu_append_item(popup2, "HTML &2", "ungetkey('2'); html_doctype");
+   menu_append_item(popup2, "HTML &3.2", "ungetkey('3'); html_doctype");
+   menu_append_item(popup2, "HTML &4", "ungetkey('4'); html_doctype");
+   menu_append_item(popup2, "HTML 4.1 Transitiona&l", "ungetkey('l'); html_doctype");
+   menu_append_item(popup2, "HTML 4.1 &Strict", "ungetkey('s'); html_doctype");
+   menu_append_item(popup2, "XHTML T&ransitional", "ungetkey('r'); html_doctype");
+   menu_append_item(popup2, "&XHTML Strict", "ungetkey('x'); html_doctype");
+
+   menu_append_item(popup, "Htm&l", "html_insert_with_2newlines", "html");
+   menu_append_item(popup, "&Head", "html_insert_with_2newlines", "head");
+   menu_append_item(popup, "&Title", "html_insert_with_2newlines", "title");               
+   menu_append_item(popup, "&Body", "html_insert_with_2newlines", "body");
+   
+   % ^CP...  Paragraph styles, etc. (<p>, <br>, <hr>, <address>, etc.)
+   popup = new_popup(menu, "Layout &Paragraph");
+   menu_append_item(popup, "&Paragraph", "html_insert_with_2newlines", "p");
+   menu_append_item(popup, "&Address", "html_simple_insert", "address");
+   menu_append_item(popup, "Block&quote", "html_insert_with_2newlines", "blockquote");
+   menu_append_item(popup, "P&reformatted", "html_insert_with_2newlines", "pre");
+   menu_append_item(popup, "Line &Break", "html_insert_eol", "br /");
+   menu_append_item(popup, "&Hrule", "html_horiz_rule");
+
+   % ^CS...  Character styles (<em>, <strong>, <b>, <i>, etc.)
+   popup = new_popup(menu, "Layout &Character");
+   menu_append_item(popup, "&Cite",       "html_simple_insert", "cite"   );
+   menu_append_item(popup, "&Emphasized", "html_simple_insert", "em"     );
+   menu_append_item(popup, "&Variable",   "html_simple_insert", "var"    );      
+   menu_append_item(popup, "&Kbd Input",  "html_simple_insert", "kbd"    );
+   menu_append_item(popup, "C&ode",       "html_simple_insert", "code"   );
+   menu_append_item(popup, "&Sample",     "html_simple_insert", "samp"   );
+   menu_append_separator(popup);          
+   menu_append_item(popup, "&Bold",       "html_simple_insert", "b"      );
+   menu_append_item(popup, "&Ital",       "html_simple_insert", "i"      );
+   menu_append_item(popup, "&Teletype",   "html_simple_insert", "tt"     );
+   menu_append_item(popup, "&Uline",      "html_simple_insert", "u"      );
+   % font tag is deprecated in Html 4.1
+   % menu_append_item(popup, "&Font",       "html_simple_insert", "font"   );
+
+   % Headings
+   popup = new_popup(menu, "&Headings");
+   for (i=1; i<=6; i++)
+     menu_append_item(popup, sprintf("H&%d", i), "html_heading", string(i)[0]);
+
+   % ^CA...  Anchors (<a>...</a>)
+   % ^CI...  Images
+   popup = new_popup(menu, "&Anchors and Images");
+   menu_append_item(popup, "&Href", "html_insert_move", "<a href=\"@\"></a>");
+   menu_append_item(popup, "&Name", "html_insert_move", "<a name=\"@\"></a>");
+   menu_append_item(popup, "&Image", "html_image");
+   
+   
+   % ^CF...  Forms (<form>...</form>)
+   popup = new_popup(menu, "&Forms");
+   menu_append_item(popup, "&Form",      "html_form");
+   menu_append_item(popup, "Text &Area", "html_text_area");
+   menu_append_item(popup, "&Chkbox",    "html_input_checkbox");
+   menu_append_item(popup, "&Hidden",    "html_input_hidden");
+   menu_append_item(popup, "&Input",     "html_input");
+   menu_append_item(popup, "&Option",    "html_insert_bol", "option");
+   menu_append_item(popup, "&Password",  "html_input_password");
+   menu_append_item(popup, "&Radio",     "html_input_radio");
+   menu_append_item(popup, "&Select",    "html_select");
+   menu_append_item(popup, "&Text",      "html_input_text");
+   menu_append_item(popup, "R&eset",     "html_input_reset");
+   menu_append_item(popup, "S&ubmit",    "html_input_submit");
+
+   
+   % ^CL...  Lists (<ul>...</ul>)
+   popup = new_popup(menu, "&Lists");
+   menu_append_item(popup, "Definition &List", "html_insert_with_2newlines", "dl");
+   menu_append_item(popup, "&Ordered List", "html_insert_with_2newlines", "ol");
+   menu_append_item(popup, "&Unordered List", "html_insert_with_2newlines", "ul");
+   menu_append_item(popup, "Di&r", "html_insert_with_2newlines", "dir");
+   menu_append_item(popup, "&Menu", "html_insert_with_2newlines", "menu");
+   menu_append_separator(popup);
+   menu_append_item(popup, "List &Item", "html_simple_insert", "li");
+   menu_append_item(popup, "Definition &Term", "html_simple_insert", "dt");
+   menu_append_item(popup, "&Definition", "html_simple_insert", "dd");
+
+   % ^CT... Tables
+   popup = new_popup(menu, "&Tables");
+   menu_append_item (popup, "&Table", "html_insert_with_2newlines", "table");
+   menu_append_item (popup, "&Row", "html_insert_with_2newlines", "tr");
+   menu_append_item (popup, "&Header", "html_simple_insert", "th");
+   menu_append_item (popup, "&Data", "html_simple_insert", "td");
+   
+   menu_append_separator(menu);
+
+   % Movement
+   popup = new_popup(menu, "&Edit");
+   menu_append_item(popup, "&Skip Tag", "html_skip_tag");
+   menu_append_item(popup, "&Bskip Tag", "html_bskip_tag");
+   menu_append_item(popup, "&Next Tag", "html_mark_next_tag");
+   menu_append_item(popup, "&Previous Tag", "html_mark_prev_tag");
+   menu_append_item(popup, "(Un)&Comment", "comment_region_or_line");
+   
+   % Special Characters
+   popup = new_popup(menu, "&Special Characters");
+   menu_append_item(popup, "&&",        "insert", "&amp;");
+   menu_append_item(popup, "&>",        "insert", "&gt;");
+   menu_append_item(popup, "&<",        "insert", "&lt;");
+   menu_append_item(popup, "&Space",    "insert", "&nbsp;");
+   menu_append_item(popup, "&Eurosign", "insert", "&euro;");
+}
+
+create_syntax_table (mode);
+define_syntax ("<", ">", '(', mode);     %  make these guys blink match
+define_syntax ("<>", '<', mode);
+define_syntax ("<!-", "-->", '%', mode);
+define_syntax ("A-Za-z&", 'w', mode);
+define_syntax ('#', '#', mode);
 
 #ifdef HAS_DFA_SYNTAX
 % The highlighting copes with comments, "&eth;" type things, and <argh> type
@@ -506,29 +635,29 @@
    dfa_define_highlight_rule (".", "normal", name);
    dfa_build_highlight_table (name);
 }
-dfa_set_init_callback (&setup_dfa_callback, "html");
+dfa_set_init_callback (&setup_dfa_callback, mode);
 %%% DFA_CACHE_END %%%
 #endif
 
-() = define_keywords ($1, "&gt&lt", 3);
-() = define_keywords ($1, "&ETH&amp&eth", 4);
-() = define_keywords ($1, strcat (
+() = define_keywords (mode, "&gt&lt", 3);
+() = define_keywords (mode, "&ETH&amp&eth", 4);
+() = define_keywords (mode, strcat (
 				  "&Auml&Euml&Iuml&Ouml&Uuml",
 				  "&auml&euml&iuml&nbsp&ouml&quot&uuml&yuml"
 				  ), 
 		      5);
 
-() = define_keywords ($1, strcat (
-				  "&AElig&Acirc&Aring&Ecirc&Icirc&Ocirc&THORN&Ucirc&acirc",
-				  "&aelig&aring&ecirc&icirc&ocirc&szlig&thorn&ucirc"
+() = define_keywords (mode, strcat (
+  "&AElig&Acirc&Aring&Ecirc&Icirc&Ocirc&THORN&Ucirc&acirc",
+  "&aelig&aring&ecirc&icirc&ocirc&szlig&thorn&ucirc"
 				  ), 
 		      6);
 
-() = define_keywords ($1, strcat (
-				  "&Aacute&Agrave&Atilde&Ccedil&Eacute&Egrave&Iacute&Igrave",
-				  "&Ntilde&Oacute&Ograve&Oslash&Otilde&Uacute&Ugrave&Yacute",
-				  "&aacute&agrave&atilde&ccedil&eacute&egrave&iacute&igrave",
-				  "&ntilde&oacute&ograve&oslash&otilde&uacute&ugrave&yacute"),
+() = define_keywords (mode, strcat (
+  "&Aacute&Agrave&Atilde&Ccedil&Eacute&Egrave&Iacute&Igrave",
+  "&Ntilde&Oacute&Ograve&Oslash&Otilde&Uacute&Ugrave&Yacute",
+  "&aacute&agrave&atilde&ccedil&eacute&egrave&iacute&igrave",
+  "&ntilde&oacute&ograve&oslash&otilde&uacute&ugrave&yacute"),
 		      7);
 
 %!%+
@@ -538,17 +667,18 @@
 %\description
 % \var{html_mode} is a mode designed for editing HTML files.  
 % If a region is defined (i.e., if a mark is set), many HTML
-% tags will insert around the region, e.g. '<B>' and '</B>'.
+% tags will insert around the region, e.g. '<b>' and '</b>'.
 % 
-% Keybindings begin with ^C and are grouped according to function:
-%     ^CA...  Anchors (<A>...</A>)
-%     ^CD...  Definition lists (<DL>...</DL>)
+% Keybindings begin with ^C (actually, with _Reserved_Key_Prefix) 
+% and are grouped according to function:
+%     ^CA...  Anchors (<a>...</a>)
+%     ^CD...  Definition lists (<dl>...</dl>)
 %     ^CF...  Forms (<form>...</form>)
 %     ^CH...  Headings, document type, etc.
 %     ^CI...  Images
-%     ^CL...  Lists (<UL>...</UL>)
-%     ^CP...  Paragraph styles, etc. (<P>, <BR>, <HR>, <ADDRESS>, etc.)
-%     ^CS...  Character styles (<EM>, <STRONG>, <B>, <I>, etc.)
+%     ^CL...  Lists (<ul>...</ul>)
+%     ^CP...  Paragraph styles, etc. (<p>, <br>, <hr>, <address>, etc.)
+%     ^CS...  Character styles (<em>, <strong>, <b>, <i>, etc.)
 %     ^CT...  Tables
 % Additionally, some special movement commands and miscellaneous
 % characters are defined:
@@ -562,19 +692,21 @@
 %     ^C<enter> insert HMTL text for '<br>'
 %     ^C<space> insert HMTL text for NonBreakableSPace
 %     ^Ce     insert HMTL text for 'Eurosymbol'
-%     ^CC     insert HTML comment (around region, if marked)
+%     ^CC     (un)comment region (if marked) or line
 % 
 % For a complete list of keybindings, use \var{describe_bindings}.
 % 
 % This function calls \var{html_mode_hook} if it exists.
 %!%-
-define html_mode ()
+public define html_mode ()
 {
-   variable html = "html";
-   
-   set_mode(html, 1);
+   set_mode(mode, 1);
    set_buffer_hook ("par_sep", "html_paragraph_separator");
-   use_syntax_table (html);
-   use_keymap (html);
+   mode_set_mode_info (mode, "init_mode_menu", &html_menu);
+   use_syntax_table (mode);
+   use_keymap (mode);
    run_mode_hooks ("html_mode_hook");
 }

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]