On Jan 16, 2008 3:59 PM, Ben Schmidt wrote:
>
> Charles E. Campbell, Jr. wrote:
> > I think it'd be a small thing -- but only Bram knows for sure.
> >
> > I'd like Decho (from my debugging plugin) to be able to report what
> > line/file/function it was called from so I can relate Decho output to
> > where it was generated.  Something like the following would do the trick:
>
> I personally would think that having a function that returns the call stack 
> as a
> list would be a better interface for this, but agree it could be handy info to
> have for plugin writers and for debugging vimscript generally.
>
> This should probably have been a new thread.
>
> Ben.

function C()
  echo expand("<sfile>")
endfunction

function B()
  echo expand("<sfile>")
  call C()
endfunction

function A()
  echo expand("<sfile>")
  call B()
endfunction

call A()

results in this being printed:

function A
function A..B
function A..B..C

So, you can easily make a function yourself returning the callstack,
something like:

function! CallStack()
  return split(substitute(expand("<sfile>"), '^\S\+\s', '', ''), '\.\.')
endfunction

HTH,
~Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui