Просмотр исходного кода

Add `BufExplorer_eval()` and `BufExplorer_execute()` for debugging.

These can be used to view or modify script-local variables and invoke
script-local functions from outside the plugin.

Examples:

- Display the MRU data structure `s:bufMru`:

      :echo BufExplorer_eval('s:bufMru')

- Use `s:MRUGetItems()` to display buffer numbers from this structure in
  MRU-order:

      :echo BufExplorer_eval('s:MRUGetItems(s:bufMru,0)')

- Re-initialize `s:bufMru`:

      :call BufExplorer_execute('let s:bufMru = s:MRUNew(0)')
Michael Henry 10 месяцев назад
Родитель
Сommit
4ab055ad4f
1 измененных файлов с 15 добавлено и 0 удалено
  1. 15 0
      plugin/bufexplorer.vim

+ 15 - 0
plugin/bufexplorer.vim

@@ -1321,6 +1321,21 @@ let g:BufExplorer_title = "\[Buf\ List\]"
 call s:Set("g:bufExplorerResize", 1)
 call s:Set("g:bufExplorerMaxHeight", 25) " Handles dynamic resizing of the window.
 
+" Evaluate a Vimscript expression in the context of this file.
+" This enables debugging of script-local variables and functions from outside
+" the plugin, e.g.:
+"   :echo BufExplorer_eval('s:bufMru')
+function! BufExplorer_eval(expr)
+    return eval(a:expr)
+endfunction
+
+" Execute a Vimscript statement in the context of this file.
+" This enables setting script-local variables from outside the plugin, e.g.:
+"   :call BufExplorer_execute('let s:bufMru = s:MRUNew(0)')
+function! BufExplorer_execute(statement)
+    execute a:statement
+endfunction
+
 " function! to start display. Set the mode to 'winmanager' for this buffer.
 " This is to figure out how this plugin was called. In a standalone fashion
 " or by winmanager.