[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu-doc 5d08342a82 28/95: Fix #6: do not show the doc
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu-doc 5d08342a82 28/95: Fix #6: do not show the documentation popup immediately |
Date: |
Tue, 19 Jul 2022 15:58:02 -0400 (EDT) |
branch: externals/corfu-doc
commit 5d08342a8227e40522b34cc5abe544d0a6debf2c
Author: Yuwei Tian <ibluefocus@outlook.com>
Commit: Yuwei Tian <ibluefocus@outlook.com>
Fix #6: do not show the documentation popup immediately
Update it with a timer, the delay time can be set by `corfu-doc-delay`.
---
corfu-doc.el | 86 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 47 insertions(+), 39 deletions(-)
diff --git a/corfu-doc.el b/corfu-doc.el
index ec11f6d82c..c06906978f 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -289,40 +289,35 @@ If this is nil, do not resize corfu doc frame
automatically."
(t (setq y y-on-bottom-side-of-cf-frame)))))))
(list x y cf-doc-frame-width cf-doc-frame-height)))
-(defun corfu-doc--show ()
- (let ((candidate (and (> corfu--total 0)
- (nth corfu--index corfu--candidates)))
- (cf-frame-edges (frame-edges corfu--frame 'inner)))
- (if candidate
- (when (and (and (fboundp 'corfu-mode) corfu-mode)
- (frame-visible-p corfu--frame))
- (unless (and (string= corfu-doc--candidate candidate)
- (frame-live-p corfu-doc--frame)
- (frame-visible-p corfu-doc--frame)
- (equal cf-frame-edges corfu-doc--cf-frame-edges)
- (eq (selected-window) corfu-doc--window))
- ;; show doc frame
- (if-let* ((res (ignore-errors (corfu-doc-fetch-documentation)))
- (doc (unless (string-empty-p (string-trim res)) res)))
- (progn
- (corfu-doc--make-frame doc)
- (apply #'corfu-doc--set-frame-position
- corfu-doc--frame
- (corfu-doc--calculate-doc-frame-position)))
- (corfu-doc--hide)))
- (corfu--echo-refresh))
- (corfu-doc--hide))
- (setq corfu-doc--candidate candidate)
- (setq corfu-doc--cf-frame-edges cf-frame-edges)
- (setq corfu-doc--window (selected-window))))
+(defun corfu-doc--get-candidate ()
+ (and (> corfu--total 0)
+ (nth corfu--index corfu--candidates)))
-(defun corfu-doc--hide ()
- (when (frame-live-p corfu-doc--frame)
- (make-frame-invisible corfu-doc--frame)
- (with-current-buffer
- (window-buffer (frame-root-window corfu-doc--frame))
- (let ((inhibit-read-only t))
- (erase-buffer)))))
+(defun corfu-doc--show ()
+ (when (and (and (fboundp 'corfu-mode) corfu-mode)
+ (frame-visible-p corfu--frame))
+ (when-let ((candidate (corfu-doc--get-candidate))
+ (cf-frame-edges (frame-edges corfu--frame 'inner)))
+ (if (and (string= candidate corfu-doc--candidate)
+ (eq (selected-window) corfu-doc--window)
+ (frame-live-p corfu-doc--frame))
+ (progn
+ (make-frame-visible corfu-doc--frame)
+ (unless (equal cf-frame-edges corfu-doc--cf-frame-edges)
+ (apply #'corfu-doc--set-frame-position
+ corfu-doc--frame
+ (corfu-doc--calculate-doc-frame-position))))
+ ;; fetch documentation and show
+ (when-let* ((res (ignore-errors (corfu-doc-fetch-documentation)))
+ (doc (unless (string-empty-p (string-trim res)) res)))
+ (corfu-doc--make-frame doc)
+ (apply #'corfu-doc--set-frame-position
+ corfu-doc--frame
+ (corfu-doc--calculate-doc-frame-position))))
+ (corfu--echo-refresh)
+ (setq corfu-doc--candidate candidate)
+ (setq corfu-doc--cf-frame-edges cf-frame-edges)
+ (setq corfu-doc--window (selected-window)))))
(defun corfu-doc-manually ()
(interactive)
@@ -330,15 +325,17 @@ If this is nil, do not resize corfu doc frame
automatically."
(corfu-doc--set-timer)))
(defun corfu-doc--set-timer (&rest _args)
+ ;; hide the doc frame immediately when candidate selection changed
+ (let ((candidate (corfu-doc--get-candidate)))
+ (unless (and (string= candidate corfu-doc--candidate)
+ (eq (selected-window) corfu-doc--window))
+ (when (and (frame-live-p corfu-doc--frame)
+ (frame-visible-p corfu-doc--frame))
+ (make-frame-invisible corfu-doc--frame))))
(when (or (null corfu-doc--timer)
(eq this-command #'corfu-doc-manually))
(setq corfu-doc--timer
- (run-with-timer
- (if (and (frame-live-p corfu-doc--frame)
- (frame-visible-p corfu-doc--frame))
- 0
- corfu-doc-delay)
- nil #'corfu-doc-show))))
+ (run-with-timer corfu-doc-delay nil #'corfu-doc-show))))
(defun corfu-doc--cancel-timer ()
(when (timerp corfu-doc--timer)
@@ -349,6 +346,17 @@ If this is nil, do not resize corfu doc frame
automatically."
(corfu-doc--cancel-timer)
(corfu-doc--show))
+(defun corfu-doc--hide ()
+ (when (frame-live-p corfu-doc--frame)
+ (make-frame-invisible corfu-doc--frame)
+ (with-current-buffer
+ (window-buffer (frame-root-window corfu-doc--frame))
+ (let ((inhibit-read-only t))
+ (erase-buffer)))
+ (setq corfu-doc--candidate nil)
+ (setq corfu-doc--cf-frame-edges nil)
+ (setq corfu-doc--window nil)))
+
(defun corfu-doc-hide ()
(when corfu-doc-delay
(corfu-doc--cancel-timer))
- [elpa] externals/corfu-doc fd15093639 05/95: Add left and right margins, (continued)
- [elpa] externals/corfu-doc fd15093639 05/95: Add left and right margins, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc c6b54c923e 14/95: Add command to quickly toggle documentation popup on or off, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 98398c61fa 15/95: Fix wrong argument type error when calling frame-visible-p, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc e18aea61e7 10/95: Version 0.0.3, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 98509cbe29 44/95: Decrease auto delay to 0.1, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 0741012875 26/95: Fix typo in comment, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 8c30a44d67 41/95: Fix #7: change the behavior of the corfu-doc-toggle command, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc f83307a233 09/95: Update doc frame when corfu frame coordinates changed, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 488da67753 13/95: Revert previous commit, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc ef1edadb4f 29/95: README: Document `corfu-doc-delay`, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 5d08342a82 28/95: Fix #6: do not show the documentation popup immediately,
ELPA Syncer <=
- [elpa] externals/corfu-doc d051b8e0b1 23/95: Place doc frame at top or bottom of the completion popup frame, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 7926ff406c 47/95: Avoid using map-merge, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc a8835a6540 43/95: Version 0.4.0, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 75faa58328 21/95: Version 0.0.5, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc d7d7c27703 70/95: Version 0.6.2, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc d5224ad109 30/95: Decrease popup displaying delay to 0.2 seconds, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 4ff6f35c18 64/95: Fix #12: make the popup functions more overrideable, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 95a1a1731d 51/95: Add contributions note, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 122e1f5900 32/95: Only record candidate that has displayed the doc popup, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 1c99932d33 57/95: Support displaying the doc frame within the parent frame, ELPA Syncer, 2022/07/19