-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
When opening a gpg-encrypted PDF, epa - the EasyPG Assistant - transparently decrypts it and loads it into a buffer named by the original, encrypted file. Consequently, epdfinfo expects to find a PDF file by this name and fails.
A quick fix is to handle encrypted files like compressed and remote files and store a decrypted copy in the current buffer’s dedicated temp directory. This is achieved by adding a simple, four-line condition to pdf-view-mode in pdf-view.el, replacing
(when (and (or jka-compr-really-do-compress
(let ((file-name-handler-alist nil))
(not (and buffer-file-name
(file-readable-p buffer-file-name)))))
(pdf-tools-pdf-buffer-p))
by
(when (and (or jka-compr-really-do-compress
(let ((file-name-handler-alist nil))
(not (and buffer-file-name
(file-readable-p buffer-file-name)
(or (not (boundp 'epa-inhibit))
epa-inhibit
(not (string-match epa-file-name-regexp
buffer-file-name)))))))
(pdf-tools-pdf-buffer-p))
Caveats:
- The condition may not be the best one, but I have not found a way to directly test whether the (decrypted) contents of a given buffer were loaded from an encrypted file.
- Storing an unencrypted copy (even inside a 700 directory) poses certain privacy risks, so this quick fix is not universally applicable. Perhaps this behavior should be customizable, defaulting to off.
- This implements reading only. I haven't looked into writing altered PDF back to their encrypted files. Stay tuned.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels