+ execute ":!pandoc " . cssopts . " --self-contained --toc '" . @% . "' -o '" . @% . "'.html"
+endfunction
+
+
+function RunMarkdownpy(prog)
+ execute ":!" . a:prog . " " . @% . " > " . @% . ".html"
+endfunction
+
+
+function RunAsciidoctor()
+ execute ":!asciidoctor " . @%
+ if executable("asciidoctor-pdf")
+ execute ":!asciidoctor-pdf " . @%
+ elseif executable("asciidoctor")
+ execute ":!asciidoctor " . @%
+ endif
+endfunction
+
+function RunAsciidoctorPdf()
+ execute ":!asciidoctor-pdf " . @%
+endfunction
+
+
+function RunMarkdown()
+ if executable("pandoc")
+ call RunPandoc()
+ elseif executable("markdown2")
+ call RunMarkdownpy("markdown2")
+ elseif executable("markdown_py")
+ call RunMarkdownpy("markdown_py")
+ else
+ echo "No markdown implementation found."
+ endif
+endfunction
+
+
+function RunAsciidoc()
+ if executable("asciidoctor-pdf")
+ call RunAsciidoctorPdf()
+ elseif executable("asciidoctor")
+ call RunAsciidoctor()
+ else
+ echo "No asciidoc implementation found."
+ endif
+endfunction
+
+
+function OnBattery()
+ if has('macunix')
+ return match(system('pmset -g batt'), "Now drawing from 'Battery Power'") != -1
+ elseif has('unix')
+ if filereadable('/sys/class/power_supply/AC/online')
+ return readfile('/sys/class/power_supply/AC/online') == ['0']
+ endif
+ endif
+ return 0