branch: externals/doc-view-follow
commit 2fe6cb676bc620ee20c64a8d24be71e98b376d47
Author: Paul Nelson <[email protected]>
Commit: Paul Nelson <[email protected]>
Add convenience function to toggle appropriate follow mode
* README.org (Extensibility): Add new "Convenience" section with a
command that selects and toggles the appropriate follow mode based on
current buffer.
---
README.org | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/README.org b/README.org
index 690173456c..1e7dcb4070 100644
--- a/README.org
+++ b/README.org
@@ -51,3 +51,21 @@ Both windows will automatically stay synchronized.
* Extensibility
The package uses generic functions, making it straightforward to add support
for additional document viewing modes. See =doc-view-follow-pdf-tools.el= for
an example of how to do this.
+
+* Convenience
+
+Since `doc-view-follow-mode` works with document files (PDF, PS, etc.) and
`follow-mode` works with text buffers, you might want a single command that
applies the appropriate mode based on your current buffer. Here's a function
that does so:
+
+#+begin_src elisp
+(defun toggle-some-follow-mode ()
+ "Toggle either `doc-view-follow-mode' or `follow-mode' as appropriate.
+In buffers where `doc-view-follow-mode' is supported, toggle that mode.
+Otherwise, toggle the standard `follow-mode'."
+ (interactive)
+ (if (and (fboundp 'doc-view-follow-supported-p)
+ (doc-view-follow-supported-p))
+ (call-interactively 'doc-view-follow-mode)
+ (call-interactively 'follow-mode)))
+
+(keymap-global-set "H-f" 'toggle-some-follow-mode)
+#+end_src