Re: :hardcopy not launching Preview

2023-07-03 Thread Lifepillar
On 2023-07-03, Bram Moolenaar  wrote:
> I suppose encrypting the file won't be possible, since the reader does
> not know how to decrypt it.  Or does the Preview app support encryption
> somehow?

Yes, macOS's Preview supports (at least some?) encrypted PDFs. I did
a quick test by encrypting a random PDF document with qpdf:

qpdf --encrypt PASSWORD OWNERPASSWORD 256 -- in.pdf out.pdf

and by opening out.pdf with Preview, which prompted for a password
before opening the document.

> The alternative is to not use a temp file but write the text through a
> pipe/socket.  That also avoids the need to find the right moment to
> delete the temp file.  Can we do this somehow?

With Preview? I don't think so. But if one wants to get fancy, the PDF
can be written to the system clipboard and then Preview can be asked to
create a new document from the clipboard's content (using AppleScript).
Then, the clipboard content can be erased.

Or, even better, one could create a (sufficiently large) RAM disk with
something like:

hdiutil attach -nomount ram://204800
diskutil erasevolume APFS TempDisk /dev/diskN

use it as volatile storage, then destroy it:

diskutil eject /Volumes/TempDisk

The RAM disk can likely be formatted with an encrypted file system, too.

Life.

-- 
-- 
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_mac+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_mac/u7vfjq%246tk%241%40ciao.gmane.io.


Re: :hardcopy not launching Preview

2023-07-03 Thread Bram Moolenaar


> On 2023-06-30, Lifepillar  wrote:
> > On 2023-06-30, Yee Cheng Chin  wrote:
> > The fix was in https://github.com/macvim-dev/macvim/pull/1390
> 
> To delete the PDF file synchronously after it has been opened in
> Preview, AppleScript can be used:
> 
> system($"osascript -e 'tell app \"Preview\" to open POSIX file 
> \"{v:fname_in}.pdf\"'")
> delete($"{v:fname_in}.pdf")
> 
> osascript should return only after the document has been opened. Running
> that will probably ask once for permissions to access files.

Thanks for looking into this.  Let me know if there is something that I
should include in the generic distribution.

Looking at this, I wonder what we should do when encryption is used.
Writing a copy of the file somewhere, without encryption, is bad then.
Even if we delete it soon after.

I suppose encrypting the file won't be possible, since the reader does
not know how to decrypt it.  Or does the Preview app support encryption
somehow?

The alternative is to not use a temp file but write the text through a
pipe/socket.  That also avoids the need to find the right moment to
delete the temp file.  Can we do this somehow?  It may require forking
the process, so that the pipe can be written to asynchronously.  Or
using ch_open() or job_start() and one of the callback functions.
Using a buffer instead of a file to store the text.

-- 
hundred-and-one symptoms of being an internet addict:
263. You have more e-mail addresses than shorts.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///  \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_mac+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_mac/20230703175852.69BAE1C08A3%40moolenaar.net.