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

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

[elpa] externals/corfu-doc be90c96079 84/95: Merge functions to get the


From: ELPA Syncer
Subject: [elpa] externals/corfu-doc be90c96079 84/95: Merge functions to get the documentation of the candidate
Date: Tue, 19 Jul 2022 15:58:07 -0400 (EDT)

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

    Merge functions to get the documentation of the candidate
---
 corfu-doc.el | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/corfu-doc.el b/corfu-doc.el
index 883520b4b0..97359ed6ee 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -226,33 +226,31 @@ WINDOW is the current window where the corfu popup is 
located."
   (set-frame-size frame width height t)
   (make-frame-visible frame))
 
-;; Function adapted from corfu.el by Daniel Mendler
-(defun corfu-doc-fetch-documentation ()
-  "Fetch documentation buffer of the current completion candidate."
-  (cond
-    ((= corfu--total 0)
-     (user-error "No candidates"))
-    ((< corfu--index 0)
-     (user-error "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)))
-       (user-error "No documentation available")))))
-
 (defun corfu-doc--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 (ignore-errors (corfu-doc-fetch-documentation))))
+  (when-let
+      ((doc
+        (ignore-errors
+          (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)))
 



reply via email to

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