François Pinard wrote:
> [Mikolaj Machowski]
>> [Mohsin]:
> 
>>> Vim only has syntax coloring with regexps.  Emacs has functions to 
>>> apply properties to text blocks, and I was hoping vim has something 
>>> comparable.
> 
>> Of course it is possible:
> 
>> :help  /\%l
>> :help  /\%c
> 
> Humph, not really!
> 
> Text properties in Emacs span text regions, which move, expand or shrink 
> while text is being edited outside or within them.  Besides 
> highlighting, text properties may also be used for making regions 
> invisible (fully collapsed, not using any estate on the display), 
> intangible (the cursor skips over them as if they were a single 
> character), and many other things as well.
> 
> Efficiently adjusting tons of text properties in a buffer is a 
> computational challenge: markers just cannot be used, as the time for 
> updating markers at each editing action is proportional to the number of 
> markers.  If I remember well, text boundaries for an Emacs buffer are 
> all held within a single heap structure.  I think some people called 
> them "priority queues", Python lovers may look for module "heapq", and 
> the boundaries only get updated when the cursor moves through them.  To 
> understand this, one should know that within Emacs, the buffer text is 
> split into the physical memory buffer as two parts on each end, with all 
> the free space (nicknamed "the hole") kept in the middle.  The cursor 
> coincides with the hole, moving the cursor moves bits of the text over 
> that hole.  The heap helps at quickly finding the nearest boundaries for 
> text properties, and updating them rather lazily, not far from the least 
> often possible.
> 
> I would not think (but I do not really know) that users could easily 
> reimplement equivalent features in Vim.  This particular problem 
> interests me somehow: I once wrote an Emacs package called `xxml.el' 
> which does a decent job at highlighting SGML, HTML and XML, or cleverly 
> refilling it (building over an astonishingly powerful packages named 
> PSGML, written by Lennart Staflin).  More than once, I pondered porting 
> this `xxml.el' to Vim, but as it heavily uses text properties, I would 
> have needed a replacement first.  Reimplementing PSGML for Vim would 
> have been a major undertaking as well, yet here, I would have went the 
> Python way, in a Python-enabled Vim.  Dreams, dreams, dreams... :-)
> 

[snip entire para Tony wrote.]

Tony,

Your comments aren’t applicable to Francois.

--Suresh


Reply via email to