From 08118ee9a6b15a287e766bd2e3cd025848136d60 Mon Sep 17 00:00:00 2001 From: Matt Beshara Date: Sun, 16 Jul 2023 11:29:05 +1000 Subject: Add numeric prefix arg to commands for viewing next/prev document --- nov.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'nov.el') diff --git a/nov.el b/nov.el index de6ef63..91dc585 100644 --- a/nov.el +++ b/nov.el @@ -687,17 +687,18 @@ the HTML is rendered with `nov-render-html-function'." (goto-char (point-min)))) (pop-to-buffer buffer))) -(defun nov-next-document () - "Go to the next document and render it." - (interactive) - (when (< nov-documents-index (1- (length nov-documents))) - (nov-goto-document (1+ nov-documents-index)))) - -(defun nov-previous-document () - "Go to the previous document and render it." - (interactive) - (when (> nov-documents-index 0) - (nov-goto-document (1- nov-documents-index)))) +(defun nov-next-document (&optional count) + "Go to the next document and render it. +Takes an optional COUNT, goes backward if COUNT is negative." + (interactive "p") + (nov-goto-document (min (1- (length nov-documents)) + (+ nov-documents-index (or count 1))))) + +(defun nov-previous-document (&optional count) + "Go to the previous document and render it. +Takes an optional COUNT, goes forward if COUNT is negative." + (interactive "p") + (nov-goto-document (max 0 (- nov-documents-index (or count 1))))) (defun nov-scroll-up (arg) "Scroll with `scroll-up' or visit next chapter if at bottom." -- cgit v1.2.3