jed-users mailing list

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

[jed-users] slang function source lookup and view function


    I've found this useful and some of you may too.
    A partial solution to the lack of documentation in Jed can be reading
the source. This short script allows me to easily view at least those
functions for which the slang source is included.

These commands will build the database for you.
----------------------------------------------------------------
On Windows I've some GNU utilities installed and you'll want to split
on something besides ':' due to the drives being in the path.
grep -nH '^define \|^private define \|^public define ' \
    {G:/Jed/{lib,slsh},H:/docs/lnx/mike/jed}/*.sl |
    sed -e 's/\.sl:/\.sl;/;s/:d/;d/;s/:p/;p/;' > ~/jed/jed_func.lst

----------------------------------------------------------------
On Linux
grep -nH '^define \|^private define \|^public define ' \
    {/usr/share/{jed/lib,slsh},~/.jed}/*.sl  > ~/.jed/jed_func.lst
----------------------------------------------------------------

You'll likely need to tweek the paths.
Hope this helps someone.
Mike


%   /home/mike/.jed/see_src.sl   July 06, 2014   Mc
#   copyright Mike McClain  under GPL 2.0


%   look at source for functions in /usr/share/jed/lib/*.sl
define see_src ()
{   variable source_index = "/home/mike/.jed/jed_func.lst";

    %   get a function name
    variable func = read_mini("Function:", Null_String, Null_String);
    !if (strlen (func)) return;

    %   surround w/ ' ' for more acurate search
    func = strcat( " ", func, "[ (]" );

    %   find where it's defined
    !if( read_file( source_index ) )
    {   message ("see_src: Failed to read " + source_index);
        return;
    }
    %if( search_search_function (func) < 0 )
    !if (re_fsearch (func))
    {   message ( func + ": not found" );
        delbuf("jed_func.lst");
        return;
    }
    variable str = line_as_string();
    delbuf("jed_func.lst");

    %   str="abbrev.sl:40:define abbrev_mode ()"
    variable arr = strchop (str, ':', 0);
    variable file = arr[0], line = arr[1];

    %   open the file where the function is defined and jump there
    !if( find_file(file) )
    {   message ("see_src: Failed to open " + file);
        return;
    }

    set_readonly(1);
    set_mode("most", 0);

    goto_line( atoi(line) );
    %   leave the buffer for the user to close when done
}

%   put see_src in help menu
private define my_load_menu_popup_hook (menubar)
{   menu_append_item ("Global.&Help", "See Function &Source", "see_src");
}
append_to_hook ("load_popup_hooks", &my_load_menu_popup_hook);



--
A man cannot be said to succeed in this life who does not satisfy one friend.
    - Henry David Thoreau
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.


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