diff options
Diffstat (limited to 'nov.el')
-rw-r--r-- | nov.el | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -650,6 +650,11 @@ Saving is only done if `nov-save-place-file' is set." (with-temp-file nov-save-place-file (insert (prin1-to-string places)))))) +(defun nov--index-valid-p (documents index) + (and (integerp index) + (>= index 0) + (< index (length documents)))) + ;;;###autoload (define-derived-mode nov-mode special-mode "EPUB" "Major mode for reading EPUB documents" @@ -686,9 +691,13 @@ Saving is only done if `nov-save-place-file' is set." (if place (let ((index (cdr (assq 'index place))) (point (cdr (assq 'point place)))) - (setq nov-documents-index index) - (nov-render-document) - (goto-char point)) + (if (nov--index-valid-p nov-documents index) + (progn + (setq nov-documents-index index) + (nov-render-document) + (goto-char point)) + (warn "Couldn't restore last position") + (nov-render-document))) (nov-render-document)))) (provide 'nov) |