[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu 6e9b8ef 10/14: Add corfu-completion-styles
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/corfu 6e9b8ef 10/14: Add corfu-completion-styles |
Date: |
Sat, 17 Apr 2021 10:25:43 -0400 (EDT) |
branch: externals/corfu
commit 6e9b8ef9b96037b5ee1ff583eafdde4cd78842fe
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add corfu-completion-styles
It may be useful to set a special completion style only for completion in
region, since completion in region has special requirements regarding the
handling of the completion prefix (See #5).
---
corfu.el | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/corfu.el b/corfu.el
index cf45558..93f4aaf 100644
--- a/corfu.el
+++ b/corfu.el
@@ -55,6 +55,11 @@
"Enable cycling for `corfu-next' and `corfu-previous'."
:type 'boolean)
+;; XXX Maybe there should be a `completion-in-region-styles' variable in Emacs
+(defcustom corfu-completion-styles nil
+ "Completion styles to use for completion in region, defaults to
`completion-styles'."
+ :type '(choice (const nil) (repeat symbol)))
+
(defgroup corfu-faces nil
"Faces used by Corfu."
:group 'corfu
@@ -270,7 +275,8 @@ If `line-spacing/=nil' or in text-mode, the background
color is used instead.")
(lambda (pattern cands)
(setq hl (lambda (x) (orderless-highlight-matches pattern x)))
cands)))
- (cons (apply #'completion-all-completions args) hl)))
+ (let ((completion-styles (or corfu-completion-styles completion-styles)))
+ (cons (apply #'completion-all-completions args) hl))))
(defun corfu--sort-predicate (x y)
"Sorting predicate which compares X and Y."
@@ -471,11 +477,11 @@ If `line-spacing/=nil' or in text-mode, the background
color is used instead.")
(other other-window-scroll-buffer)
(restore (make-symbol "corfu--restore")))
(fset restore (lambda ()
- (when (eq this-command #'corfu-abort)
- (setq this-command #'ignore))
- (remove-hook 'pre-command-hook restore)
- (setq other-window-scroll-buffer other)
- (set-window-configuration config)))
+ (when (eq this-command #'corfu-abort)
+ (setq this-command #'ignore))
+ (remove-hook 'pre-command-hook restore)
+ (setq other-window-scroll-buffer other)
+ (set-window-configuration config)))
(run-at-time 0 nil (lambda () (add-hook 'pre-command-hook restore)))))
;; Company support, taken from `company.el', see `company-show-doc-buffer'.
@@ -522,7 +528,8 @@ If `line-spacing/=nil' or in text-mode, the background
color is used instead.")
(pt (max 0 (- (point) beg)))
(str (buffer-substring-no-properties beg end))
(metadata (completion-metadata (substring str 0 pt) table
pred)))
- (pcase (completion-try-completion str table pred pt metadata)
+ (pcase (let ((completion-styles (or corfu-completion-styles
completion-styles)))
+ (completion-try-completion str table pred pt metadata))
((and `(,newstr . ,newpt) (guard (not (equal str newstr))))
(completion--replace beg end newstr)
(goto-char (+ beg newpt)))))))
@@ -564,7 +571,8 @@ If `line-spacing/=nil' or in text-mode, the background
color is used instead.")
(defun corfu--completion-in-region (&rest args)
"Corfu completion in region function passing ARGS to
`completion--in-region'."
- (let ((completion-show-inline-help)
+ (let ((completion-styles (or corfu-completion-styles completion-styles))
+ (completion-show-inline-help)
(completion-auto-help))
(apply #'completion--in-region args)))
- [elpa] externals/corfu updated (7bab236 -> 4c2c997), Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 53ecf48 03/14: corfu-show-location/documentation: Add error messages, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 4e58a71 04/14: Minor optimizations, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu ff1579e 11/14: README: Add link to ELPA, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 2ebd35f 12/14: corfu-map: Bind M-n and M-p, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 4c2c997 14/14: Version 0.2, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 41eb724 02/14: Ignore corfu-abort if documentation/location window is shown, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 82474fb 01/14: Fix typo in corfu-minor-mode, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 7fcd09b 08/14: README: Update caveat, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 6e9b8ef 10/14: Add corfu-completion-styles,
Protesilaos Stavrou <=
- [elpa] externals/corfu 10660b4 07/14: corfu-first: Jump to the prompt if first candidate is selected, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu cf7c6c9 05/14: Do not show annotation in candidate preview (See #2), Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu cca1eaf 09/14: Extract corfu--move-prefix-candidates-to-front, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 6e91059 06/14: Fix some face issues, add comment about face usage, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu a01d068 13/14: Do not colorize left border (See #6), Protesilaos Stavrou, 2021/04/17