Hi oldcapecod!

(CC'ing HTML indent maintainer)

On Mo, 11 Feb 2013, oldcapecod wrote:

> OK, all that's needed is ...
> 
> filetype plugin indent on
> 
> in the .vimrc file.   

The indent html file causes this. There are actually two problems there. 

First the indent-expression already matches <img> tags, while it should 
only match <i> tags. This can be circumvented by this patch:

--- html.vim.orig   2013-02-12 12:57:48.416440086 +0100
+++ html.vim    2013-02-12 13:41:30.609442857 +0100
@@ -63,7 +63,7 @@
 call <SID>HtmlIndentPush('h4')
 call <SID>HtmlIndentPush('h5')
 call <SID>HtmlIndentPush('h6')
-call <SID>HtmlIndentPush('i')
+call <SID>HtmlIndentPush('i[^m]') " don't match img tag
 call <SID>HtmlIndentPush('iframe')
 call <SID>HtmlIndentPush('ins')
 call <SID>HtmlIndentPush('kbd')

Second, the HtmlIndentOpen and HtmlIndentClose() function use expansive 
regular expressions, that make vim hang on very long lines. We can tweak 
the RE a little bit (using \%( instead of \() but this doesn't help here 
much, so instead I would propose to generally skip lines that are, say 
longer > 1000 chars:

--- html.vim.orig       2013-02-12 12:57:48.416440086 +0100
+++ html.vim    2013-02-12 13:56:58.438043709 +0100
@@ -122,14 +122,20 @@
 
 " [-- count indent-increasing tags of line a:lnum --]
 fun! <SID>HtmlIndentOpen(lnum, pattern)
+    if strlen(getline(a:lnum)) > 1000 " skip expansive pattern match, return 0
+       return 0
+    endif
     let s = substitute('x'.getline(a:lnum),
-    \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
+    \ '.\{-}\(\%(<\)\%('.a:pattern.'\)\>\)', "\1", 'g')
     let s = substitute(s, "[^\1].*$", '', '')
     return strlen(s)
 endfun
 
 " [-- count indent-decreasing tags of line a:lnum --]
 fun! <SID>HtmlIndentClose(lnum, pattern)
+    if strlen(getline(a:lnum)) > 1000  " skip expansive pattern match, return 0
+       return 0
+    endif
     let s = substitute('x'.getline(a:lnum),
     \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
     let s = substitute(s, "[^\1].*$", '', '')


Alternatively, we could skipt the expansive .\{-} part (I am not sure, 
how essential this part is, it looks at a first glance superfluous and 
causes the many expansive backtracking to happen many many times:

--- html.vim.orig       2013-02-12 12:57:48.416440086 +0100
+++ html.vim    2013-02-12 13:58:36.290528940 +0100
@@ -123,7 +123,7 @@
 " [-- count indent-increasing tags of line a:lnum --]
 fun! <SID>HtmlIndentOpen(lnum, pattern)
     let s = substitute('x'.getline(a:lnum),
-    \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
+    \ '\(\%(<\)\%('.a:pattern.'\)\>\)', "\1", 'g')
     let s = substitute(s, "[^\1].*$", '', '')
     return strlen(s)
 endfun
@@ -131,7 +131,7 @@
 " [-- count indent-decreasing tags of line a:lnum --]
 fun! <SID>HtmlIndentClose(lnum, pattern)
     let s = substitute('x'.getline(a:lnum),
-    \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
+    \ '\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
     let s = substitute(s, "[^\1].*$", '', '')
     return strlen(s)
 endfun

The maintainer should decide which method fits best in here.


regards
Christian
-- 
Der geheimste Geist eines Autors verrät sich nicht in den bösen,
sondern in den schönsten Charakteren, die er immer mit der Schwäche
seiner Natur unwillkürlich begabt.
                -- Jean Paul

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui