[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu fd1c5e9 5/5: defcustom: Replace corfu-min-width w
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/corfu fd1c5e9 5/5: defcustom: Replace corfu-min-width with corfu-width-limits |
Date: |
Sun, 18 Apr 2021 10:40:16 -0400 (EDT) |
branch: externals/corfu
commit fd1c5e9f178d20aeed61a8404516b4743984997a
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
defcustom: Replace corfu-min-width with corfu-width-limits
---
README.org | 7 +++----
corfu.el | 22 ++++++++++++----------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/README.org b/README.org
index 8167b9c..7efef38 100644
--- a/README.org
+++ b/README.org
@@ -21,8 +21,8 @@ understand.
Corfu is a minimal package of less than 500 lines of code (my arbitrary limit
for small components providing a single specific feature). In contrast to the
-featureful and complex Company package, Corfu only provides the completion UI
-and does not include custom completion backends. Completions are generated by
+featureful and complex Company package, Corfu only offers a completion UI and
+does not include custom completion backends. Completions are generated by
calling the ~completion-at-point-functions~ (Capfs). Many code completion
backends provide such a Capf, such that relying only on the default completion
is often sufficient. For example the language server packages,
[[https://github.com/joaotavora/eglot][Eglot]] and
@@ -43,7 +43,7 @@ is often sufficient. For example the language server
packages, [[https://github.
- Jumping to location/documentation of current candidate (Company extension)
- Support for ~annotation-function~ and ~affixation-function~
-Notable non-feature: Timer-based automatic completions are not supported.
+Notable non-feature: Timer-based idle completions are not supported.
* Configuration
@@ -126,7 +126,6 @@ counterpart of Corfu.
This package is experimental and new. I am not yet claiming that this package
works correctly. There are a few known technical caveats.
-- No additional caching, the completion table is called repeatedly.
- The overlay popup is brittle (Alternatives to consider: Posframe, Postip)
- The thin popup borders are only drawn if =line-spacing=nil=.
- The abort handling could be improved, for example the input could be undone.
diff --git a/corfu.el b/corfu.el
index 5aa458f..4b0711f 100644
--- a/corfu.el
+++ b/corfu.el
@@ -47,9 +47,10 @@
"Maximal number of candidates to show."
:type 'integer)
-(defcustom corfu-min-width 15
- "Minimum popup width."
- :type 'integer)
+(defcustom corfu-width-limits
+ (cons 15 80)
+ "Popup width limits."
+ :type '(cons integer integer))
(defcustom corfu-cycle nil
"Enable cycling for `corfu-next' and `corfu-previous'."
@@ -188,18 +189,19 @@ If `line-spacing/=nil' or in text-mode, the background
color is used instead.")
(rbar (corfu--border (car size) (cdr size) (- (ceiling (car size) 3))
'corfu-bar 'corfu-background))
(col (+ (- pos (line-beginning-position)) corfu--base))
- (max-width (min (/ (window-total-width) 2) (- (window-total-width)
col 4)))
+ (max-width (min (cdr corfu-width-limits) (/ (window-total-width) 2)))
+ (rest-width (- (window-total-width) col 4))
(ypos (- (line-number-at-pos pos)
(save-excursion (move-to-window-line 0)
(line-number-at-pos))))
(count (length lines))
(row 0) (width) (formatted) (beg))
- (if (< max-width corfu-min-width)
- (setq width (max corfu-min-width (/ (window-total-width) 2))
- lines (mapcar (lambda (x) (truncate-string-to-width x width))
lines)
- width (apply #'max (mapcar #'string-width lines))
+ (if (< rest-width (car corfu-width-limits))
+ (setq lines (mapcar (lambda (x) (truncate-string-to-width x
max-width)) lines)
+ width (apply #'max (car corfu-width-limits) (mapcar
#'string-width lines))
col (max 0 (- col width 2)))
- (setq lines (mapcar (lambda (x) (truncate-string-to-width x max-width))
lines)
- width (apply #'max corfu-min-width (mapcar #'string-width lines))))
+ (setq max-width (min rest-width max-width)
+ lines (mapcar (lambda (x) (truncate-string-to-width x max-width))
lines)
+ width (apply #'max (car corfu-width-limits) (mapcar #'string-width
lines))))
(save-excursion
(beginning-of-line)
(forward-line (if (and (< count ypos)