plugins: Change easychair2 url
[vimconf.git] / macros.vim
index b33bf4da65992365e37c3886d23716cc993d43ce..1da3dae9c56080df7f1cdc01545f006bef4759ac 100644 (file)
@@ -78,9 +78,12 @@ endfunction
 
 
 function InsertIncludeGuardsWithoutEndif()
 
 
 function InsertIncludeGuardsWithoutEndif()
-  let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16)
-  execute "normal! i#ifndef " . gatename
-  execute "normal!   o#define " . gatename
+  " Build name of guard: Take filename, replace some chars by _ and
+  " prepend a random sequence to make guard robust against file name
+  " collisions.
+  let guardname = substitute(expand("%:t"), "[\\.-]", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16)
+  execute "normal! i#ifndef " . guardname
+  execute "normal! o#define " . guardname
 endfunction
 
 
 endfunction
 
 
@@ -109,6 +112,15 @@ endfunction
 
 function RunAsciidoctor()
   execute ":!asciidoctor " . @%
 
 function RunAsciidoctor()
   execute ":!asciidoctor " . @%
+  if executable("asciidoctor-pdf")
+    execute ":!asciidoctor-pdf " . @%
+  elseif executable("asciidoctor")
+    execute ":!asciidoctor " . @%
+  endif
+endfunction
+
+function RunAsciidoctorPdf()
+  execute ":!asciidoctor-pdf " . @%
 endfunction
 
 
 endfunction
 
 
@@ -126,7 +138,9 @@ endfunction
 
 
 function RunAsciidoc()
 
 
 function RunAsciidoc()
-  if executable("asciidoctor")
+  if executable("asciidoctor-pdf")
+    call RunAsciidoctorPdf()
+  elseif executable("asciidoctor")
     call RunAsciidoctor()
   else
     echo "No asciidoc implementation found."
     call RunAsciidoctor()
   else
     echo "No asciidoc implementation found."