X-Git-Url: https://git.sthu.org/?p=vimconf.git;a=blobdiff_plain;f=macros.vim;h=046e381283aef870c7ebc0b50008867ff8551ecd;hp=1397f0f3f580b08d579c5c564cb5cebada048d98;hb=46aa2f3bae61870b8360e8a22aa11d8786cc19d8;hpb=dffcffd5d9cc9f49219eb0855028af85a71fb25b diff --git a/macros.vim b/macros.vim index 1397f0f..046e381 100644 --- a/macros.vim +++ b/macros.vim @@ -90,10 +90,40 @@ function RunPandoc() " If pandoc.css exists, use it let cssopts = "" if findfile("pandoc.css", ".") == "pandoc.css" - let cssopts = "-c pandoc.css --self-contained" + let cssopts = "-c pandoc.css" endif - execute ":!pandoc " . cssopts . " --toc " . @% . " -o " . @% . ".html" + execute ":!pandoc " . cssopts . " --self-contained --toc '" . @% . "' -o '" . @% . "'.html" +endfunction + + +function RunMarkdownpy(prog) + execute ":!" . a:prog . " " . @% . " > " . @% . ".html" +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 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 endfunction