[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu f4939bbef7 1/6: Simplify corfu-docframe
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu f4939bbef7 1/6: Simplify corfu-docframe |
Date: |
Thu, 17 Nov 2022 23:57:32 -0500 (EST) |
branch: externals/corfu
commit f4939bbef7a3fa7c50822fdfdb3760ec221257c0
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Simplify corfu-docframe
---
extensions/corfu-docframe.el | 42 +++++++++++++-----------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/extensions/corfu-docframe.el b/extensions/corfu-docframe.el
index b8c8b54f2e..e2a7af9e2c 100644
--- a/extensions/corfu-docframe.el
+++ b/extensions/corfu-docframe.el
@@ -111,31 +111,17 @@ See `frame-edges' for details.")
(and (frame-live-p corfu-docframe--frame)
(frame-visible-p corfu-docframe--frame)))
-(defun corfu-docframe--get-doc ()
- "Get the documentation for the current completion candidate.
-The documentation is trimmed. Returns nil if an error occurs or
-the documentation content is empty."
- (when-let
- ((doc
- (cond
- ((= corfu--total 0) nil) ;; No candidates
- ((< corfu--index 0) nil) ;; No candidate selected
- (t
- (if-let*
- ((fun (plist-get corfu--extra :company-doc-buffer))
- (res
- ;; fix showing candidate location
- ;; when fetch helpful documentation
- (save-excursion
- (let ((inhibit-message t)
- (message-log-max nil))
- (funcall fun (nth corfu--index corfu--candidates))))))
- (let ((buf (or (car-safe res) res)))
- (with-current-buffer buf
- (buffer-string)))
- nil))))) ;; No documentation available
- (unless (string-empty-p (string-trim doc))
- doc)))
+(defun corfu-docframe--get-doc (candidate)
+ "Get the documentation for CANDIDATE.
+Returns nil if an error occurs or the documentation content is empty."
+ (when-let* ((fun (plist-get corfu--extra :company-doc-buffer))
+ (res (save-excursion
+ (let ((inhibit-message t)
+ (message-log-max nil))
+ (funcall fun candidate)))))
+ (with-current-buffer (or (car-safe res) res)
+ (setq res (buffer-string)))
+ (and (not (string-empty-p (string-trim res))) res)))
(defun corfu-docframe--size (&optional width height)
"Calculate popup size in the form of (width height).
@@ -300,10 +286,8 @@ the corfu popup, its value is 'bottom, 'top, 'right or
'left."
(new-edges (frame-edges corfu--frame 'inner-edges))
(edges-changed (not (equal new-edges corfu-docframe--edges))))
(when doc-changed
- (if-let (doc (corfu-docframe--get-doc))
- ;; turn on word wrap and hide fringe indicators
- (with-current-buffer
- (corfu--make-buffer " *corfu-docframe*" doc)
+ (if-let (doc (corfu-docframe--get-doc candidate))
+ (with-current-buffer (corfu--make-buffer " *corfu-docframe*" doc)
;; TODO extract
(setq-local line-move-visual t
truncate-partial-width-windows nil
- [elpa] externals/corfu updated (ca94d7db18 -> db19e932fb), ELPA Syncer, 2022/11/17
- [elpa] externals/corfu 70d85b1193 4/6: Remove corfu-docframe--teardown, ELPA Syncer, 2022/11/17
- [elpa] externals/corfu d905f06836 3/6: Indentation, ELPA Syncer, 2022/11/17
- [elpa] externals/corfu f4939bbef7 1/6: Simplify corfu-docframe,
ELPA Syncer <=
- [elpa] externals/corfu b26bd4435f 2/6: Simplify corfu-docframe, ELPA Syncer, 2022/11/17
- [elpa] externals/corfu 9361a8e37f 5/6: corfu-docframe: Fix warnings, ELPA Syncer, 2022/11/17
- [elpa] externals/corfu db19e932fb 6/6: Simplify corfu-docframe, ELPA Syncer, 2022/11/17