]> Pileus Git - vpaste/commitdiff
Add custom modeline to top of file as well
authorAndy Spencer <andy753421@gmail.com>
Sat, 9 Mar 2013 21:17:31 +0000 (21:17 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 9 Mar 2013 21:17:31 +0000 (21:17 +0000)
This gives the custom modeline a chance to run first, that way if the
default modeline crashes the custom modeline is still used. We leave it
at the bottom too so that the custom modeline gets precedence if
everything is working OK.

index.cgi

index 0b7859e77c74ccb4d2021509f6d58211da0ba887..bbabd30b4e9f587c7d4bd5f100572cc74af36c01 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -116,7 +116,8 @@ function respond {
 function format {
        # Create a temp file with the provided modeline
        tmp="$(mktemp)"
-       sed "\$avim: $(get_modeline)" "$1" > "$tmp"
+       sed -e  "1ivim: $(get_modeline)" \
+           -e "\$avim: $(get_modeline)" "$1" > "$tmp"
 
        # Determine cache name
        md5="$(cat index.cgi vimrc "$tmp" /usr/bin/ex | md5sum -b)"
@@ -136,7 +137,7 @@ function format {
                        '+sil! set iconstring= ruf= stl= tal=' \
                        "+sil! set titlestring=$1\ -\ vpaste.net" \
                        '+sil! set noml' \
-                       '+sil! $d|'$2    \
+                       '+sil! 1d|$d|'$2 \
                        '+sil! %s/\r//g' \
                        '+sil! TOhtml'   \
                        "+sav! $out"     \