aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilij Schneidermann <mail@vasilij.de>2023-04-21 17:47:46 +0200
committerVasilij Schneidermann <mail@vasilij.de>2023-04-21 17:48:03 +0200
commit58c35e677e11f5c04a702b42ac753c80c8955089 (patch)
treec3062fa8381bc00dc110fd08fdef4185fba49124
parentca8d250bfbe687eff7d8bc18708f6968e719ec65 (diff)
Add multi-isearch interop
This implements the much requested feature of C-s behaving similarly to how it does in info buffers. Many thanks to Madhu for discovering multi-isearch.el (AKA misearch).
-rw-r--r--README.md1
-rw-r--r--nov.el24
2 files changed, 25 insertions, 0 deletions
diff --git a/README.md b/README.md
index f643795..7ac7889 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@ Features:
- Supports textual and image documents
- Info-style history navigation
- View source of document files
+- Info-style incremental search
- Metadata display
- Image rescaling
diff --git a/nov.el b/nov.el
index 73521b3..d814727 100644
--- a/nov.el
+++ b/nov.el
@@ -991,5 +991,29 @@ See also `nov-bookmark-make-record'."
(setq imenu-create-index-function 'nov-imenu-create-index))
(add-hook 'nov-mode-hook 'nov-imenu-setup)
+
+;;; multi-isearch interop
+
+(defun nov-misearch-next-buffer (buffer wrap)
+ (if isearch-forward
+ (cond
+ ((< nov-documents-index (1- (length nov-documents)))
+ (nov-goto-document (1+ nov-documents-index))
+ (current-buffer))
+ (wrap
+ (nov-goto-document 0)
+ nil))
+ (cond
+ ((> nov-documents-index 0)
+ (nov-goto-document (1- nov-documents-index))
+ (current-buffer))
+ (wrap
+ (nov-goto-document (1- (length nov-documents)))
+ nil))))
+
+(defun nov-misearch-setup ()
+ (setq-local multi-isearch-next-buffer-function #'nov-misearch-next-buffer))
+(add-hook 'nov-mode-hook #'nov-misearch-setup)
+
(provide 'nov)
;;; nov.el ends here