Closed dbarnett closed 9 years ago
Or we could skip writing files entirely and use data URIs, something like:
call maktaba#syscall#Create([
\ 'sensible-browser',
\ printf('data:text/html,%s'", join(getline(1, '$')))]).Call()
I really like the data URI idea, but I'm concerned about length limits. Either the shell or the browser itself could impose a length limit, and we might lose content. I think a temp file will be more robust. In fact, when I ran into length limts before, a temp file was the suggested workaround.
I think I will save the file to a user-configurable location which defaults to somewhere in /tmp
.
Down the road, we could even add a flag for users who don't want to clean up the file automatically. Maybe we could add a :SyncopateOpenHtmlFile
command for those users.
There's probably an xdg dir that would be appropriate. XDG_TMP_DIR or XDG_DATA_DIR, perhaps?
I tried using SyncopateExportToBrowser on a file in /etc/ where I didn't have write access and got some errors:
and my browser opened to a nonexistent file (since the file was never written).
I think rather than writing the buffer from
:TOhtml
, it would be better to get the contents withgetline(1, '$')
and write them to a temp file.