[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu-doc 6c0653336d 36/95: Avoid doc frame repositioni
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu-doc 6c0653336d 36/95: Avoid doc frame repositioning delay |
Date: |
Tue, 19 Jul 2022 15:58:02 -0400 (EDT) |
branch: externals/corfu-doc
commit 6c0653336d458add71597415ab6288ecf36376e8
Author: Yuwei Tian <ibluefocus@outlook.com>
Commit: Yuwei Tian <ibluefocus@outlook.com>
Avoid doc frame repositioning delay
---
corfu-doc.el | 76 +++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 45 insertions(+), 31 deletions(-)
diff --git a/corfu-doc.el b/corfu-doc.el
index 3115a30389..63b954dccf 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -212,8 +212,12 @@ If this is nil, do not resize corfu doc frame
automatically."
(buffer-string)))
(user-error "No documentation available")))))
-(defun corfu-doc--calculate-doc-frame-position ()
- "Calculate doc frame position (x, y), pixel width and height."
+(defun corfu-doc--calculate-doc-frame-position (&optional fwidth fheight)
+ "Calculate doc frame position (x, y), pixel width and height.
+
+The pixel width and height of the doc frame are calculated by the
+documentation content, they can also be specified by optional parameters
+FWIDTH and FHEIGHT."
(let* (x y
(space 1) ;; 1 pixel space between corfu frame and corfu doc frame
(cf-parent-frame (frame-parent corfu--frame))
@@ -228,27 +232,29 @@ If this is nil, do not resize corfu doc frame
automatically."
(car (cl-subseq (frame-edges cf-parent-frame 'inner) 0 2)))
(cf-parent-frame-width (frame-pixel-width cf-parent-frame))
(cf-doc-frame-width
- (if (not corfu-doc-resize-frame)
- ;; left border + left margin + inner width + right margin +
right border
- (+ 1
- (alist-get 'left-fringe corfu-doc--frame-parameters 0)
- (* (frame-char-width) corfu-doc-max-width)
- (alist-get 'right-fringe corfu-doc--frame-parameters 0)
- 1)
- (fit-frame-to-buffer corfu-doc--frame
- corfu-doc-max-height nil
- corfu-doc-max-width nil)
- ;; outer width - left border - left margin - right margin - right
border
- (- (frame-pixel-width corfu-doc--frame)
- 1
- (alist-get 'left-fringe corfu-doc--frame-parameters 0)
- (alist-get 'right-fringe corfu-doc--frame-parameters 0)
- 1)))
+ (or fwidth
+ (if (not corfu-doc-resize-frame)
+ ;; left border + left margin + inner width + right margin +
right border
+ (+ 1
+ (alist-get 'left-fringe corfu-doc--frame-parameters 0)
+ (* (frame-char-width) corfu-doc-max-width)
+ (alist-get 'right-fringe corfu-doc--frame-parameters 0)
+ 1)
+ (fit-frame-to-buffer corfu-doc--frame
+ corfu-doc-max-height nil
+ corfu-doc-max-width nil)
+ ;; outer width - left border - left margin - right margin -
right border
+ (- (frame-pixel-width corfu-doc--frame)
+ 1
+ (alist-get 'left-fringe corfu-doc--frame-parameters 0)
+ (alist-get 'right-fringe corfu-doc--frame-parameters 0)
+ 1))))
(cf-doc-frame-height
- (if (not corfu-doc-resize-frame)
- (* (frame-char-height) corfu-doc-max-height)
- ;; outer height - top border - bottom border
- (- (frame-pixel-height corfu-doc--frame) 1 1)))
+ (or fheight
+ (if (not corfu-doc-resize-frame)
+ (* (frame-char-height) corfu-doc-max-height)
+ ;; outer height - top border - bottom border
+ (- (frame-pixel-height corfu-doc--frame) 1 1))))
(display-geometry (assq 'geometry (frame-monitor-attributes
corfu--frame)))
(display-width (nth 3 display-geometry))
(display-x (nth 1 display-geometry))
@@ -342,15 +348,23 @@ 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))
- (if (> corfu-doc-delay corfu-doc-hide-threshold)
- (make-frame-invisible corfu-doc--frame)
- (corfu-doc--clear-buffer)))))
+ (when (> corfu-doc-delay 0)
+ (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))
+ (if (> corfu-doc-delay corfu-doc-hide-threshold)
+ (make-frame-invisible corfu-doc--frame)
+ ;; clear buffer and reset doc frame position immediately
+ (corfu-doc--clear-buffer)
+ (let ((cf-frame-edges (frame-edges corfu--frame 'inner)))
+ (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
+ (frame-pixel-width corfu-doc--frame)
+ (frame-pixel-height corfu-doc--frame))))))))))
(when (or (null corfu-doc--timer)
(eq this-command #'corfu-doc-manually))
(setq corfu-doc--timer
- [elpa] externals/corfu-doc 348fc32035 40/95: Version 0.3.1, (continued)
- [elpa] externals/corfu-doc 348fc32035 40/95: Version 0.3.1, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 6c62c6634f 37/95: README: Document reducing the popup flickering, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 8313341ae8 52/95: Version 0.4.2, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 84f344ce60 31/95: Version 0.2.0, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 15dfe652f5 22/95: Automatically resize the corfu doc frame, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 214b14115e 39/95: Hide doc frame if there is no documentation, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 95fdae5755 46/95: Update installation, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc df8d7e2242 34/95: README: Document `corfu-doc-hide-threshold`, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 2a3f515022 63/95: Add corfu-doc--popup-scroll function, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc b3394359de 54/95: Fix #9 (again): fix error when candidate index is nil, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 6c0653336d 36/95: Avoid doc frame repositioning delay,
ELPA Syncer <=
- [elpa] externals/corfu-doc 2e74659620 60/95: Hide the doc frame when current candidate is nil, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 807448a3de 38/95: Version 0.3.0, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 5a6f4f879d 59/95: Version 0.5.0, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 91e66b0804 25/95: Avoid warning if x-gtk-resize-child-frames is missing, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 904df4f99a 62/95: Make corfu-doc-mode a global minor mode, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 9750d1af61 65/95: Fix calling corfu-doc--refresh-popup, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 9d81c522f6 56/95: Simplify code, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc f63395100e 69/95: Fix typo (#14), ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 96b5de8cce 61/95: Version 0.5.1, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 611895ef47 66/95: Version 0.6.0, ELPA Syncer, 2022/07/19