Show marks in the statusline.
[profile.git] / .vimrc
diff --git a/.vimrc b/.vimrc
index d29cc40..14401a6 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -663,12 +663,37 @@ fun! Has_Unicode() "{{{2
 endfun "}}}2
 
 " Helper for status line.
+" Show file encoding
+func! Show_Encoding() "{{{2
+  let l:enc = &fenc
+  if l:enc == ""
+    let l:enc = &enc
+    if l:enc == ""
+      return ""
+    endif
+    let l:enc = '(' . l:enc . ')'
+  endif
+
+  if has("multi_byte")
+    if &bomb
+      if Has_Unicode()
+        let l:enc = l:enc . "☻"
+      else
+        let l:enc = l:enc . "@"
+      endif
+    endif
+  endif
+
+  return l:enc . ","
+endfun "}}}2
+
+" Helper for status line.
 " Show space, underscore or dollar sign depending on list mode.
 fun! Show_List() "{{{2
   call Iain_Vars()
   if w:iainlist == 0
     " No list.
-    return " "
+    return ""
   elseif Has_Unicode()
     if w:iainlist == 1
       " Just tabs.
@@ -793,14 +818,61 @@ fun! Show_SearchForward() "{{{2
   return ""
 endfun "}}}2
 
+" Helper for status line.
+" Show marks set in cursor line.
+fun! Show_Marks() "{{{2
+  if ! exists("g:iainsigns")
+    return ""
+  endif
+
+  let l:marks = ""
+
+  let l:signs = g:iainsigns
+  let l:sign = ""
+  let l:cursorline = line(".")
+  while strlen(l:signs)
+    let l:sign = matchstr(l:signs, '^[A-Za-z]\+\(:.\)*[.=>-][^ ]\+')
+    let l:sign = substitute(l:sign, '^[A-Za-z]\+', "", "")
+    let l:ascii = matchstr(l:sign, '^:.')
+    let l:mark = substitute(l:sign, '^\(:.\)*[.=>-]', "", "")
+    if strlen(l:ascii)
+      let l:ascii = substitute(l:ascii, '^:', "", "")
+    else
+      let l:ascii = l:mark
+    endif
+    let l:ascii = substitute(l:ascii, '"', '\\"', "")
+
+    if l:ascii == "o"
+      let l:line = "."
+    else
+      let l:line = "'" . l:ascii
+    endif
+
+    " Ignore cursor line which will always match.
+    if l:line != "."
+      if l:cursorline == line(l:line)
+        let l:marks = l:marks . l:mark
+      endif
+    endif
+
+    let l:signs = substitute(l:signs, '^[^ ]\+ *', "", "")
+  endwhile
+
+  if l:marks == ""
+    return ""
+  else
+    return "M:" . l:marks . " "
+  endif
+endfun "}}}2
+
 " Show the status line.
 fun! Show_StatusLine() "{{{2
   if ! has("statusline")
     return
   endif
   call Iain_Vars()
-  let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_List()}%{Show_Bind()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%{Show_VirtualEdit()}%{Show_Undo()}%Y%M%R%{Show_SearchForward()}]%{Show_Alt()}\ '
-  let l:sl3='L:%1*%4.6l%0*/%-4.6L\ C:%1*%3.6c%V%0*\ \|\ %P'
+  let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_Encoding()}%{Show_List()}%{Show_Bind()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%{Show_VirtualEdit()}%{Show_Undo()}%Y%M%R%{Show_SearchForward()}]%{Show_Alt()}\ '
+  let l:sl3='%{Show_Marks()}L:%1*%4.6l%0*/%-4.6L\ C:%1*%3.6c%V%0*\ \|\ %P'
   let l:hexformat='%b'
   if b:iainhex
     let l:hexformat='0\x%02B'