neomake: Battery-dependent config
[vimconf.git] / macros.vim
index dd0b28dd605d6cfc81db27bbb59e35b7bc386ed7..58599670c737d4e4f01f920551b31a873f571155 100644 (file)
@@ -93,7 +93,35 @@ function RunPandoc()
     let cssopts = "-c pandoc.css"
   endif
 
-  execute ":!pandoc " . cssopts . " --self-contained --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')
+    return readfile('/sys/class/power_supply/AC/online') == ['0']
+  endif
+  return 0
 endfunction