[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu 52f6701197 1/7: Try to implement location support
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu 52f6701197 1/7: Try to implement location support for docframe |
Date: |
Fri, 18 Nov 2022 05:57:33 -0500 (EST) |
branch: externals/corfu
commit 52f67011979ec928bf9032851fd871cee00db3c8
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Try to implement location support for docframe
---
extensions/corfu-docframe.el | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/extensions/corfu-docframe.el b/extensions/corfu-docframe.el
index 69614e8428..a39e4375d4 100644
--- a/extensions/corfu-docframe.el
+++ b/extensions/corfu-docframe.el
@@ -82,6 +82,10 @@
(defvar-local corfu-docframe--toggle t
"Local docframe toggle state.")
+(defvar-local corfu-docframe--function
+ #'corfu-docframe--documentation
+ "Documentation function.")
+
(defvar corfu-docframe--frame nil
"Doc frame.")
@@ -107,7 +111,8 @@ See `frame-edges' for details.")
'(corfu-docframe--candidate
corfu-docframe--edges
corfu-docframe--direction
- corfu-docframe--toggle)
+ corfu-docframe--toggle
+ corfu-docframe--function)
"Buffer-local state variables used by corfu-docframe.")
(defun corfu-docframe--visible-p ()
@@ -115,7 +120,23 @@ See `frame-edges' for details.")
(and (frame-live-p corfu-docframe--frame)
(frame-visible-p corfu-docframe--frame)))
-(defun corfu-docframe--get-doc (candidate)
+(defun corfu-docframe--get-source (candidate)
+ (when-let* ((fun (plist-get corfu--extra :company-location))
+ (loc (funcall fun candidate))
+ (res (or (and (bufferp (car loc)) (car loc))
(find-file-noselect (car loc) t))))
+ (save-window-excursion
+ (with-current-buffer res
+ (save-excursion
+ (save-restriction
+ (widen)
+ (if (bufferp (car loc))
+ (goto-char (cdr loc))
+ (goto-char (point-min))
+ (forward-line (1- (cdr loc))))
+ (setq res (buffer-substring (point) (point-max)))
+ (and (not (string-blank-p res)) res)))))))
+
+(defun corfu-docframe--get-documentation (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))
@@ -272,7 +293,7 @@ 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 candidate))
+ (if-let (doc (corfu-docframe--get-source candidate))
(with-current-buffer (corfu--make-buffer " *corfu-docframe*" doc)
;; TODO extract settings
(setq-local line-move-visual t
@@ -325,6 +346,12 @@ If ARG is omitted or nil, scroll down by a near full
screen."
(interactive "p")
(corfu-docframe-scroll-up (- (or n 1))))
+(defun corfu-docframe-show-location ()
+ (setq corfu-docframe--function #'corfu-)
+ (when-let (candidate (and (>= corfu--index 0)
+ (nth corfu--index corfu--candidates)))
+ (corfu-docframe--show candidate)))
+
(defun corfu-docframe-toggle ()
"Toggle the doc popup display or hide.
- [elpa] externals/corfu updated (9f735cf4e6 -> cfc97d4885), ELPA Syncer, 2022/11/18
- [elpa] externals/corfu 4e0ee2f98e 5/7: corfu-infoframe: Update commentary, ELPA Syncer, 2022/11/18
- [elpa] externals/corfu 7aa006e000 6/7: corfu-infoframe: Remap scroll commands, ELPA Syncer, 2022/11/18
- [elpa] externals/corfu cfc97d4885 7/7: corfu-infoframe: Reduce print length (Fix #249), ELPA Syncer, 2022/11/18
- [elpa] externals/corfu 52f6701197 1/7: Try to implement location support for docframe,
ELPA Syncer <=
- [elpa] externals/corfu 4e5a41b8fd 2/7: Add corfu-docframe-location and corfu-docframe-documentation, ELPA Syncer, 2022/11/18
- [elpa] externals/corfu de6c1dd044 3/7: Rename to corfu-infoframe, ELPA Syncer, 2022/11/18
- [elpa] externals/corfu 82f8ae9c9e 4/7: Add corfu-infoframe-map, ELPA Syncer, 2022/11/18