X-Git-Url: https://git.sthu.org/?p=vimconf.git;a=blobdiff_plain;f=macros.vim;h=b33bf4da65992365e37c3886d23716cc993d43ce;hp=dd0b28dd605d6cfc81db27bbb59e35b7bc386ed7;hb=940c5d4d85492624fab8c01bfd8c98e3eadadc42;hpb=80e8ae230847c2d518a6274abdde5ec83117293c diff --git a/macros.vim b/macros.vim index dd0b28d..b33bf4d 100644 --- a/macros.vim +++ b/macros.vim @@ -10,6 +10,11 @@ function TexTransUmlaute() execute ':%s/²/\^2/&' endfunction +function! s:texTableBfEntries() + execute 's/\( *\)\([^ &][^&]*[^ &]\)\( \+\)/\1\\textbf{\2}\3/g' +endfunction + +command! -range TexTableBfEntries call s:texTableBfEntries() "Open current file with a specific program function OpenIn(prog) @@ -93,7 +98,51 @@ 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 RunAsciidoctor() + execute ":!asciidoctor " . @% +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") + 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 endfunction