|
From: | Rik |
Subject: | Re: option for enabling/disabling auto-suggest feature |
Date: | Tue, 19 Jun 2018 09:54:25 -0700 |
On 06/17/2018 11:58 AM, Sudeepam Pandey
wrote:
As a first pass, I would implement exactly the methodology we have for missing_function_hook. In pt-id.cc the function is void tree_identifier::eval_undefined_error (void) { int l = line (); int c = column (); maybe_missing_function_hook (name ()); if (l == -1 && c == -1) error_with_id ("Octave:undefined-function", "'%s' undefined", name ().c_str ()); else error_with_id ("Octave:undefined-function", "'%s' undefined near line %d column %d", name ().c_str (), l, c); } The list of calls to error() in graphics.cc above should be examined to find only the ones that elicit "unknown property". For these errors I would create a local function err_unknown_property(). err_unknown_property would be the analog to eval_undefined_error above. It would first call maybe_missing_property_hook (name ()) and then call error_with_id(). The function maybe_missing_property_hook should look like maybe_missing_function_hook in variables.cc void maybe_missing_function_hook (const std::string& name) { // Don't do this if we're handling errors. if (buffer_error_messages == 0 && ! Vmissing_function_hook.empty ()) { octave::symbol_table& symtab = octave::__get_symbol_table__ ("maybe_missing_function_hook"); octave_value val = symtab.find_function (Vmissing_function_hook); if (val.is_defined ()) { // Ensure auto-restoration. octave::unwind_protect frame; frame.protect_var (Vmissing_function_hook); // Clear the variable prior to calling the function. const std::string func_name = Vmissing_function_hook; Vmissing_function_hook.clear (); // Call. octave::feval (func_name, octave_value (name)); } } } You will also need something like this from variables.cc adapted to graphics.cc static std::string Vmissing_function_hook = "__unimplemented__"; DEFUN (missing_function_hook, args, nargout, doc: /* -*- texinfo -*- @deftypefn {} address@hidden =} missing_function_hook () @deftypefnx {} address@hidden =} missing_function_hook (@var{new_val}) @deftypefnx {} {} missing_function_hook (@var{new_val}, "local") Query or set the internal variable that specifies the function to call when an unknown identifier is requested. When called from inside a function with the @qcode{"local"} option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function. @seealso{missing_component_hook} @end deftypefn */) { return SET_INTERNAL_VARIABLE (missing_function_hook); } Hope this helps, Rik
|
[Prev in Thread] | Current Thread | [Next in Thread] |