emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/corfu-doc b8b47f79bc 03/95: Make the documentation scro


From: ELPA Syncer
Subject: [elpa] externals/corfu-doc b8b47f79bc 03/95: Make the documentation scrollable
Date: Tue, 19 Jul 2022 15:57:59 -0400 (EDT)

branch: externals/corfu-doc
commit b8b47f79bcf643347166996c8521e7aaf0a5360c
Author: Tian Yuwei <ibluefocus@outlook.com>
Commit: Tian Yuwei <ibluefocus@outlook.com>

    Make the documentation scrollable
---
 README.org   | 10 ++++++++++
 corfu-doc.el | 19 +++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/README.org b/README.org
index b751b93b6a..fc0173ce5d 100644
--- a/README.org
+++ b/README.org
@@ -20,6 +20,16 @@ Enable it with =M-x corfu-doc-mode= or by using 
=corfu-mode-hook=:
 (add-hook 'corfu-mode-hook #'corfu-doc-mode)
 #+end_src
 
+** Scroll the documentation
+
+Bind keys =M-p= and =M-n= to commands =corfu-doc-scroll-down= and
+=corfu-doc-scroll-up= to scroll the documentation.
+
+#+begin_src elisp
+(define-key corfu-map (kbd "M-p") #'corfu-doc-scroll-down) ;; corfu-next
+(define-key corfu-map (kbd "M-n") #'corfu-doc-scroll-up)  ;; corfu-previous
+#+end_src
+
 * License
 
 GPLv3
diff --git a/corfu-doc.el b/corfu-doc.el
index e57ae066ac..cdf4c13f9b 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -272,6 +272,25 @@
     (corfu-doc--cancel-timer))
   (corfu-doc--hide))
 
+(defun corfu-doc--funcall (function &rest args)
+  (when-let ((cf-doc-buf (and (frame-live-p corfu-doc--frame)
+                              (frame-visible-p corfu-doc--frame)
+                              (get-buffer " *corfu-doc*"))))
+    (when (functionp function)
+      (with-selected-frame corfu-doc--frame
+        (with-current-buffer cf-doc-buf
+          (apply function args))))))
+
+;;;###autoload
+(defun corfu-doc-scroll-up (&optional arg)
+  (interactive "^P")
+  (corfu-doc--funcall #'scroll-up-command arg))
+
+;;;###autoload
+(defun corfu-doc-scroll-down (&optional arg)
+  (interactive "^P")
+  (corfu-doc--funcall #'scroll-down-command arg))
+
 ;;;###autoload
 (define-minor-mode corfu-doc-mode
   "Corfu doc minor mode."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]