An alternative to including all local functions in the temp file is something like this:
1. Find the local function names referred to in the region being evaluated. The current version of matlab-shell-region->script does this. Let's call this list included-functions. 2. Find function calls to other local functions for each function in this list. Add these function names to included-functions. 3. Repeat step 2 until included-functions doesn't change. We've now traversed the dependency chain of local functions beginning with the region to be evaluated. 4. Insert all functions in included-functions at the end of the temp file. I can probably code this up but I'd like to know what Eric thinks first. Karthik Uwe Brauer <o...@mat.ucm.es> writes: >>>> "KC" == Karthik Chikmagalur <karthikchikmaga...@gmail.com> writes: > >> Hi, > >> I'm having trouble using matlab-shell-region->script when my script >> is structured as follows, and I call >> matlab-shell-run-region-or-line on the function call: > >> %---- 8< ---- >> %% Function call >> func2(x) > >> %% Local functions >> function y = func1(x) >> y = x * 2; >> end > >> function z = func2(x) >> y = func1(x); >> z = y + 1; >> end >> %---- 8< ---- > >> When I call func2(x), matlab-shell-region->script copies over only >> func2 to the temporary file, even though func2 requires func1 to be >> defined. > > > Thanks, I was not aware of that problem > >> This probably makes the call to matlab-shell more expensive, but I >> think this should be the default behavior to avoid subtle failures >> like this. > > It looks fine to me, but I only deal with relatively small files. What > do others think, especially Eric, who provided the original code? > > Regards > > Uwe _______________________________________________ Matlab-emacs-discuss mailing list Matlab-emacs-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss