Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor the PML fold expression.

  • Loading branch information...
commit 16064398d7ac4ae759fbe44daaadf9e0fe004a98 1 parent 31d7ff9
@nelstrom authored
Showing with 12 additions and 18 deletions.
  1. +12 −18 ftplugin/pml.vim
View
30 ftplugin/pml.vim
@@ -24,25 +24,19 @@ endif
" PML specific folding {{{1
let s:elements = ['sidebar', 'figure']
function! PmlFolds()
- if match(getline(v:lnum), "<sect1") >= 0
- return ">1"
- elseif match(getline(v:lnum), "</sect1") >= 0
- return "<1"
- elseif match(getline(v:lnum), "<sect2") >= 0
- return ">2"
- elseif match(getline(v:lnum), "</sect2") >= 0
- return "<2"
- elseif match(getline(v:lnum), "<sect3") >= 0
- return ">3"
- elseif match(getline(v:lnum), "</sect3") >= 0
- return "<3"
- elseif match(getline(v:lnum), "<figure") >= 0
- return "a1"
- elseif match(getline(v:lnum), "</figure") >= 0
- return "s1"
- elseif match(getline(v:lnum), "<sidebar") >= 0
+ let currentline = getline(v:lnum)
+ let openSection = '<sect\zs\d\>'
+ let closeSection = '<\/sect\zs\d\>'
+ let openElement = '<\zs\(' . join(s:elements, '\|') . '\)\>'
+ let closeElement = '<\/\zs\(' . join(s:elements, '\|') . '\)\>'
+
+ if match(currentline, openSection) >=0
+ return ">" . matchstr(currentline, openSection)
+ elseif match(currentline, closeSection) >=0
+ return "<" . matchstr(currentline, closeSection)
+ elseif match(currentline, openElement) >=0
return "a1"
- elseif match(getline(v:lnum), "</sidebar") >= 0
+ elseif match(currentline, closeElement) >=0
return "s1"
else
return "="
Please sign in to comment.
Something went wrong with that request. Please try again.