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

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

[elpa] externals/corfu-doc c6b54c923e 14/95: Add command to quickly togg


From: ELPA Syncer
Subject: [elpa] externals/corfu-doc c6b54c923e 14/95: Add command to quickly toggle documentation popup on or off
Date: Tue, 19 Jul 2022 15:58:01 -0400 (EDT)

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

    Add command to quickly toggle documentation popup on or off
---
 README.org   | 12 ++++++++++--
 corfu-doc.el | 13 +++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/README.org b/README.org
index fc0173ce5d..d25af713d5 100644
--- a/README.org
+++ b/README.org
@@ -1,10 +1,10 @@
 #+TITLE: corfu-doc - Documentation popup for Corfu
-#+AUTHOR: Tian Yuwei
+#+AUTHOR: Yuwei Tian
 
 * Introduction
 
 Display a documentation popup for completion candidate when using Corfu.
-It can be re regarded as =company-quickhelp= for 
[[https://github.com/minad/corfu][Corfu]].
+It can be regarded as =company-quickhelp= for 
[[https://github.com/minad/corfu][Corfu]].
 
 [[https://github.com/galeo/corfu-doc/blob/screenshots/right.png?raw=true]]
 
@@ -30,6 +30,14 @@ Bind keys =M-p= and =M-n= to commands 
=corfu-doc-scroll-down= and
 (define-key corfu-map (kbd "M-n") #'corfu-doc-scroll-up)  ;; corfu-previous
 #+end_src
 
+** Quickly toggle the documentation on or off
+
+Bind a key to quickly toggle the documentation popup on or off.
+
+#+begin_src elisp
+(define-key corfu-map (kbd "M-d") #'corfu-doc-toggle)
+#+end_src
+
 * License
 
 GPLv3
diff --git a/corfu-doc.el b/corfu-doc.el
index a1407ff325..c93027b42e 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -334,6 +334,19 @@
      (advice-remove 'corfu--popup-show #'corfu-doc--set-timer)
      (advice-remove 'corfu--popup-hide #'corfu-doc-hide))))
 
+;;;###autoload
+(defun corfu-doc-toggle (&optional arg)
+  "Toggle corfu doc on or off.
+With optional ARG, turn corfu doc on if and only if ARG is positive."
+  (interactive "P")
+  (if (null arg)
+      (setq arg (if corfu-doc-mode -1 1))
+    (setq arg (prefix-numeric-value arg)))
+  (if (> arg 0)
+      (corfu-doc-manually)
+    (corfu-doc-hide))
+  (corfu-doc-mode arg))
+
 
 (provide 'corfu-doc)
 ;;; corfu-doc.el ends here



reply via email to

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