jed-users mailing list

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

Improval of help.sl


Hi,

I propose the following patch for help.sl. It (1) makes all commands are
indented at the same column, (2) splits the keymap in a global part and a
local part to make more visible which keys are mode specific and (3)
adds a short description of the command if available. The third part is
not very intelligent and takes much time, but maybe someone has an idea
how to improve it. (One might be caching.)

#v+
Index: help.sl
===================================================================
--- help.sl	(Revision 34)
+++ help.sl	(Arbeitskopie)
@@ -347,12 +347,97 @@
    pop2buf("*KeyBindings*");
    erase_buffer ();
    dump_bindings (map);
-   bob(); replace ("ESC [ A", "UP");
-   bob(); replace ("ESC [ B", "DOWN");
-   bob(); replace ("ESC [ C", "RIGHT");
-   bob(); replace ("ESC [ D", "LEFT");
-   bob(); replace ("ESC O P", "GOLD");
+
+   if (map != "global")
+   {
+       insert("\nInherited from the global keymap:\n");
+       push_spot();
+       dump_bindings("global");
+       pop_spot();
+
+       variable global_map = Assoc_Type[String_Type];
+       while ( not eobp() )
+       {
+           push_mark();
+           () = ffind("\t\t\t");
+           variable key = bufsubstr();
+           () = right(3);
+           push_mark();
+           eol();
+           global_map[key] = bufsubstr();
+           delete_line();
+       }
+
+       bob();
+       forever
+       {
+           push_mark();
+           () = ffind("\t\t\t");
+           key = bufsubstr();
+           if (key == "")
+             break;
+
+           if ( assoc_key_exists(global_map, key) )
+           {
+               () = right(3);
+               push_mark();
+               eol();
+               if (bufsubstr() == global_map[key])
+               {
+                   delete_line();
+                   push_spot();
+                   eob();
+                   insert(key + "\t\t\t" + global_map[key] + "\n");
+                   pop_spot();
+               }
+               else
+                 () = down(1);
+           }
+           else
+             () = down(1);
+       }
+   }
    bob();
+
+   replace ("ESC [ A", "UP");
+   replace ("ESC [ B", "DOWN");
+   replace ("ESC [ C", "RIGHT");
+   replace ("ESC [ D", "LEFT");
+   replace ("ESC O P", "GOLD");
+
+   do
+      if (ffind("\t\t\t") and what_column() > TAB)
+      {
+          if ( what_column() <= TAB*3 )
+            deln( (what_column()-1)/TAB );
+          else
+            deln(3);
+      }
+   while ( down(1) );
+   bob();
+
+   do
+      if ( ffind("\t\t\t") )
+      {
+          () = right(3);
+          push_mark();
+          !if ( ffind_char('(') )
+            eol();
+          variable fun = bufsubstr();
+          variable dsc = help_get_doc_string(fun);
+          pop;
+          if (dsc != NULL)
+          {
+              eol();
+              dsc = substr(dsc, is_substr(dsc, "\n SYNOPSIS\n ")+12,
+                           strlen(dsc) );
+              whitespace( 48 - what_column() );
+              insert(substr(dsc, 1, is_substr(dsc, "\n")-1) );
+          }
+      }
+   while ( down(1) );
+   bob();
+
    CASE_SEARCH = cse;
    set_buffer_modified_flag(0);
    pop2buf (buf);
#v-

Good night, Jörg.
-- 
Dummheit anprangern ist ungefährlich, weil sich niemand angegriffen fühlt.

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


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