branch: externals/doc-view-follow-mode
commit b876f634a4f448384a15ecb7fd7bb079b292d4cd
Author: Paul Nelson <ultr...@gmail.com>
Commit: Paul Nelson <ultr...@gmail.com>

    Improve doc-view-follow--hijack function
    
    * doc-view-follow.el (doc-view-follow--hijack): Rewrite using
    funcall-interactively, following Stefan Monnier's suggestion.
---
 doc-view-follow.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/doc-view-follow.el b/doc-view-follow.el
index 8150c03e9c..b032ccee4d 100644
--- a/doc-view-follow.el
+++ b/doc-view-follow.el
@@ -165,12 +165,14 @@ document buffers."
 Called non-interactively, calls ORIG-FUN with ARGS.  Called
 interactively, toggles `doc-view-follow-mode' when supported, otherwise
 toggles `follow-mode'."
-  (if (called-interactively-p 'any)
-      (let ((target-fun (if (doc-view-follow-supported-p major-mode)
-                            #'doc-view-follow-mode
-                          orig-fun)))
-        (call-interactively target-fun))
-    (apply orig-fun args)))
+  (apply (if (called-interactively-p 'any)
+             #'funcall-interactively #'funcall)
+         (if (and (doc-view-follow-supported-p major-mode)
+                  ;; Let's not overdo it.
+                  (called-interactively-p 'any))
+             #'doc-view-follow-mode
+           orig-fun)
+         args))
 
 ;;;###autoload
 (define-minor-mode doc-view-follow-mode

Reply via email to