To: vim-dev@vim.org Subject: Patch 6.1.137 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.137 Problem: Converting to HTML has a clumsy way of dealing with tabs which may change the highlighting. Solution: Replace tabs with spaces after converting a line to HTML. (Preben Guldberg) Files: runtime/syntax/2html.vim *** ../vim61.136/runtime/syntax/2html.vim Mon Jan 7 22:24:33 2002 --- runtime/syntax/2html.vim Wed Jul 10 20:52:56 2002 *************** *** 1,6 **** " Vim syntax support file " Maintainer: Bram Moolenaar ! " Last Change: 2001 Dec 12 " (modified by David Ne\v{c}as (Yeti) ) " Transform a file into HTML, using the current syntax highlighting. --- 1,6 ---- " Vim syntax support file " Maintainer: Bram Moolenaar ! " Last Change: 2002 Jul 10 " (modified by David Ne\v{c}as (Yeti) ) " Transform a file into HTML, using the current syntax highlighting. *************** *** 130,135 **** --- 130,136 ---- let s:old_icon = &icon let s:old_et = &l:et let s:old_report = &report + let s:old_search = @/ set notitle noicon setlocal et set report=1000000 *************** *** 160,185 **** endif exe "normal a\n\n
\n\e"
  
! exe "normal \p"
  
  " List of all id's
  let s:idlist = ","
  
  " Loop over all lines in the original text
  let s:end = line("$")
  let s:lnum = 1
  while s:lnum <= s:end
  
!   " Get the current line, with tabs expanded to spaces when needed
!   " FIXME: What if it changes syntax highlighting?
    let s:line = getline(s:lnum)
-   if stridx(s:line, "\t") >= 0
-     exe s:lnum . "retab!"
-     let s:did_retab = 1
-     let s:line = getline(s:lnum)
-   else
-     let s:did_retab = 0
-   endif
    let s:len = strlen(s:line)
    let s:new = ""
  
--- 161,183 ----
  endif
  exe "normal a\n\n
\n\e"
  
! wincmd p
  
  " List of all id's
  let s:idlist = ","
  
+ let s:expandedtab = ' '
+ while strlen(s:expandedtab) < &ts
+   let s:expandedtab = s:expandedtab . ' '
+ endwhile
+ 
  " Loop over all lines in the original text
  let s:end = line("$")
  let s:lnum = 1
  while s:lnum <= s:end
  
!   " Get the current line
    let s:line = getline(s:lnum)
    let s:len = strlen(s:line)
    let s:new = ""
  
***************
*** 209,217 ****
        break
      endif
    endwhile
!   if s:did_retab
!     undo
!   endif
  
    exe "normal \pa" . strtrans(s:new) . "\n\e\p"
    let s:lnum = s:lnum + 1
--- 207,224 ----
        break
      endif
    endwhile
! 
!   " Expand tabs
!   let s:pad=0
!   let s:start = 0
!   let s:idx = stridx(s:line, "\t")
!   while s:idx >= 0
!     let s:i = &ts - ((s:start + s:pad + s:idx) % &ts)
!     let s:new = substitute(s:new, '\t', strpart(s:expandedtab, 0, s:i), '')
!     let s:pad = s:pad + s:i - 1
!     let s:start = s:start + s:idx + 1
!     let s:idx = stridx(strpart(s:line, s:start), "\t")
!   endwhile
  
    exe "normal \pa" . strtrans(s:new) . "\n\e\p"
    let s:lnum = s:lnum + 1
***************
*** 278,300 ****
    endif
  endwhile
  
! " Cleanup (we've already lost last user's pattern match highlighting)
  %s:\s\+$::e
- if has("extra_search")
-   nohlsearch
- endif
  
  " Restore old settings
  let &report = s:old_report
  let &title = s:old_title
  let &icon = s:old_icon
  let &paste = s:old_paste
! exe "normal \p"
  let &l:et = s:old_et
! exe "normal \p"
  
  " Save a little bit of memory (worths doing?)
! unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title
  unlet s:whatterm s:idlist s:lnum s:end s:fgc s:bgc
  unlet! s:col s:id s:attr s:len s:line s:new s:did_retab s:numblines
  delfunc s:HtmlColor
--- 285,305 ----
    endif
  endwhile
  
! " Cleanup
  %s:\s\+$::e
  
  " Restore old settings
  let &report = s:old_report
  let &title = s:old_title
  let &icon = s:old_icon
  let &paste = s:old_paste
! let @/ = s:old_search
! wincmd p
  let &l:et = s:old_et
! wincmd p
  
  " Save a little bit of memory (worths doing?)
! unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
  unlet s:whatterm s:idlist s:lnum s:end s:fgc s:bgc
  unlet! s:col s:id s:attr s:len s:line s:new s:did_retab s:numblines
  delfunc s:HtmlColor
*** ../vim61.136/src/version.c	Sun Jul 21 21:16:47 2002
--- src/version.c	Sun Jul 21 21:18:40 2002
***************
*** 608,609 ****
--- 608,611 ----
  {   /* Add new patch number below this line */
+ /**/
+     137,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
18. Your wife drapes a blond wig over your monitor to remind you of what she
    looks like.

 ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
\\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
 \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///