[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless a3471e47aa 083/204: Explain company integrati
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless a3471e47aa 083/204: Explain company integration (+ misc formatting improvements) |
Date: |
Tue, 11 Jan 2022 12:58:19 -0500 (EST) |
branch: externals/orderless
commit a3471e47aaf8bede75736137336b6970cdcd5679
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Explain company integration (+ misc formatting improvements)
---
README.org | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 49 insertions(+), 13 deletions(-)
diff --git a/README.org b/README.org
index 350c702c10..0a44714886 100644
--- a/README.org
+++ b/README.org
@@ -21,8 +21,7 @@ documentation).
With a bit of effort, it might still be possible to use =orderless= with
other completion UIs, even if those UIs don't support the standard
-Emacs completion styles. Currently there is support for
-[[https://github.com/abo-abo/swiper][Ivy]] and
+Emacs completion styles. Currently there is support for
[[https://github.com/abo-abo/swiper][Ivy]] and
[[https://github.com/raxod502/selectrum][Selectrum]] (see below).
If you use MELPA, the easiest way to install =orderless= is via
@@ -96,6 +95,14 @@ define new matching styles. The predefined ones are:
This is just =regexp-quote=.
+- orderless-prefixes :: the component is split at word endings and
+ each piece must match at a word boundary in the candidate, occurring
+ in that order.
+
+ This is similar to the built-in =partial-completion= completion-style.
+ For example, =re-re= matches =query-replace-regexp=, =recode-region= and
+ =magit-remote-list-refs=; =f-d.t= matches =final-draft.txt=.
+
- orderless-initialism :: each character of the component should appear
as the beginning of a word in the candidate, in order.
@@ -104,32 +111,24 @@ define new matching styles. The predefined ones are:
- orderless-strict-initialism :: like initialism but only allow
non-letters in between the matched words.
- For example =fb= would match =foo-bar= but not =foo-qux-bar=.
+ For example =fb= would match =foo-bar= but not =foo-qux-bar=.
- orderless-strict-leading-initialism :: like strict-initialism but
require the first initial to match the candidate's first word.
- For example =bb= would match =bar-baz= but not =foo-bar-baz=.
+ For example =bb= would match =bar-baz= but not =foo-bar-baz=.
- orderless-strict-full-initialism :: like strict-initialism but
require the first initial to match the candidate's first word and the
last initial to be at the final word.
- For example =fbb= would match =foo-bar-baz= but not =foo-bar-baz-qux=.
+ For example =fbb= would match =foo-bar-baz= but not =foo-bar-baz-qux=.
- orderless-flex :: the characters of the component should appear in
that order in the candidate, but not necessarily consecutively.
This maps =abc= to =a.*b.*c=.
-- orderless-prefixes :: the component is split at word endings and
- each piece must match at a word boundary in the candidate, occurring
- in that order.
-
- This is similar to the built-in =partial-completion= completion-style.
- For example, =re-re= matches =query-replace-regexp=, =recode-region= and
- =magit-remote-list-refs=; =f-d.t= matches =final-draft.txt=.
-
The variable =orderless-component-matching-styles= should be set to a
list of the desired styles to use. By default it enables the regexp
and initialism styles.
@@ -250,3 +249,40 @@ configuration:
(setq selectrum-refine-candidates-function #'orderless-filter)
(setq selectrum-highlight-candidates-function #'orderless-highlight-matches)
#+end_src
+
+** Company
+
+Company comes with a =company-capf= backend that uses the
+completion-at-point functions, which in turn use completion styles.
+This means that the =company-capf= backend will automatically use
+=orderless=, no configuration necessary!
+
+But there are a couple of points of discomfort:
+
+1. Pressing SPC takes you out of completion, so with the default
+ separator you are limited to one component, which is no fun. To fix
+ this add a separator that is allowed to occur in identifiers, for
+ example, for Emacs Lisp code you could use an ampersand:
+
+ #+begin_src emacs-lisp
+ (setq orderless-component-separator "[ &]")
+ #+end_src
+
+2. The matching portions of candidates aren't highlighted. That's
+ because =company-capf= is hard-coded to look for the
+ =completions-common-part= face, and it only use one face,
+ =company-echo-common= to highlight candidates.
+
+ So, while you can't get different faces for different components,
+ you can at least get the matches highlighted in the sole available
+ face with this configuration:
+
+ #+begin_src emacs-lisp
+ (defun just-one-face (fn &rest args)
+ (let ((orderless-match-faces [completions-common-part]))
+ (apply fn args)))
+
+ (advice-add 'company-capf--candidates :around #'just-one-face)
+ #+end_src
+
+ (Aren't dynamically scoped variables and the advice system nifty?)
- [elpa] externals/orderless 7f79dc2233 038/204: Don't move point unless actually completing, (continued)
- [elpa] externals/orderless 7f79dc2233 038/204: Don't move point unless actually completing, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ae36760f61 015/204: Colorize matching portions of candidates, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2913935f16 002/204: Add README and tweak commentary, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2be7bf8c3d 009/204: Add forgotten :test to cl-pushnew call, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 4effeb0839 032/204: Merge pull request #5 from protesilaos/update-defface-syntax, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 118ec4f36a 025/204: Document customization options, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3b2741737b 042/204: Fix regression bug on no matches, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ba93f3e521 055/204: Typo in README pointed out by codecoll, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c23a9a40be 050/204: Typo in README, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 40d46ba925 080/204: Fix typo, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a3471e47aa 083/204: Explain company integration (+ misc formatting improvements),
ELPA Syncer <=
- [elpa] externals/orderless 7e57a5458c 085/204: Allow dispatcher to modify component without handling it, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 7a547b5722 093/204: Drew says "progressive completion", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 99e90bf139 103/204: Declare orderless-old-component-separator obsolete too, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 42bca066b9 108/204: Split dispatchers into their own variable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 81248a8dbf 109/204: Merge branch 'dispatcher', ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 0efa87672d 011/204: Fix bug on no matches, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless acc2645cf3 030/204: Even better match faces (kindly contributed by Protesilaos), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 6ada0ad21c 035/204: Add docstrings to functions, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a371c26c69 003/204: Stronger wording for warning, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d576dc9fac 028/204: Add reminder that match faces only are used if orderless "wins", ELPA Syncer, 2022/01/11