From d9065c485ca656176f7376d19b15ea4312546645 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Fri, 21 Apr 2023 17:30:24 +0200 Subject: Handle saved places not being readable --- nov.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nov.el b/nov.el index 0d9e524..873136e 100644 --- a/nov.el +++ b/nov.el @@ -216,6 +216,11 @@ Unnecessary nesting is removed with `nov-unnest-directory'." (nov-fix-permissions directory) status)) +(defun nov-warn (message &optional level) + "Like `display-warning', but for nov-specific warnings. +Displays MESSAGE in a warnings buffer, with LEVEL as severity." + (display-warning 'nov message level)) + (defmacro nov-ignore-file-errors (&rest body) "Like `ignore-errors', but for file errors." `(condition-case nil (progn ,@body) (file-error nil))) @@ -768,7 +773,11 @@ Internal URLs are visited with `nov-visit-relative-file'." (with-temp-buffer (insert-file-contents-literally nov-save-place-file) (goto-char (point-min)) - (read (current-buffer))))) + (condition-case nil + (read (current-buffer)) + (error + (nov-warn "Failed to retrieve saved places from `nov-save-place-file'") + nil))))) (defun nov-saved-place (identifier) "Retrieve saved place for IDENTIFIER in `nov-saved-place-file'." @@ -864,7 +873,7 @@ Saving is only done if `nov-save-place-file' is set." (setq nov-documents-index index) (nov-render-document) (goto-char point)) - (warn "Couldn't restore last position") + (nov-warn "Couldn't restore last position") (nov-render-document))) (nov-render-document)))) -- cgit v1.2.3