# HG changeset patch # User Soren Hauberg # Date 1234425036 -3600 # Node ID f44de8c0aac60e2ae5adb1ad1929515e9e2cdda0 # Parent 3cedb606145dea4884c66479bf7e05b5ef9cc89a scripts/help/lookfor.m: Adapt to new cache scheme. diff -r 3cedb606145d -r f44de8c0aac6 scripts/ChangeLog --- a/scripts/ChangeLog Wed Feb 11 10:14:58 2009 -0500 +++ b/scripts/ChangeLog Thu Feb 12 08:50:36 2009 +0100 @@ -1,3 +1,7 @@ +2009-02-12 Soren Hauberg + + * help/lookfor.m: Adapt to new cache scheme. + 2009-02-11 Jaroslav Hajek * general/sortrows.m: Employ __sortrows_idx__ when applicable, diff -r 3cedb606145d -r f44de8c0aac6 scripts/help/lookfor.m --- a/scripts/help/lookfor.m Wed Feb 11 10:14:58 2009 -0500 +++ b/scripts/help/lookfor.m Thu Feb 12 08:50:36 2009 +0100 @@ -54,70 +54,77 @@ endif str = lower (str); - ## Search operators, keywords, and built-ins - cache_file = fullfile (octave_config_info.datadir, "builtin_cache.mat"); + ## Search functions, operators, and keywords that come with Octave + cache_file = fullfile (octave_config_info.datadir, "etc", "DOC"); if (exist (cache_file, "file")) [fun, help_text] = search_cache (str, cache_file, search_type); + had_core_cache = true; else fun = help_text = {}; + had_core_cache = false; endif ## Search functions in path + pathorig = __pathorig__ (); p = path (); idx = find (p == pathsep ()); prev_idx = 1; for n = 1:length (idx) f = p (prev_idx:idx (n)-1); - cache_file = fullfile (f, "help_cache.mat"); - if (exist (cache_file, "file")) - ## We have a cache. Read it and search it! - [funs, hts] = search_cache (str, cache_file, search_type); - fun (end+1:end+length (funs)) = funs; - help_text (end+1:end+length (hts)) = hts; - else + + ## Should we search the directory or has it been covered by the cache? + if (!had_core_cache || isempty (findstr (f, pathorig))) + cache_file = fullfile (f, "DOC"); + if (exist (cache_file, "file")) + ## We have a cache in the directory, then read it and search it! + [funs, hts] = search_cache (str, cache_file, search_type); + fun (end+1:end+length (funs)) = funs; + help_text (end+1:end+length (hts)) = hts; + else ## We don't have a cache. Search files - funs_in_f = __list_functions__ (f); - for m = 1:length (funs_in_f) - fn = funs_in_f {m}; + funs_in_f = __list_functions__ (f); + for m = 1:length (funs_in_f) + fn = funs_in_f {m}; - ## Skip files that start with __ - if (length (fn) > 2 && strcmp (fn (1:2), "__")) - continue; - endif + ## Skip files that start with __ + if (length (fn) > 2 && strcmp (fn (1:2), "__")) + continue; + endif - ## Extract first sentence - try - first_sentence = get_first_help_sentence (fn); - status = 0; - catch - status = 1; - end_try_catch + ## Extract first sentence + try + first_sentence = get_first_help_sentence (fn); + status = 0; + catch + status = 1; + end_try_catch - if (search_type == 2) # search entire help text - [text, format] = get_help_text (fn); + if (search_type == 2) # search entire help text + [text, format] = get_help_text (fn); - ## Take action depending on help text format - switch (lower (format)) - case "plain text" - status = 0; - case "texinfo" - [text, status] = makeinfo (text, "plain text"); - case "html" - [text, status] = strip_html_tags (text); - otherwise - status = 1; - endswitch + ## Take action depending on help text format + switch (lower (format)) + case "plain text" + status = 0; + case "texinfo" + [text, status] = makeinfo (text, "plain text"); + case "html" + [text, status] = strip_html_tags (text); + otherwise + status = 1; + endswitch - elseif (status == 0) # only search the first sentence of the help text - text = first_sentence; - endif + elseif (status == 0) # only search the first sentence of the help text + text = first_sentence; + endif - ## Search the help text, if we can - if (status == 0 && !isempty (strfind (text, str))) - fun (end+1) = fn; - help_text (end+1) = first_sentence; - endif - endfor + ## Search the help text, if we can + if (status == 0 && !isempty (strfind (text, str))) + fun (end+1) = fn; + help_text (end+1) = first_sentence; + endif + endfor + endif endif prev_idx = idx (n) + 1; endfor