Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions lisp/pdf-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ PNG images in Emacs buffers."
(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)))))
(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))
(let ((tempfile (pdf-util-make-temp-file)))
(write-region nil nil tempfile nil 'no-message)
Expand Down Expand Up @@ -556,30 +560,21 @@ operating on a local copy of a remote file."
(defun pdf-view--write-contents-function ()
"Function for `write-contents-functions' to save the buffer."
(when (pdf-util-pdf-buffer-p)
(let ((tempfile (pdf-info-save pdf-view--server-file-name)))
(let ((tempfile (pdf-info-save pdf-view--server-file-name))
(inhibit-read-only t))
(unwind-protect
(progn
;; Order matters here: We need to first copy the new
;; content (tempfile) to the PDF, and then close the PDF.
;; Order matters here: We need to first read the new
;; content (tempfile) into the buffer, and then close the PDF.
;; Since while closing the file (and freeing its resources
;; in the process), it may be immediately reopened due to
;; redisplay happening inside the pdf-info-close function
;; (while waiting for a response from the process.).
(copy-file tempfile (or (buffer-file-name)
(read-file-name
"File name to save PDF to: "))
t)
(pdf-info-close pdf-view--server-file-name)

(when pdf-view--buffer-file-name
(copy-file tempfile pdf-view--buffer-file-name t))
(clear-visited-file-modtime)
(set-buffer-modified-p nil)
(setq pdf-view--server-file-name
(pdf-view-buffer-file-name))
t)
(insert-file-contents tempfile nil nil nil t)
(pdf-info-close pdf-view--server-file-name))
(when (file-exists-p tempfile)
(delete-file tempfile))))))
(delete-file tempfile)))))
nil)

(defun pdf-view--after-revert ()
"Reload the local copy in case of a remote file, and close the document."
Expand Down
Loading