comparison runtime/doc/if_pyth.txt @ 4407:2a166caf8709 v7.3.952

updated for version 7.3.952 Problem: Python: It's not easy to change window/buffer/tabpage. Solution: Add ability to assign to vim.current.{tabpage,buffer,window}. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Wed, 15 May 2013 15:51:08 +0200
parents cfd76908da25
children c16602758d84
comparison
equal deleted inserted replaced
4406:5fa162c3a23c 4407:2a166caf8709
240 < 240 <
241 vim.current *python-current* 241 vim.current *python-current*
242 An object providing access (via specific attributes) to various 242 An object providing access (via specific attributes) to various
243 "current" objects available in vim: 243 "current" objects available in vim:
244 vim.current.line The current line (RW) String 244 vim.current.line The current line (RW) String
245 vim.current.buffer The current buffer (RO) Buffer 245 vim.current.buffer The current buffer (RW) Buffer
246 vim.current.window The current window (RO) Window 246 vim.current.window The current window (RW) Window
247 vim.current.tabpage The current tab page (RO) TabPage 247 vim.current.tabpage The current tab page (RW) TabPage
248 vim.current.range The current line range (RO) Range 248 vim.current.range The current line range (RO) Range
249 249
250 The last case deserves a little explanation. When the :python or 250 The last case deserves a little explanation. When the :python or
251 :pyfile command specifies a range, this range of lines becomes the 251 :pyfile command specifies a range, this range of lines becomes the
252 "current range". A range is a bit like a buffer, but with all access 252 "current range". A range is a bit like a buffer, but with all access
253 restricted to a subset of lines. See |python-range| for more details. 253 restricted to a subset of lines. See |python-range| for more details.
254 254
255 Note: When assigning to vim.current.{buffer,window,tabpage} it expects
256 valid |python-buffer|, |python-window| or |python-tabpage| objects
257 respectively. Assigning triggers normal (with |autocommand|s)
258 switching to given buffer, window or tab page. It is the only way to
259 switch UI objects in python: you can't assign to
260 |python-tabpage|.window attribute. To switch without triggering
261 autocommands use >
262 py << EOF
263 saved_eventignore = vim.options['eventignore']
264 vim.options['eventignore'] = 'all'
265 try:
266 vim.current.buffer = vim.buffers[2] # Switch to buffer 2
267 finally:
268 vim.options['eventignore'] = saved_eventignore
269 EOF
270 <
255 vim.vars *python-vars* 271 vim.vars *python-vars*
256 vim.vvars *python-vvars* 272 vim.vvars *python-vvars*
257 Dictionary-like objects holding dictionaries with global (|g:|) and 273 Dictionary-like objects holding dictionaries with global (|g:|) and
258 vim (|v:|) variables respectively. Identical to `vim.bindeval("g:")`, 274 vim (|v:|) variables respectively. Identical to `vim.bindeval("g:")`,
259 but faster. 275 but faster.