Function: pdf-view--write-contents-function
pdf-view--write-contents-function is a natively compiled function
defined in pdf-view.el.
Signature
(pdf-view--write-contents-function)
Documentation
Function for write-contents-functions to save the buffer.
Source Code
;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-view.el
(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)))
(unwind-protect
(progn
;; Order matters here: We need to first copy the new
;; content (tempfile) to the PDF, 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)
(when (file-exists-p tempfile)
(delete-file tempfile))))))