home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.996 < prev    next >
Encoding:
Internet Message Format  |  2013-05-20  |  13.7 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.996
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.996
  11. Problem:    Python: Can't check types of what is returned by bindeval().
  12. Solution:   Add vim.List, vim.Dictionary and vim.Function types. (ZyX)
  13. Files:        runtime/doc/if_pyth.txt, src/if_py_both.h, src/testdir/test86.in,
  14.         src/testdir/test86.ok, src/testdir/test87.in,
  15.         src/testdir/test87.ok
  16.  
  17.  
  18. *** ../vim-7.3.995/runtime/doc/if_pyth.txt    2013-05-17 16:39:59.000000000 +0200
  19. --- runtime/doc/if_pyth.txt    2013-05-21 19:21:58.000000000 +0200
  20. ***************
  21. *** 11,19 ****
  22.   3. Buffer objects                |python-buffer|
  23.   4. Range objects                |python-range|
  24.   5. Window objects                |python-window|
  25. ! 6. pyeval(), py3eval() Vim functions        |python-pyeval|
  26. ! 7. Dynamic loading                |python-dynamic|
  27. ! 8. Python 3                    |python3|
  28.   
  29.   {Vi does not have any of these commands}
  30.   
  31. --- 11,20 ----
  32.   3. Buffer objects                |python-buffer|
  33.   4. Range objects                |python-range|
  34.   5. Window objects                |python-window|
  35. ! 6. Tab page objects                |python-tabpage|
  36. ! 7. pyeval(), py3eval() Vim functions        |python-pyeval|
  37. ! 8. Dynamic loading                |python-dynamic|
  38. ! 9. Python 3                    |python3|
  39.   
  40.   {Vi does not have any of these commands}
  41.   
  42. ***************
  43. *** 176,182 ****
  44.          list or dictionary. Thus modifications to these objects imply 
  45.          modifications of the original.
  46.   
  47. !        Additionally, vimlist and vimdictionary type have read-write 
  48.          `.locked` attribute that returns
  49.            Value           Meaning ~
  50.            zero            Variable is not locked
  51. --- 177,183 ----
  52.          list or dictionary. Thus modifications to these objects imply 
  53.          modifications of the original.
  54.   
  55. !        Additionally, vim.List and vim.Dictionary type have read-write 
  56.          `.locked` attribute that returns
  57.            Value           Meaning ~
  58.            zero            Variable is not locked
  59. ***************
  60. *** 189,202 ****
  61.          case these locks are ignored by anything except |:let|: |extend()| 
  62.          does not care, neither does python interface).
  63.   
  64. !        Vimdictionary type also supports `.scope` attribute which is one of
  65.            Value              Meaning ~
  66.            zero               Dictionary is not a scope one
  67.            vim.VAR_DEF_SCOPE  Function-local or global scope dictionary
  68.            vim.VAR_SCOPE      Other scope dictionary
  69.   
  70.       2. if expression evaluates to a function reference, then it returns 
  71. !        callable vimfunction object. Use self keyword argument to assign 
  72.          |self| object for dictionary functions.
  73.   
  74.       Note: this function has the same behavior as |lua-eval| (except that 
  75. --- 190,204 ----
  76.          case these locks are ignored by anything except |:let|: |extend()| 
  77.          does not care, neither does python interface).
  78.   
  79. !        vim.Dictionary type also supports `.scope` attribute which is one 
  80. !        of
  81.            Value              Meaning ~
  82.            zero               Dictionary is not a scope one
  83.            vim.VAR_DEF_SCOPE  Function-local or global scope dictionary
  84.            vim.VAR_SCOPE      Other scope dictionary
  85.   
  86.       2. if expression evaluates to a function reference, then it returns 
  87. !        callable vim.Function object. Use self keyword argument to assign 
  88.          |self| object for dictionary functions.
  89.   
  90.       Note: this function has the same behavior as |lua-eval| (except that 
  91. ***************
  92. *** 205,210 ****
  93. --- 207,216 ----
  94.             relying on outputs of vim.eval() being a copy of original or 
  95.             vim.eval("1") returning a string.
  96.   
  97. +     You can use "List", "Dictionary" and "Function" vim module attributes 
  98. +     to test whether object has given type. These types are currently not 
  99. +     subclassable, neither they contain constructors, so you can use them 
  100. +     only for checks like `isinstance(obj, vim.List)`.
  101.   
  102.   
  103.   Error object of the "vim" module
  104. ***************
  105. *** 302,307 ****
  106. --- 308,316 ----
  107.       buffer-local options and |python-window| objects to access to
  108.       window-local options.
  109.   
  110. +     Type of this object is available via "Options" attribute of vim 
  111. +     module.
  112.   Output from Python                    *python-output*
  113.       Vim displays all Python code output in the Vim message area.  Normal
  114.       output appears as information messages, and error output appears as
  115. ***************
  116. *** 371,376 ****
  117. --- 380,387 ----
  118.   A trailing '\n' is allowed and ignored, so that you can do: >
  119.       :py b.append(f.readlines())
  120.   
  121. + Buffer object type is available using "Buffer" attribute of vim module.
  122.   Examples (assume b is the current buffer) >
  123.       :py print b.name        # write the buffer file name
  124.       :py b[0] = "hello!!!"        # replace the top line
  125. ***************
  126. *** 412,417 ****
  127. --- 423,430 ----
  128.               for Python's built-in list objects.
  129.       r.append(list, nr)  Idem, after line "nr"
  130.   
  131. + Range object type is available using "Range" attribute of vim module.
  132.   Example (assume r is the current range):
  133.       # Send all lines in a range to the default printer
  134.       vim.command("%d,%dhardcopy!" % (r.start+1,r.end+1))
  135. ***************
  136. *** 456,461 ****
  137. --- 469,476 ----
  138.   The height attribute is writable only if the screen is split horizontally.
  139.   The width attribute is writable only if the screen is split vertically.
  140.   
  141. + Window object type is available using "Window" attribute of vim module.
  142.   ==============================================================================
  143.   6. Tab page objects                    *python-tabpage*
  144.   
  145. ***************
  146. *** 474,487 ****
  147.       vars        The tab page |t:| variables.
  148.       window        Current tabpage window.
  149.   
  150.   ==============================================================================
  151. ! 6. pyeval() and py3eval() Vim functions            *python-pyeval*
  152.   
  153.   To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()| 
  154.   functions to evaluate Python expressions and pass their values to VimL.
  155.   
  156.   ==============================================================================
  157. ! 7. Dynamic loading                    *python-dynamic*
  158.   
  159.   On MS-Windows the Python library can be loaded dynamically.  The |:version|
  160.   output then includes |+python/dyn|.
  161. --- 489,504 ----
  162.       vars        The tab page |t:| variables.
  163.       window        Current tabpage window.
  164.   
  165. + TabPage object type is available using "TabPage" attribute of vim module.
  166.   ==============================================================================
  167. ! 7. pyeval() and py3eval() Vim functions            *python-pyeval*
  168.   
  169.   To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()| 
  170.   functions to evaluate Python expressions and pass their values to VimL.
  171.   
  172.   ==============================================================================
  173. ! 8. Dynamic loading                    *python-dynamic*
  174.   
  175.   On MS-Windows the Python library can be loaded dynamically.  The |:version|
  176.   output then includes |+python/dyn|.
  177. ***************
  178. *** 498,504 ****
  179.   sure edit "gvim.exe" and search for "python\d*.dll\c".
  180.   
  181.   ==============================================================================
  182. ! 8. Python 3                        *python3*
  183.   
  184.                               *:py3* *:python3*
  185.   The `:py3` and `:python3` commands work similar to `:python`.  A simple check
  186. --- 515,521 ----
  187.   sure edit "gvim.exe" and search for "python\d*.dll\c".
  188.   
  189.   ==============================================================================
  190. ! 9. Python 3                        *python3*
  191.   
  192.                               *:py3* *:python3*
  193.   The `:py3` and `:python3` commands work similar to `:python`.  A simple check
  194. *** ../vim-7.3.995/src/if_py_both.h    2013-05-21 19:10:56.000000000 +0200
  195. --- src/if_py_both.h    2013-05-21 19:21:58.000000000 +0200
  196. ***************
  197. *** 4245,4250 ****
  198. --- 4245,4259 ----
  199.       {"windows",  (PyObject *)(void *)&TheWindowList},
  200.       {"tabpages", (PyObject *)(void *)&TheTabPageList},
  201.       {"current",  (PyObject *)(void *)&TheCurrent},
  202. +     {"Buffer",     (PyObject *)&BufferType},
  203. +     {"Range",      (PyObject *)&RangeType},
  204. +     {"Window",     (PyObject *)&WindowType},
  205. +     {"TabPage",    (PyObject *)&TabPageType},
  206. +     {"Dictionary", (PyObject *)&DictionaryType},
  207. +     {"List",       (PyObject *)&ListType},
  208. +     {"Function",   (PyObject *)&FunctionType},
  209. +     {"Options",    (PyObject *)&OptionsType},
  210.   };
  211.   
  212.   typedef int (*object_adder)(PyObject *, const char *, PyObject *);
  213. *** ../vim-7.3.995/src/testdir/test86.in    2013-05-17 13:37:57.000000000 +0200
  214. --- src/testdir/test86.in    2013-05-21 19:21:58.000000000 +0200
  215. ***************
  216. *** 631,640 ****
  217.   cb.append('Current line: ' + repr(vim.current.line))
  218.   for b in vim.buffers:
  219.       if b is not cb:
  220. !         vim.command('bwipeout! ' + b.number)
  221.   EOF
  222.   :tabonly!
  223.   :only!
  224.   :endfun
  225.   :"
  226.   :call Test()
  227. --- 631,656 ----
  228.   cb.append('Current line: ' + repr(vim.current.line))
  229.   for b in vim.buffers:
  230.       if b is not cb:
  231. !         vim.command('bwipeout! ' + str(b.number))
  232.   EOF
  233.   :tabonly!
  234.   :only!
  235. + :"
  236. + :" Test types
  237. + py << EOF
  238. + for expr, attr in (
  239. +     ('vim.vars',                         'Dictionary'),
  240. +     ('vim.options',                      'Options'),
  241. +     ('vim.bindeval("{}")',               'Dictionary'),
  242. +     ('vim.bindeval("[]")',               'List'),
  243. +     ('vim.bindeval("function(\'tr\')")', 'Function'),
  244. +     ('vim.current.buffer',               'Buffer'),
  245. +     ('vim.current.range',                'Range'),
  246. +     ('vim.current.window',               'Window'),
  247. +     ('vim.current.tabpage',              'TabPage'),
  248. + ):
  249. +     cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
  250. + EOF
  251.   :endfun
  252.   :"
  253.   :call Test()
  254. *** ../vim-7.3.995/src/testdir/test86.ok    2013-05-17 16:18:27.000000000 +0200
  255. --- src/testdir/test86.ok    2013-05-21 19:21:58.000000000 +0200
  256. ***************
  257. *** 333,339 ****
  258.   Current tab pages:
  259.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  260.     Windows:
  261. !     <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (954, 0)
  262.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  263.     Windows:
  264.       <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
  265. --- 333,339 ----
  266.   Current tab pages:
  267.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  268.     Windows:
  269. !     <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (970, 0)
  270.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  271.     Windows:
  272.       <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
  273. ***************
  274. *** 359,361 ****
  275. --- 359,370 ----
  276.   Current window: <window 0>
  277.   Current buffer: <buffer test86.in>
  278.   Current line: 'Type error at assigning None to vim.current.buffer'
  279. + vim.vars:Dictionary:True
  280. + vim.options:Options:True
  281. + vim.bindeval("{}"):Dictionary:True
  282. + vim.bindeval("[]"):List:True
  283. + vim.bindeval("function('tr')"):Function:True
  284. + vim.current.buffer:Buffer:True
  285. + vim.current.range:Range:True
  286. + vim.current.window:Window:True
  287. + vim.current.tabpage:TabPage:True
  288. *** ../vim-7.3.995/src/testdir/test87.in    2013-05-17 13:37:57.000000000 +0200
  289. --- src/testdir/test87.in    2013-05-21 19:21:58.000000000 +0200
  290. ***************
  291. *** 622,627 ****
  292. --- 622,643 ----
  293.   EOF
  294.   :tabonly!
  295.   :only!
  296. + :"
  297. + :" Test types
  298. + py3 << EOF
  299. + for expr, attr in (
  300. +     ('vim.vars',                         'Dictionary'),
  301. +     ('vim.options',                      'Options'),
  302. +     ('vim.bindeval("{}")',               'Dictionary'),
  303. +     ('vim.bindeval("[]")',               'List'),
  304. +     ('vim.bindeval("function(\'tr\')")', 'Function'),
  305. +     ('vim.current.buffer',               'Buffer'),
  306. +     ('vim.current.range',                'Range'),
  307. +     ('vim.current.window',               'Window'),
  308. +     ('vim.current.tabpage',              'TabPage'),
  309. + ):
  310. +     cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
  311. + EOF
  312.   :endfun
  313.   :"
  314.   :call Test()
  315. *** ../vim-7.3.995/src/testdir/test87.ok    2013-05-21 18:19:33.000000000 +0200
  316. --- src/testdir/test87.ok    2013-05-21 19:21:58.000000000 +0200
  317. ***************
  318. *** 322,328 ****
  319.   Current tab pages:
  320.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  321.     Windows:
  322. !     <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (930, 0)
  323.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  324.     Windows:
  325.       <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
  326. --- 322,328 ----
  327.   Current tab pages:
  328.     <tabpage 0>(1): 1 windows, current is <window object (unknown)>
  329.     Windows:
  330. !     <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (946, 0)
  331.     <tabpage 1>(2): 1 windows, current is <window object (unknown)>
  332.     Windows:
  333.       <window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
  334. ***************
  335. *** 348,350 ****
  336. --- 348,359 ----
  337.   Current window: <window 0>
  338.   Current buffer: <buffer test87.in>
  339.   Current line: 'Type error at assigning None to vim.current.buffer'
  340. + vim.vars:Dictionary:True
  341. + vim.options:Options:True
  342. + vim.bindeval("{}"):Dictionary:True
  343. + vim.bindeval("[]"):List:True
  344. + vim.bindeval("function('tr')"):Function:True
  345. + vim.current.buffer:Buffer:True
  346. + vim.current.range:Range:True
  347. + vim.current.window:Window:True
  348. + vim.current.tabpage:TabPage:True
  349. *** ../vim-7.3.995/src/version.c    2013-05-21 19:10:56.000000000 +0200
  350. --- src/version.c    2013-05-21 19:48:38.000000000 +0200
  351. ***************
  352. *** 730,731 ****
  353. --- 730,733 ----
  354.   {   /* Add new patch number below this line */
  355. + /**/
  356. +     996,
  357.   /**/
  358.  
  359. -- 
  360. SUPERIMPOSE "England AD 787".  After a few more seconds we hear hoofbeats in
  361. the distance.  They come slowly closer.  Then out of the mist comes KING
  362. ARTHUR followed by a SERVANT who is banging two half coconuts together.
  363.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  364.  
  365.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  366. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  367. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  368.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  369.