branch: elpa/pdf-tools
commit 388950ae94558654fcc9c19bfd7530328f326919
Author: Miha Rihtaršič <[email protected]>
Commit: Miha Rihtaršič <[email protected]>
Support decryption of non-file-visiting pdf buffers
Opening a pdf e-mail attachment from within Emacs can show a pdf-view
buffer,
where (buffer-file-name) returns nil.
---
lisp/pdf-view.el | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/lisp/pdf-view.el b/lisp/pdf-view.el
index f2b8922724..d45571adfd 100644
--- a/lisp/pdf-view.el
+++ b/lisp/pdf-view.el
@@ -466,12 +466,14 @@ PNG images in Emacs buffers."
"Read a password, if the document is encrypted and open it."
(interactive)
(when (pdf-info-encrypted-p)
- (let ((prompt (format "Enter password for `%s': "
- (abbreviate-file-name
- (buffer-file-name))))
- (key (concat "/pdf-tools" (buffer-file-name)))
+ (let ((fn (buffer-file-name))
+ (prompt "Enter password for pdf document: ")
(i 3)
- password)
+ key password)
+ (when fn
+ (setq prompt (format "Enter password for `%s': "
+ (abbreviate-file-name fn)))
+ (setq key (concat "/pdf-tools" fn)))
(while (and (> i 0)
(pdf-info-encrypted-p))
(setq i (1- i))
@@ -479,7 +481,8 @@ PNG images in Emacs buffers."
(setq prompt "Invalid password, try again: ")
(ignore-errors (pdf-info-open nil password)))
(pdf-info-open nil password)
- (password-cache-add key password)))
+ (when key
+ (password-cache-add key password))))
nil)
(defun pdf-view-buffer-file-name ()