aboutsummaryrefslogtreecommitdiffstats
path: root/elpa/company-20220425.1145/company.info
blob: c01ccb5f2507ba95e14e624487c7b51609f60f45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
This is company.info, produced by makeinfo version 6.7 from
company.texi.

This user manual is for Company version 0.9.14snapshot (8 January 2022).

Copyright © 2021-2022 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this
     document under the terms of the GNU Free Documentation License,
     Version 1.3 or any later version published by the Free Software
     Foundation.
INFO-DIR-SECTION Emacs misc features
START-INFO-DIR-ENTRY
* Company: (company).           A modular text completion framework.
END-INFO-DIR-ENTRY


File: company.info,  Node: Top,  Next: Overview,  Up: (dir)

Company
*******

Company is a modular text completion framework for GNU Emacs.

The goal of this document is to lay out the foundational knowledge of
the package, so that the readers of the manual could competently start
adapting Company to their needs and preferences.

This user manual is for Company version 0.9.14snapshot (8 January 2022).

Copyright © 2021-2022 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this
     document under the terms of the GNU Free Documentation License,
     Version 1.3 or any later version published by the Free Software
     Foundation.

* Menu:

* Overview:: Terminology and Structure
* Getting Started:: Quick Start Guide
* Customization:: User Options
* Frontends:: Frontends Usage Instructions
* Backends:: Backends Usage Instructions
* Troubleshooting:: When Something Goes Wrong
* Index::

— The Detailed Node Listing —

Overview

* Terminology::
* Structure::

Getting Started

* Installation::
* Initial Setup::
* Usage Basics::
* Commands::

Customization

* Customization Interface::
* Configuration File::

Frontends

* Tooltip Frontends::
* Preview Frontends::
* Echo Frontends::
* Candidates Search::
* Filter Candidates::
* Quick Access a Candidate::

Backends

* Backends Usage Basics::
* Grouped Backends::
* Package Backends::
* Candidates Post-Processing::



File: company.info,  Node: Overview,  Next: Getting Started,  Prev: Top,  Up: Top

1 Overview
**********

“Company” is a modular text completion framework for GNU Emacs.

In other words, it is a package for retrieving, manipulating, and
displaying text completion candidates.  It aims to assist developers,
writers, and scientists during code and text writing.

* Menu:

* Terminology::
* Structure::


File: company.info,  Node: Terminology,  Next: Structure,  Up: Overview

1.1 Terminology
===============

“Completion” is an act of intelligibly guessing possible variants of
words based on already typed characters.  To “complete” a word means to
insert a correctly guessed variant into the buffer.

Consequently, the “candidates” are the aforementioned guessed variants
of words.  Each of the candidates has the potential to be chosen for
successful completion.  And each of the candidates contains the
initially typed characters: either only at the beginning (so-called
“prefix matches”), or also inside (“non-prefix matches”) of a candidate
(1).

The package’s name “Company” is based on the combination of the two
words: ‘Complete’ and ‘Anything’.  These words reflect the package’s
commitment to handling completion candidates and its extensible nature
allowing it to cover a wide range of usage scenarios.

   ---------- Footnotes ----------

   (1) A good starting point to learn about types of matches is to play
with the Emacs’s user option ‘completion-styles’.  For illustrations on
how Company visualizes the matches, *note Frontends::.


File: company.info,  Node: Structure,  Prev: Terminology,  Up: Overview

1.2 Structure
=============

The Company is easily extensible because its significant building blocks
are pluggable modules: backends (*note Backends::) and frontends (*note
Frontends::).

The “backends” are responsible for retrieving completion candidates;
which are then outputted by the “frontends”.  For an easy and quick
initial setup, Company is supplied with the preconfigured sets of the
backends and frontends.  The default behavior of the modules can be
adjusted per particular needs, goals, and preferences.  It is also
typical to utilize backends from a variety of third-party libraries
(https://github.com/company-mode/company-mode/wiki/Third-Party-Packages),
developed to be pluggable with Company.

But Company consists not only of the backends and frontends.

A core of the package plays the role of a controller, connecting the
modules, making them work together; and exposing configurations and
commands for a user to operate with.  For more details, *note
Customization:: and *note Commands::.

Also, Company is bundled with an alternative workflow configuration
“company-tng” — defining ‘company-tng-frontend’, ‘company-tng-mode’, and
‘company-tng-map’ — that allows performing completion with just <TAB>.
To enable this configuration, add the following line to the Emacs
initialization file (*note (emacs)Init File::):

     (add-hook 'after-init-hook 'company-tng-mode)


File: company.info,  Node: Getting Started,  Next: Customization,  Prev: Overview,  Up: Top

2 Getting Started
*****************

This chapter provides basic instructions for Company setup and usage.

* Menu:

* Installation::
* Initial Setup::
* Usage Basics::
* Commands::


File: company.info,  Node: Installation,  Next: Initial Setup,  Up: Getting Started

2.1 Installation
================

Company package is distributed via commonly used package archives in a
form of both stable and development releases.  To install Company, type
‘M-x package-install <RET> company <RET>’.

For more details on Emacs package archives, *note (emacs)Packages::.


File: company.info,  Node: Initial Setup,  Next: Usage Basics,  Prev: Installation,  Up: Getting Started

2.2 Initial Setup
=================

The package Company provides a minor mode “company-mode”.

To activate the _company-mode_, execute the command ‘M-x company-mode’
that toggles the mode on and off.  When it is switched on, the mode line
(*note (emacs)Mode line::) should indicate its presence with an
indicator ‘company’.

After _company-mode_ had been enabled, the package auto-starts
suggesting completion candidates.  The candidates are retrieved and
shown according to the typed characters and the default (until a user
specifies otherwise) configurations.

To have Company always enabled for the following sessions, add the line
‘(global-company-mode)’ to the Emacs configuration file
(*note (emacs)Init File::).


File: company.info,  Node: Usage Basics,  Next: Commands,  Prev: Initial Setup,  Up: Getting Started

2.3 Usage Basics
================

By default — having _company-mode_ enabled (*note Initial Setup::) — a
tooltip with completion candidates is shown when a user types in a few
characters.

To initiate completion manually, use the command ‘M-x company-complete’.

To select next or previous of the shown completion candidates, use
respectively key bindings ‘C-n’ and ‘C-p’, then do one of the following:

   • Hit <RET> to choose a selected candidate for completion.

   • Hit <TAB> to complete with the “common part”: characters present at
     the beginning of all the candidates.

   • Hit ‘C-g’ to stop activity of Company.


File: company.info,  Node: Commands,  Prev: Usage Basics,  Up: Getting Started

2.4 Commands
============

Under the hood, mentioned in the previous section keys are bound to the
commands of the out-of-the-box Company.

‘C-n’
‘M-n’
     Select the next candidate (‘company-select-next-or-abort’,
     ‘company-select-next’).

‘C-p’
‘M-p’
     Select the previous candidate (‘company-select-previous-or-abort’,
     ‘company-select-previous’).

‘RET’
‘<return>’
     Insert the selected candidate (‘company-complete-selection’).

‘TAB’
‘<tab>’
     Insert the common part of all the candidates
     (‘company-complete-common’).

‘C-g’
‘<ESC ESC ESC>’
     Cancel _company-mode_ activity (‘company-abort’).

‘C-h’
‘<f1>’
     Display a buffer with the documentation for the selected candidate
     (‘company-show-doc-buffer’).

‘C-w’
     Display a buffer with the definition of the selected candidate
     (‘company-show-location’).

The full list of the default key bindings is stored in the variables
‘company-active-map’ and ‘company-search-map’ (1).

Moreover, Company is bundled with a number of convenience commands that
do not have default key bindings defined.  The following examples
illustrate how to assign key bindings to such commands.

     (global-set-key (kbd "<tab>") #'company-indent-or-complete-common)

     (with-eval-after-load 'company
       (define-key company-active-map (kbd "M-/") #'company-complete))

     (with-eval-after-load 'company
       (define-key company-active-map
                   (kbd "TAB")
                   #'company-complete-common-or-cycle)
       (define-key company-active-map
                   (kbd "<backtab>")
                   (lambda ()
                     (interactive)
                     (company-complete-common-or-cycle -1))))

In the same manner, an additional key can be assigned to a command or a
command can be unbound from a key.  For instance:

     (with-eval-after-load 'company
       (define-key company-active-map (kbd "M-.") #'company-show-location)
       (define-key company-active-map (kbd "RET") nil))

   ---------- Footnotes ----------

   (1) For a more user-friendly output of the pre-defined key bindings,
utilize ‘M-x describe-keymap <RET> company-active-map’ or
‘C-h f <RET> company-mode’.


File: company.info,  Node: Customization,  Next: Frontends,  Prev: Getting Started,  Up: Top

3 Customization
***************

Emacs provides two equally acceptable ways for user preferences
configuration: via customization interface (for more details, *note
(emacs)Easy Customization::) and a configuration file
(*note (emacs)Init File::).  Naturally, Company can be configured by
both of these approaches.

* Menu:

* Customization Interface::
* Configuration File::


File: company.info,  Node: Customization Interface,  Next: Configuration File,  Up: Customization

3.1 Customization Interface
===========================

In order to employ the customization interface, run
‘M-x customize-group <RET> company’.

This interface outputs all the options available for user customization,
so you may find it beneficial to review this list even if you are going
to configure Company with the configuration file.

For instructions on how to change the settings, *note (emacs)Changing a
Variable::.


File: company.info,  Node: Configuration File,  Prev: Customization Interface,  Up: Customization

3.2 Configuration File
======================

Company is a customization-rich package.  This section lists some of the
core settings that influence the overall behavior of the _company-mode_.

 -- User Option: company-minimum-prefix-length
     This is one of the values (together with ‘company-idle-delay’),
     based on which Company auto-stars looking up completion candidates.
     This option configures how many characters have to be typed in by a
     user before candidates start to be collected and displayed.  An
     often choice nowadays is to configure this option to a lower number
     than the default value of ‘3’.

 -- User Option: company-idle-delay
     This is the second of the options that configure Company’s
     auto-start behavior (together with
     ‘company-minimum-prefix-length’).  The value of this option defines
     how fast Company is going to react to the typed input, such that
     setting ‘company-idle-delay’ to ‘0’ makes Company react
     immediately, ‘nil’ disables auto-starting, and a larger value
     postpones completion auto-start for that number of seconds.  For an
     even fancier setup, set this option value to a predicate function,
     as shown in the following example:

          (setq company-idle-delay
                (lambda () (if (company-in-string-or-comment) nil 0.3)))

 -- User Option: company-global-modes
     This option allows to specify in which major modes _company-mode_
     can be enabled by ‘(global-company-mode)’.  *Note Initial Setup::.
     The default value of ‘t’ enables Company in all major modes.
     Setting ‘company-global-modes’ to ‘nil’ equal in action to toggling
     off _global-company-mode_.  Providing a list of major modes results
     in having _company-mode_ enabled in the listed modes only.  For the
     opposite result, provide a list of major modes with ‘not’ being the
     first element of the list, as shown in the following example:

          (setq company-global-modes '(not erc-mode message-mode eshell-mode))

 -- User Option: company-selection-wrap-around
     Enable this option to loop (cycle) the candidates’ selection: after
     selecting the last candidate on the list, a command to select the
     next candidate does so with the first candidate.  By default, this
     option is disabled, which means the selection of the next candidate
     stops on the last item.  The selection of the previous candidate is
     influenced by this option similarly.

 -- User Option: company-require-match
     To allow typing in characters that don’t match the candidates, set
     the value of this option to ‘nil’.  For an opposite behavior (that
     is, to disallow non-matching input), set it to ‘t’.  By default,
     Company is configured to require a matching input only if a user
     manually enables completion or selects a candidate; by having the
     option configured to call the function ‘company-explicit-action-p’.

 -- User Option: company-lighter-base
     This user options allows to configure a string indicator of the
     enabled _company-mode_ in the mode line.  The default value is
     ‘company’.

 -- User Option: company-insertion-on-trigger
     One more pair of the user options may instruct Company to complete
     with the selected candidate by typing one of the
     ‘company-insertion-triggers’.  The user option
     ‘company-insertion-on-trigger’ can be enabled or disabled by
     setting its value to one of: ‘nil’, ‘t’, or a predicate function
     name.  *note Predicate: (eintr)Wrong Type of Argument.

 -- User Option: company-insertion-triggers
     This option has an effect only when ‘company-insertion-on-trigger’
     is enabled.  The value can be one of: a string of characters, a
     list of syntax description characters (*note (elisp)Syntax Class
     Table::), or a predicate function.  By default, this user option is
     set to the list of the syntax characters: ‘(?\ ?\) ?.)’, which
     translates to the whitespaces, close parenthesis, and punctuation.
     It is safe to configure the value to a character that can
     potentially be part of a valid completion; in this case, Company
     does not treat such characters as triggers.

Hooks
-----

Company exposes the following life-cycle hooks:

 -- User Option: company-completion-started-hook

 -- User Option: company-completion-cancelled-hook

 -- User Option: company-completion-finished-hook

 -- User Option: company-after-completion-hook


File: company.info,  Node: Frontends,  Next: Backends,  Prev: Customization,  Up: Top

4 Frontends
***********

Company is packaged with several frontends and provides a predefined set
of enabled frontends.  A list of the enabled frontends can be changed by
configuring the user option ‘company-frontends’.

Each frontend is simply a function that receives a command and acts
accordingly to it: outputs candidates, hides its output, refreshes
displayed data, and so on.

All of the Company frontends can be categorized by the type of the
output into the three groups: “tooltip-”, “preview-”, and “echo-”
frontends.  We overview these groups in the first sections of this
chapter.  The sections that follow are dedicated to the ways the
displayed candidates can be searched, filtered, and quick-accessed.

* Menu:

* Tooltip Frontends::
* Preview Frontends::
* Echo Frontends::
* Candidates Search::
* Filter Candidates::
* Quick Access a Candidate::


File: company.info,  Node: Tooltip Frontends,  Next: Preview Frontends,  Up: Frontends

4.1 Tooltip Frontends
=====================

This group of frontends displays completion candidates in an overlayed
tooltip (aka pop-up).  Company provides three _tooltip frontends_,
listed below.

 -- Function: company-pseudo-tooltip-unless-just-one-frontend
     This is one of the default frontends.  It starts displaying a
     tooltip only if more than one completion candidate is available,
     which nicely combines — and it is done so by default — with
     ‘company-preview-if-just-one-frontend’, *note Preview Frontends::.

 -- Function: company-pseudo-tooltip-frontend
     This frontend outputs a tooltip for any number of completion
     candidates.

 -- Function: company-pseudo-tooltip-unless-just-one-frontend-with-delay
     This is a peculiar frontend, that displays a tooltip only if more
     than one candidate is available, and only after a delay.  The delay
     can be configured with the user option
     ‘company-tooltip-idle-delay’.  A typical use case for plugging in
     this frontend would be displaying a tooltip only on a manual
     request (when needed), as shown in the following example:

          (setq company-idle-delay 0
                company-tooltip-idle-delay 10
                company-require-match nil
                company-frontends
                '(company-pseudo-tooltip-unless-just-one-frontend-with-delay
                  company-preview-frontend
                  company-echo-metadata-frontend)
                company-backends '(company-capf))

          (global-set-key (kbd "<tab>")
                          (lambda ()
                            (interactive)
                            (let ((company-tooltip-idle-delay 0.0))
                              (company-complete)
                              (and company-candidates
                                   (company-call-frontends 'post-command)))))

User Options
------------

To change the _tooltip frontends_ configuration, adjust the following
user options.

 -- User Option: company-tooltip-align-annotations
     An “annotation” is a string that carries additional information
     about a candidate; such as a data type, function arguments, or
     whatever a backend appoints to be a valuable piece of information
     about a candidate.  By default, the annotations are shown right
     beside the candidates.  Setting the option value to ‘t’ aligns
     annotations to the right side of the tooltip.

          (setq company-tooltip-align-annotations t)

         [image src="./images/small/tooltip-annotations.png"]

 -- User Option: company-tooltip-limit
     Controls the maximum number of the candidates shown simultaneously
     in the tooltip (the default value is ‘10’).  When the number of the
     available candidates is larger than this option’s value, Company
     paginates the results.

          (setq company-tooltip-limit 4)

            [image src="./images/small/tooltip-limit.png"]

 -- User Option: company-tooltip-offset-display
     Use this option to choose in which way to output paginated results.
     The default value is ‘scrollbar’.  Another supported value is
     ‘lines’; choose it to show the quantity of the candidates not
     displayed by the current tooltip page.

          (setq company-tooltip-offset-display 'lines)

        [image src="./images/small/tooltip-offset-display.png"]

 -- User Option: company-tooltip-minimum
     This user option acts only when a tooltip is shown close to the
     bottom of a window.  It guarantees visibility of this number of
     completion candidates below point.  When the number of lines
     between point and the bottom of a window is less than
     ‘company-tooltip-minimum’ value, the tooltip is displayed above
     point.

          (setq company-tooltip-minimum 4)

        [image src="./images/small/tooltip-minimum-below.png"]


        [image src="./images/small/tooltip-minimum-above.png"]

 -- User Option: company-tooltip-flip-when-above
     This is one of the fancy features Company has to suggest.  When
     this setting is enabled, no matter if a tooltip is shown above or
     below point, the candidates are always listed starting near point.
     (Putting it differently, the candidates are mirrored horizontally
     if a tooltip changes its position, instead of being commonly listed
     top-to-bottom.)

          (setq company-tooltip-flip-when-above t)

             [image src="./images/small/tooltip-flip.png"]

 -- User Option: company-tooltip-minimum-width
     Sets the minimum width of a tooltip, excluding the margins and the
     scroll bar.  Changing this value especially makes sense if a user
     navigates between tooltip pages.  Keeping this value at the default
     ‘0’ allows Company to always adapt the width of the tooltip to the
     longest shown candidate.  Enlarging ‘company-tooltip-minimum-width’
     prevents possible significant shifts in the width of the tooltip
     when navigating to the next/previous tooltip page.  (For an
     alternate solution, see ‘company-tooltip-width-grow-only’.)

 -- User Option: company-tooltip-width-grow-only
     This is another way to restrict auto-adaptation of the tooltip
     width (another is by adjusting ‘company-tooltip-minimum-width’
     value) when navigating between the tooltip pages.

 -- User Option: company-tooltip-maximum-width
     This user option controls the maximum width of the tooltip inner
     area.  By default, its value is pseudo-limitless, potentially
     permitting the output of extremely long candidates.  But if long
     lines become an issue, set this option to a smaller number, such as
     ‘60’ or ‘70’.

 -- User Option: company-tooltip-margin
     Controls the width of the “margin” on the sides of the tooltip
     inner area.  If ‘company-format-margin-function’ is set,
     ‘company-tooltip-margin’ defines only the right margin.

          (setq company-tooltip-margin 3)

            [image src="./images/small/tooltip-margin.png"]

Candidates Icons
----------------

An “icon” is an image or a text that represents a candidate’s kind; it
is displayed in front of a candidate.  The term “kind” here stands for a
high-level category a candidate fits into.  (Such as ‘array’,
‘function’, ‘file’, ‘string’, ‘color’, etc.  For an extended list of the
possible _kinds_, see the user option ‘company-text-icons-mapping’ or
the variable ‘company-vscode-icons-mapping’.)

 -- User Option: company-format-margin-function
     Allows setting a function to format the left margin of a tooltip
     inner area; namely, to output candidate’s _icons_.  The predefined
     formatting functions are listed below.  A user may also set this
     option to a custom function.  To disable left margin formatting,
     set the value of the option to ‘nil’ (this way control over the
     size of the left margin returns to the user option
     ‘company-tooltip-margin’).

 -- Function: company-vscode-dark-icons-margin
 -- Function: company-vscode-light-icons-margin
     These functions utilize VSCode dark and light theme icon sets (1).
     The related two user options are ‘company-icon-size’ and
     ‘company-icon-margin’.

         [image src="./images/small/tooltip-icons-vscode.png"]

 -- Function: company-text-icons-margin
     This function produces letters and symbols formatted according to
     the ‘company-text-icons-format’.  The rest of the user options
     affecting this function behavior are listed below.

          [image src="./images/small/tooltip-icons-text.png"]

 -- Function: company-dot-icons-margin
     This function produces a colored Unicode symbol of a circle
     formatted according to the ‘company-dot-icons-format’.  Other user
     options that affect the resulting output are listed below.

          [image src="./images/small/tooltip-icons-dot.png"]

The following user options influence appearance of the _text_ and _dot_
_icons_.

 -- User Option: company-text-icons-mapping
     Lists candidates’ _kinds_ with their corresponding _icons_
     configurations.

 -- User Option: company-text-face-extra-attributes
     A list of face attributes to be applied to the _icons_.

          (setq company-text-face-extra-attributes
                '(:weight bold :slant italic))

          [image src="./images/small/tooltip-icon-face.png"]

 -- User Option: company-text-icons-add-background
     If this option is enabled, when an _icon_ doesn’t have a background
     configured by ‘company-text-icons-mapping’, then a generated
     background is applied.

          (setq company-text-icons-add-background t)

           [image src="./images/small/tooltip-icon-bg.png"]

 -- Function: company-detect-icons-margin
     This is the default margin formatting function, that applies one of
     the ‘company-vscode-*-icons-margin’ functions if ‘vscode’ icons set
     is supported; otherwise applies a ‘company-text-icons-margin’
     function.

Faces
-----

Out-of-the-box Company defines and configures distinguished faces (*note
(emacs)Faces::) for light and dark themes.  Moreover, some of the
built-in and third-party themes fine-tune Company to fit their palettes.
That is why there’s often no real need to make such adjustments on a
user side.  However, this chapter presents some hints on where to start
customizing Company interface.

Namely, the look of a tooltip is controlled by the ‘company-tooltip*’
named faces.

The following example hints how a user may approach tooltip faces
customization:

     (custom-set-faces
      '(company-tooltip
        ((t (:background "ivory" :foreground "MistyRose3"))))
      '(company-tooltip-selection
        ((t (:background "LemonChiffon1" :foreground "MistyRose4"))))
      '(company-tooltip-common ((t (:weight bold :foreground "pink1"))))
      '(company-scrollbar-fg ((t (:background "ivory3"))))
      '(company-scrollbar-bg ((t (:background "ivory2"))))
      '(company-tooltip-annotation ((t (:foreground "MistyRose2")))))

         [image src="./images/small/tooltip-faces-light.png"]

   ---------- Footnotes ----------

   (1) SVG images support has to be enabled in Emacs for these icons set
to be used.  The supported images types can be checked with ‘C-h v
image-types’.  Before compiling Emacs, make sure ‘librsvg’ is installed
on your system.


File: company.info,  Node: Preview Frontends,  Next: Echo Frontends,  Prev: Tooltip Frontends,  Up: Frontends

4.2 Preview Frontends
=====================

Frontends in this group output a completion candidate or a common part
of the candidates temporarily inline, as if a word had already been
completed (1).

 -- Function: company-preview-if-just-one-frontend
     This is one of the frontends enabled by default.  This frontend
     outputs a preview if only one completion candidate is available; it
     is a good suit to be combined with
     ‘company-pseudo-tooltip-unless-just-one-frontend’, *note Tooltip
     Frontends::.

 -- Function: company-preview-frontend
     This frontend outputs the first of the available completion
     candidates inline for a preview.

 -- Function: company-preview-common-frontend
     As the name of this frontend suggests, it outputs for a preview
     only a common part of the candidates.

The look of the preview is controlled by the following faces:
‘company-preview’, ‘company-preview-common’, and
‘company-preview-search’.

            [image src="./images/small/preview-light.png"]


             [image src="./images/small/preview-dark.png"]

   ---------- Footnotes ----------

   (1) The candidates retrieved according to ‘non-prefix’ matches (*note
Terminology::) may be shown in full after point.


File: company.info,  Node: Echo Frontends,  Next: Candidates Search,  Prev: Preview Frontends,  Up: Frontends

4.3 Echo Frontends
==================

The frontends listed in this section display information in the Emacs’s
echo area, *note (emacs)Echo Area::.

 -- Function: company-echo-metadata-frontend
     This frontend is a part of the predefined frontends set.  Its
     responsibility is to output a short documentation string for a
     completion candidate in the echo area.

              [image src="./images/small/echo-meta.png"]


The last pair of the built-in frontends isn’t that commonly used and not
as full-featured as the previously reviewed _tooltip-_ and _preview-_
frontends, but still, feel free to play with them and have some fun!

 -- Function: company-echo-frontend
     This frontend outputs all the available completion candidates in
     the echo area.

                 [image src="./images/small/echo.png"]

 -- Function: company-echo-strip-common-frontend
     It acts similarly to the previous frontend but outputs a common
     part of the candidates once for all of them.

              [image src="./images/small/echo-strip.png"]

 -- User Option: company-echo-truncate-lines
     This is the only _echo frontends_ targeted setting.  When enabled,
     the output is truncated to fit the echo area.  This setting is set
     to ‘t’ by default.

To apply visual changes to the output of these frontends, configure the
faces ‘company-echo’ and ‘company-echo-common’.


File: company.info,  Node: Candidates Search,  Next: Filter Candidates,  Prev: Echo Frontends,  Up: Frontends

4.4 Candidates Search
=====================

By default, when _company-mode_ is in action, a key binding ‘C-s’ starts
looking for matches to additionally typed characters among the displayed
candidates.  When a search is initiated, an indicator
‘Search: CHARACTERS’ is shown in the Emacs’s mode line.

To quit the search mode, hit ‘C-g’.

 -- User Option: company-search-regexp-function
     The value of this user option must be a function that interprets
     the search input.  By default it is set to the function
     ‘regexp-quote’, with looks for an exact match.  Company defines
     several more functions suitable for this option.  They are listed
     below.

 -- Function: company-search-words-regexp
     Searches for words separated with spaces in the given order.

 -- Function: company-search-words-in-any-order-regexp
     Searches for words separated with spaces in any order.

 -- Function: company-search-flex-regexp
     Searches for characters in the given order, with anything in
     between.

Search matches are distinguished by the ‘company-tooltip-search’ and
‘company-tooltip-search-selection’ faces.

            [image src="./images/small/tooltip-search.png"]


File: company.info,  Node: Filter Candidates,  Next: Quick Access a Candidate,  Prev: Candidates Search,  Up: Frontends

4.5 Filter Candidates
=====================

Candidates filtering is started by typing the default key binding
‘C-M-s’.  Filtering acts on a par with the search (*note Candidates
Search::), indicating its activation by the text ‘Filter: CHARACTERS’ in
the mode line and influencing the displayed candidates.  The difference
is that the filtering, as its name suggests, keeps displaying only the
matching candidates (in addition to distinguishing the matches with a
face).

To quit the filtering, hit ‘C-g’.  To toggle between search and filter
states, use key binding ‘C-o’.

            [image src="./images/small/tooltip-filter.png"]


File: company.info,  Node: Quick Access a Candidate,  Prev: Filter Candidates,  Up: Frontends

4.6 Quick Access a Candidate
============================

Company provides a way to choose a candidate for completion without
having to navigate to that candidate: by hitting one of the quick-access
keys.  By default, quick-access key bindings utilize a modifier <META>
and one of the digits, such that pressing ‘M-1’ completes with the first
candidate on the list and ‘M-0’ with the tenth candidate.

If ‘company-show-quick-access’ is enabled, _tooltip-_ and _echo-_
frontends show quick-access hints.

     (setq company-show-quick-access 'left)

         [image src="./images/small/tooltip-quick-access.png"]


               [image src="./images/small/echo-qa.png"]


            [image src="./images/small/echo-strip-qa.png"]

To customize the key bindings, either do it via Customization Interface
(*note Customization Interface::) or use the following approach:

     (custom-set-variables
      '(company-quick-access-keys '("a" "o" "e" "u" "i"))
      '(company-quick-access-modifier 'super))

A modifier should be one of ‘meta’, ‘super’, ‘hyper’, ‘ control’.

The following example applies a bit of customization and demonstrates
how to change quick-access hints faces.

     (setq company-show-quick-access t)

     (custom-set-faces
      '(company-tooltip-quick-access ((t (:foreground "pink1"))))
      '(company-tooltip-quick-access-selection
        ((t (:foreground "pink1" :slant italic)))))

        [image src="./images/small/tooltip-qa-faces-light.png"]


File: company.info,  Node: Backends,  Next: Troubleshooting,  Prev: Frontends,  Up: Top

5 Backends
**********

We can metaphorically say that each backend is like an engine.  (The
reality is even better since backends are just functions.)  Fueling such
an engine with a command causes the production of material for Company
to move further on.  Typically, moving on means outputting that material
to a user via one or several configured frontends, *note Frontends::.

Just like Company provides a preconfigured list of the enabled
frontends, it also defines a list of the backends to rely on by default.
This list is stored in the user option ‘company-backends’.  The
docstring of this variable has been a source of valuable information for
years.  That’s why we’re going to stick to a tradition and suggest
reading the output of ‘C-h v company-backends’ for insightful details
about backends.  Nevertheless, the fundamental concepts are described in
this user manual too.

* Menu:

* Backends Usage Basics::
* Grouped Backends::
* Package Backends::
* Candidates Post-Processing::


File: company.info,  Node: Backends Usage Basics,  Next: Grouped Backends,  Up: Backends

5.1 Backends Usage Basics
=========================

One of the significant concepts to understand about Company is that the
package relies on one backend at a time (1).  The backends are invoked
one by one, in the sequential order of the items on the
‘company-backends’ list.

The name of the currently active backend is shown in the mode line and
in the output of the command ‘M-x company-diag’.

In most cases (mainly to exclude false-positive results), the next
backend is not invoked automatically.  For the purpose of invoking the
next backend, use the command ‘company-other-backend’: either by calling
it with ‘M-x’ or by binding the command to the keys of your choice, such
as:

     (global-set-key (kbd "C-c C-/") #'company-other-backend)

It is also possible to specifically start a backend with the command
‘M-x company-begin-backend’ or by calling a backend by its name, for
instance: ‘M-x company-capf’.  As usual for Emacs, such backends calls
can be assigned to key bindings, for example:

     (global-set-key (kbd "C-c y") 'company-yasnippet)

   ---------- Footnotes ----------

   (1) The grouped backends act as one complex backend.  *Note Grouped
Backends::.


File: company.info,  Node: Grouped Backends,  Next: Package Backends,  Prev: Backends Usage Basics,  Up: Backends

5.2 Grouped Backends
====================

In many cases, it can be desirable to receive candidates from several
backends simultaneously.  This can be achieved by configuring “grouped
backends”: a sub-list of backends in the ‘company-backends’ list, that
is handled specifically by Company.

The most important part of this handling is the merge of the completion
candidates from the grouped backends.  (But only from the backends that
return the same _prefix_ value, see ‘C-h v company-backends’ for more
details.)

To keep the candidates organized in accordance with the grouped backends
order, add the keyword ‘:separate’ to the list of the grouped backends.
The following example illustrates this.

     (defun my-text-mode-hook ()
       (setq-local company-backends
                   '((company-dabbrev company-ispell :separate)
                     company-files)))

     (add-hook 'text-mode-hook #'my-text-mode-hook)

Another keyword ‘:with’ helps to make sure the results from major/minor
mode agnostic backends (such as _company-yasnippet_,
_company-dabbrev-code_) are returned without preventing results from
context-aware backends (such as _company-capf_ or _company-clang_).  For
this feature to work, put backends dependent on a mode at the beginning
of the grouped backends list, then put a keyword ‘:with’, and only then
put context agnostic backend(s), as shown in the following concise
example:

     (setq company-backends '((company-capf :with company-yasnippet)))


File: company.info,  Node: Package Backends,  Next: Candidates Post-Processing,  Prev: Grouped Backends,  Up: Backends

5.3 Package Backends
====================

The following sections give a short overview of the commonly used
backends bundled with Company.  Each section is devoted to one of the
roughly outlined groups of the backends.

Some of the backends expose user options for customization; a few of
these options are introduced below.  For those who would like to fetch
the full list of a backend’s user options, we suggest doing one of the
following:

   • Execute command ‘M-x customize-group <RET> <backend-name>’.

   • Open the source file of the backend and run
     ‘M-x occur <RET> ^(defcustom’.

        − Optionally, search for the matches with
          ‘M-x isearch <RET> (defcustom’.

* Menu:

* Code Completion::
* Text Completion::
* File Name Completion::
* Template Expansion::


File: company.info,  Node: Code Completion,  Next: Text Completion,  Up: Package Backends

5.3.1 Code Completion
---------------------

 -- Function: company-capf
     In the Emacs’s world, the current tendency is to have the
     completion logic provided by ‘completion-at-point-functions’ (CAPF)
     implementations.  [Among the other things, this is what the popular
     packages that support language server protocol (LSP) also rely on.]

     Since _company-capf_ works as a bridge to the standard CAPF
     facility, it is probably the most often used and recommended
     backend nowadays, including for Emacs Lisp coding.

     Just to illustrate, the following minimal backends setup

          (setq company-backends '((company-capf company-dabbrev-code)))

     might cover a large number of basic use cases, especially so in
     major modes that have CAPF support implemented.

     For more details on CAPF, *note (elisp)Completion in Buffers::.

 -- Function: company-dabbrev-code
     This backend works similarly to the built-in Emacs package
     _dabbrev_, searching for completion candidates inside the contents
     of the open buffer(s).  Internally, its based on the backend
     _company-dabbrev_ (*note Text Completion::).

 -- Function: company-keywords
     This backend provides completions for many of the widely spread
     programming languages _keywords_: words bearing specific meaning in
     a language.

 -- Function: company-clang
     As the name suggests, use this backend to get completions from
     _Clang_ compiler; that is, for the languages in the _C_ language
     family: _C_, _C++_, _Objective-C_.

 -- Function: company-semantic
     This backend relies on a built-in Emacs package that provides
     language-aware editing commands based on source code parsers, *note
     (emacs)Semantic::.  Having enabled _semantic-mode_ makes it to be
     used by the CAPF mechanism (*note (emacs)Symbol Completion::),
     hence a user may consider enabling _company-capf_ backend instead.

 -- Function: company-etags
     This backend works on top of a built-in Emacs package _etags_,
     *note (emacs)Tags Tables::.  Similarly to aforementioned _Semantic_
     usage, tags-based completions now are a part of the Emacs’ CAPF
     facility, therefore a user may consider switching to _company-capf_
     backend.


File: company.info,  Node: Text Completion,  Next: File Name Completion,  Prev: Code Completion,  Up: Package Backends

5.3.2 Text Completion
---------------------

 -- Function: company-dabbrev
     This backend works similarly to the built-in Emacs package
     _dabbrev_, searching for completion candidates inside the contents
     of the open buffer(s).  It is one of the often used backends, and
     it has several interesting options for configuration.  Let’s review
     a few of them.

      -- User Option: company-dabbrev-minimum-length
          This option sets the minimum length of a completion candidate
          to collect from the text.  The default value of ‘4’ is
          intended to prevent potential performance issues.  But in many
          scenarios, it may be acceptable to lower this value.  Note
          that this option also affects the behavior of the
          _company-dabbrev-code_ backend.

               (setq company-dabbrev-minimum-length 2)

      -- User Option: company-dabbrev-other-buffers
          By default, _company-dabbrev_ collects completion candidates
          from all not ignored buffers (see more on that below).  This
          behavior can be changed to collecting candidates from the
          current buffer only (by setting the value to ‘nil’) or from
          the buffers with the same major mode:

               (setq company-dabbrev-other-buffers t)

      -- User Option: company-dabbrev-ignore-buffers
          The value of this option should be a regexp or a predicate
          function that can be used to match a buffer name.  The matched
          buffers are omitted from the search for completion candidates.

     The last two options described here relate to handling uppercase
     and lowercase letters in completion candidates.  The illustrative
     examples given below can be reproduced in the ‘*scratch*’ buffer,
     with the word ‘Enjoy’ typed in, and with this initial setup:

          (setq-local company-backends '(company-dabbrev)
                      company-dabbrev-other-buffers nil
                      company-dabbrev-ignore-case nil
                      company-dabbrev-downcase nil)

      -- User Option: company-dabbrev-ignore-case
          This user option controls whether the case is ignored when
          collecting completion candidates.  When the option is set to
          ‘nil’, ‘Enjoy’ is suggested as a completion candidate for the
          typed ‘Enj’ letters, but not for ‘enj’.  When the option is
          set to ‘t’, ‘Enjoy’ is suggested as a candidate for both ‘Enj’
          and ‘enj’ input; note that ‘enj’ prefix is “overwritten” by
          completing with the ‘Enjoy’ candidate.  The third, default,
          type of behavior solves this issue, keeping the case of the
          typed prefix (and still collecting candidates
          case-insensitively):

               (setq company-dabbrev-ignore-case 'keep-prefix)

          Now we can type ‘enj’, complete it with the suggested ‘Enjoy’,
          and _enjoy_ the result.

      -- User Option: company-dabbrev-downcase
          This user option controls whether completion candidates are
          down-cased before their display.  When the option is set to
          ‘nil’, no transformation is performed; in the environment
          described above, typing ‘Enj’ results in the candidate ‘Enjoy’
          being suggested.  When the option is set to ‘t’, the
          down-cased candidate ‘enjoy’ is suggested.  By default, this
          option is set to ‘case-replace’, meaning taking a value of the
          Emacs’s variable ‘case-replace’ (‘t’ is the current default).


 -- Function: company-ispell
     This backend returns completion candidates collected by _Ispell_, a
     built-in Emacs package that performs spell-checking.  *Note
     Checking and Correcting Spelling: (emacs)Spelling.  Note that
     _Ispell_ uses only one dictionary at a time (combining several
     dictionaries into one file is an accepted practice).  By default,
     _company-ispell_ suggests candidates from a dictionary specified by
     the Emacs’s setting ‘ispell-complete-word-dict’.

      -- User Option: company-ispell-dictionary
          Optionally, set a file path for _company-ispell_ to use
          another dictionary.


File: company.info,  Node: File Name Completion,  Next: Template Expansion,  Prev: Text Completion,  Up: Package Backends

5.3.3 File Name Completion
--------------------------

 -- Function: company-files
     This backend can be used to retrieve completion candidates for the
     absolute and relative paths in the directory structure of an
     operating system.  The behavior of the _company-files_ backend can
     be adjusted with the two user options.

      -- User Option: company-files-exclusions
          It may be desirable to exclude directories or files from the
          list of suggested completion candidates.  For example,
          someone’s setup might look this way:

               (setq company-files-exclusions '(".git/" ".DS_Store"))

      -- User Option: company-files-chop-trailing-slash
          This setting is enabled by default, which results in stripping
          off a trailing slash from an inserted directory name.  On
          typing a trailing slash, the process of completion gets
          started again, from inside the just inserted directory.

          Setting ‘company-files-chop-trailing-slash’ to ‘nil’ makes
          directory names to be inserted as is, with a trailing slash.
          In this case, the completion process can be continued, for
          example, either by explicitly calling _company-files_ backend
          (*note Backends Usage Basics::) or by starting typing a name
          of a file/directory known to be located under the inserted
          directory.


File: company.info,  Node: Template Expansion,  Prev: File Name Completion,  Up: Package Backends

5.3.4 Template Expansion
------------------------

 -- Function: company-abbrev
     This is a completion backend for a built-in word abbreviation mode
     (*note (emacs)Abbrevs::), that allows completing abbreviations with
     their expansions.

 -- Function: company-tempo
     A backend for users of Tempo
     (https://www.lysator.liu.se/~davidk/elisp/), one more built-in
     Emacs package for creating and inserting (expanding) templates.

 -- Function: company-yasnippet
     Used as a completion backend for the popular third-party template
     system YASnippet (https://github.com/joaotavora/yasnippet).


File: company.info,  Node: Candidates Post-Processing,  Prev: Package Backends,  Up: Backends

5.4 Candidates Post-Processing
==============================

A list of completion candidates, supplied by a backend, can be
additionally manipulated (reorganized, reduced, sorted, etc) before its
output.  This is done by adding a processing function name to the user
option ‘company-transformers’ list, for example:

     (setq company-transformers '(delete-consecutive-dups
                                  company-sort-by-occurrence))

Company is bundled with several such transformer functions.  They are
listed below.

 -- Function: company-sort-by-occurrence
     Sorts candidates using ‘company-occurrence-weight-function’
     algorithm.

 -- User Option: company-occurrence-weight-function
     Can be set to one of ‘company-occurrence-prefer-closest-above’
     (default) or ‘company-occurrence-prefer-any-closest’.  This user
     option defines the behavior of the ‘company-sort-by-occurrence’
     transformer function.

 -- Function: company-sort-by-backend-importance
     Sorts candidates as two priority groups, differentiated by the
     keyword ‘:with’ (*note Grouped Backends::).  Backends positioned in
     the backends list before the keyword ‘:with’ are treated as more
     important.

 -- Function: company-sort-prefer-same-case-prefix
     Gives preference to the candidates that match the prefix
     case-insensitively.


File: company.info,  Node: Troubleshooting,  Next: Index,  Prev: Backends,  Up: Top

6 Troubleshooting
*****************

If something goes wrong, the first thing we recommend doing is to
execute command ‘M-x company-diag’ and thoroughly study its output.

This command outputs important details about the internal workings of
Company at the moment of the ‘company-diag’ command execution, including
a responsible backend and a list of completion candidates provided by
it.

Based on the value of the ‘Used backend’ in the output of the command
‘M-x company-diag’, these possible actions may follow:

   • If the used backend does not belong to the Company package, report
     the issue to the corresponding third-party package maintainer(s).

   • If the used backend is ‘company-capf’, then take a look at the line
     starting with ‘Value of c-a-p-f:’.  The issue could have been
     caused by a function listed there.  To identify to which package it
     belongs, type ‘M-x find-function <RET> <function-name> <RET>’.

If the aforementioned steps didn’t help to find the cause of the issue,
then file a bug report to
the Company Issue Tracker (https://github.com/company-mode/company-mode/issues),
attaching the following information:

  1. Output of the ‘M-x company-diag’.

  2. The exact error message: you can find it in the ‘*Messages*’
     buffer.

  3. The steps to reproduce the behavior.  Ideally, if you can, starting
     with a bare Emacs session: ‘emacs -Q’.

  4. The backtrace of the error, which you can get by running the
     command: ‘M-x toggle-debug-on-error’ before reproducing the error.


File: company.info,  Node: Index,  Prev: Troubleshooting,  Up: Top

Index
*****

* Menu:

* Key Index::
* Variable Index::
* Function Index::
* Concept Index::


File: company.info,  Node: Key Index,  Next: Variable Index,  Up: Index

Key Index
=========

[index]
* Menu:

* C-g:                                   Usage Basics.         (line 20)
* C-g <1>:                               Commands.             (line 30)
* C-g <2>:                               Candidates Search.    (line 11)
* C-g <3>:                               Filter Candidates.    (line 14)
* C-h:                                   Commands.             (line 34)
* C-M-s:                                 Filter Candidates.    (line  6)
* C-n:                                   Usage Basics.         (line 12)
* C-n <1>:                               Commands.             (line 11)
* C-o:                                   Filter Candidates.    (line 14)
* C-p:                                   Usage Basics.         (line 12)
* C-p <1>:                               Commands.             (line 16)
* C-s:                                   Candidates Search.    (line  6)
* C-w:                                   Commands.             (line 39)
* M-<digit>:                             Quick Access a Candidate.
                                                               (line  6)
* RET:                                   Usage Basics.         (line 15)
* RET <1>:                               Commands.             (line 21)
* TAB:                                   Usage Basics.         (line 17)
* TAB <1>:                               Commands.             (line 25)


File: company.info,  Node: Variable Index,  Next: Function Index,  Prev: Key Index,  Up: Index

Variable Index
==============

[index]
* Menu:

* company-after-completion-hook:         Configuration File.  (line  94)
* company-backends:                      Backends.            (line  12)
* company-backends <1>:                  Backends Usage Basics.
                                                              (line   6)
* company-backends <2>:                  Grouped Backends.    (line   6)
* company-completion-cancelled-hook:     Configuration File.  (line  90)
* company-completion-finished-hook:      Configuration File.  (line  92)
* company-completion-started-hook:       Configuration File.  (line  88)
* company-dabbrev-downcase:              Text Completion.     (line  64)
* company-dabbrev-ignore-buffers:        Text Completion.     (line  32)
* company-dabbrev-ignore-case:           Text Completion.     (line  47)
* company-dabbrev-minimum-length:        Text Completion.     (line  13)
* company-dabbrev-other-buffers:         Text Completion.     (line  23)
* company-dot-icons-format:              Tooltip Frontends.   (line 179)
* company-echo-truncate-lines:           Echo Frontends.      (line  33)
* company-files-chop-trailing-slash:     File Name Completion.
                                                              (line  19)
* company-files-exclusions:              File Name Completion.
                                                              (line  12)
* company-format-margin-function:        Tooltip Frontends.   (line 153)
* company-frontends:                     Frontends.           (line   6)
* company-global-modes:                  Configuration File.  (line  31)
* company-icon-margin:                   Tooltip Frontends.   (line 164)
* company-icon-size:                     Tooltip Frontends.   (line 164)
* company-idle-delay:                    Configuration File.  (line  17)
* company-insertion-on-trigger:          Configuration File.  (line  64)
* company-insertion-triggers:            Configuration File.  (line  72)
* company-ispell-dictionary:             Text Completion.     (line  84)
* company-lighter-base:                  Configuration File.  (line  59)
* company-minimum-prefix-length:         Configuration File.  (line   9)
* company-mode:                          Initial Setup.       (line   6)
* company-occurrence-weight-function:    Candidates Post-Processing.
                                                              (line  21)
* company-require-match:                 Configuration File.  (line  51)
* company-search-regexp-function:        Candidates Search.   (line  13)
* company-selection-wrap-around:         Configuration File.  (line  43)
* company-show-quick-access:             Quick Access a Candidate.
                                                              (line  14)
* company-text-face-extra-attributes:    Tooltip Frontends.   (line 192)
* company-text-icons-add-background:     Tooltip Frontends.   (line 200)
* company-text-icons-format:             Tooltip Frontends.   (line 171)
* company-text-icons-mapping:            Tooltip Frontends.   (line 188)
* company-tooltip-align-annotations:     Tooltip Frontends.   (line  52)
* company-tooltip-flip-when-above:       Tooltip Frontends.   (line  99)
* company-tooltip-idle-delay:            Tooltip Frontends.   (line  22)
* company-tooltip-limit:                 Tooltip Frontends.   (line  64)
* company-tooltip-margin:                Tooltip Frontends.   (line 133)
* company-tooltip-maximum-width:         Tooltip Frontends.   (line 126)
* company-tooltip-minimum:               Tooltip Frontends.   (line  84)
* company-tooltip-minimum-width:         Tooltip Frontends.   (line 111)
* company-tooltip-offset-display:        Tooltip Frontends.   (line  74)
* company-tooltip-width-grow-only:       Tooltip Frontends.   (line 121)
* company-transformers:                  Candidates Post-Processing.
                                                              (line   6)


File: company.info,  Node: Function Index,  Next: Concept Index,  Prev: Variable Index,  Up: Index

Function Index
==============

[index]
* Menu:

* company-abbrev:                        Template Expansion.  (line   6)
* company-abort:                         Commands.            (line  30)
* company-begin-backend:                 Backends Usage Basics.
                                                              (line  23)
* company-capf:                          Code Completion.     (line   6)
* company-clang:                         Code Completion.     (line  36)
* company-complete:                      Usage Basics.        (line  10)
* company-complete-common:               Commands.            (line  25)
* company-complete-selection:            Commands.            (line  21)
* company-dabbrev:                       Text Completion.     (line   6)
* company-dabbrev-code:                  Code Completion.     (line  25)
* company-detect-icons-margin:           Tooltip Frontends.   (line 209)
* company-diag:                          Backends Usage Basics.
                                                              (line  11)
* company-diag <1>:                      Troubleshooting.     (line   6)
* company-dot-icons-margin:              Tooltip Frontends.   (line 178)
* company-echo-frontend:                 Echo Frontends.      (line  21)
* company-echo-metadata-frontend:        Echo Frontends.      (line   9)
* company-echo-strip-common-frontend:    Echo Frontends.      (line  27)
* company-etags:                         Code Completion.     (line  48)
* company-files:                         File Name Completion.
                                                              (line   6)
* company-ispell:                        Text Completion.     (line  75)
* company-keywords:                      Code Completion.     (line  31)
* company-mode:                          Initial Setup.       (line   6)
* company-other-backend:                 Backends Usage Basics.
                                                              (line  14)
* company-preview-common-frontend:       Preview Frontends.   (line  21)
* company-preview-frontend:              Preview Frontends.   (line  17)
* company-preview-if-just-one-frontend:  Preview Frontends.   (line  10)
* company-pseudo-tooltip-frontend:       Tooltip Frontends.   (line  17)
* company-pseudo-tooltip-unless-just-one-frontend: Tooltip Frontends.
                                                              (line  11)
* company-pseudo-tooltip-unless-just-one-frontend-with-delay: Tooltip Frontends.
                                                              (line  21)
* company-search-flex-regexp:            Candidates Search.   (line  26)
* company-search-words-in-any-order-regexp: Candidates Search.
                                                              (line  23)
* company-search-words-regexp:           Candidates Search.   (line  20)
* company-select-next:                   Commands.            (line  11)
* company-select-next-or-abort:          Commands.            (line  11)
* company-select-previous:               Commands.            (line  16)
* company-select-previous-or-abort:      Commands.            (line  16)
* company-semantic:                      Code Completion.     (line  41)
* company-show-doc-buffer:               Commands.            (line  34)
* company-show-location:                 Commands.            (line  39)
* company-sort-by-backend-importance:    Candidates Post-Processing.
                                                              (line  28)
* company-sort-by-occurrence:            Candidates Post-Processing.
                                                              (line  17)
* company-sort-prefer-same-case-prefix:  Candidates Post-Processing.
                                                              (line  34)
* company-tempo:                         Template Expansion.  (line  11)
* company-text-icons-margin:             Tooltip Frontends.   (line 170)
* company-tng-frontend:                  Structure.           (line  26)
* company-tng-mode:                      Structure.           (line  26)
* company-vscode-dark-icons-margin:      Tooltip Frontends.   (line 162)
* company-vscode-light-icons-margin:     Tooltip Frontends.   (line 163)
* company-yasnippet:                     Template Expansion.  (line  16)
* global-company-mode:                   Initial Setup.       (line  18)


File: company.info,  Node: Concept Index,  Prev: Function Index,  Up: Index

Concept Index
=============

[index]
* Menu:

* abbrev:                                Template Expansion.  (line   6)
* abort:                                 Usage Basics.        (line  20)
* abort <1>:                             Commands.            (line  30)
* activate:                              Initial Setup.       (line   8)
* active backend:                        Backends Usage Basics.
                                                              (line  11)
* active backend <1>:                    Troubleshooting.     (line  15)
* annotation:                            Tooltip Frontends.   (line  53)
* auto-start:                            Initial Setup.       (line  13)
* backend:                               Structure.           (line   6)
* backend <1>:                           Structure.           (line  10)
* backend <2>:                           Backends Usage Basics.
                                                              (line  11)
* backend <3>:                           Backends Usage Basics.
                                                              (line  14)
* backend <4>:                           Troubleshooting.     (line  15)
* backends:                              Backends.            (line   6)
* backends <1>:                          Backends Usage Basics.
                                                              (line   6)
* backends <2>:                          Grouped Backends.    (line   6)
* backends <3>:                          Package Backends.    (line   6)
* basics:                                Usage Basics.        (line   6)
* bug:                                   Troubleshooting.     (line   6)
* bug <1>:                               Troubleshooting.     (line  27)
* bundled backends:                      Package Backends.    (line   6)
* cancel:                                Usage Basics.        (line  20)
* cancel <1>:                            Commands.            (line  30)
* candidate:                             Terminology.         (line  10)
* candidate <1>:                         Usage Basics.        (line  12)
* candidate <2>:                         Usage Basics.        (line  15)
* candidate <3>:                         Preview Frontends.   (line   6)
* color:                                 Tooltip Frontends.   (line 219)
* color <1>:                             Quick Access a Candidate.
                                                              (line  37)
* common part:                           Usage Basics.        (line  17)
* common part <1>:                       Commands.            (line  25)
* common part <2>:                       Preview Frontends.   (line   6)
* company-echo:                          Echo Frontends.      (line   6)
* company-preview:                       Preview Frontends.   (line   6)
* company-tng:                           Structure.           (line  26)
* company-tooltip:                       Tooltip Frontends.   (line 219)
* company-tooltip-search:                Candidates Search.   (line   6)
* complete:                              Terminology.         (line   6)
* complete <1>:                          Usage Basics.        (line  12)
* complete <2>:                          Usage Basics.        (line  15)
* complete <3>:                          Usage Basics.        (line  17)
* complete <4>:                          Commands.            (line  21)
* complete <5>:                          Preview Frontends.   (line   6)
* completion:                            Terminology.         (line   6)
* completion <1>:                        Usage Basics.        (line  12)
* completion <2>:                        Usage Basics.        (line  15)
* completion <3>:                        Usage Basics.        (line  17)
* configure:                             Customization.       (line   6)
* configure <1>:                         Customization Interface.
                                                              (line   6)
* configure <2>:                         Configuration File.  (line   6)
* configure <3>:                         Tooltip Frontends.   (line  49)
* configure <4>:                         Tooltip Frontends.   (line 219)
* configure <5>:                         Preview Frontends.   (line  25)
* configure <6>:                         Echo Frontends.      (line  38)
* configure <7>:                         Candidates Search.   (line  30)
* configure <8>:                         Quick Access a Candidate.
                                                              (line  28)
* configure <9>:                         Quick Access a Candidate.
                                                              (line  37)
* custom:                                Customization.       (line   6)
* custom <1>:                            Customization Interface.
                                                              (line   6)
* custom <2>:                            Configuration File.  (line   6)
* custom <3>:                            Tooltip Frontends.   (line  49)
* custom <4>:                            Tooltip Frontends.   (line 219)
* custom <5>:                            Preview Frontends.   (line  25)
* custom <6>:                            Echo Frontends.      (line  38)
* custom <7>:                            Candidates Search.   (line  30)
* custom <8>:                            Quick Access a Candidate.
                                                              (line  28)
* custom <9>:                            Quick Access a Candidate.
                                                              (line  37)
* definition:                            Commands.            (line  39)
* distribution:                          Installation.        (line   6)
* doc:                                   Commands.            (line  34)
* duplicate:                             Candidates Post-Processing.
                                                              (line   6)
* echo:                                  Echo Frontends.      (line   6)
* enable:                                Initial Setup.       (line   8)
* error:                                 Troubleshooting.     (line   6)
* error <1>:                             Troubleshooting.     (line  27)
* expansion:                             Template Expansion.  (line   6)
* extensible:                            Structure.           (line   6)
* face:                                  Tooltip Frontends.   (line 219)
* face <1>:                              Preview Frontends.   (line   6)
* face <2>:                              Preview Frontends.   (line  25)
* face <3>:                              Echo Frontends.      (line   6)
* face <4>:                              Echo Frontends.      (line  38)
* face <5>:                              Candidates Search.   (line   6)
* face <6>:                              Candidates Search.   (line  30)
* face <7>:                              Filter Candidates.   (line   6)
* face <8>:                              Quick Access a Candidate.
                                                              (line  37)
* filter:                                Filter Candidates.   (line   6)
* finish:                                Usage Basics.        (line  20)
* finish <1>:                            Commands.            (line  30)
* font:                                  Tooltip Frontends.   (line 219)
* font <1>:                              Quick Access a Candidate.
                                                              (line  37)
* frontend:                              Structure.           (line   6)
* frontend <1>:                          Structure.           (line  10)
* frontends:                             Frontends.           (line   6)
* grouped backends:                      Grouped Backends.    (line   6)
* icon:                                  Tooltip Frontends.   (line 145)
* install:                               Installation.        (line   6)
* interface:                             Tooltip Frontends.   (line  49)
* interface <1>:                         Tooltip Frontends.   (line 219)
* interface <2>:                         Preview Frontends.   (line  25)
* interface <3>:                         Echo Frontends.      (line  38)
* interface <4>:                         Candidates Search.   (line  30)
* interface <5>:                         Quick Access a Candidate.
                                                              (line  37)
* intro:                                 Initial Setup.       (line   6)
* issue:                                 Troubleshooting.     (line   6)
* issue tracker:                         Troubleshooting.     (line  27)
* kind:                                  Tooltip Frontends.   (line 145)
* location:                              Commands.            (line  39)
* manual:                                Initial Setup.       (line   8)
* manual <1>:                            Usage Basics.        (line  10)
* margin:                                Tooltip Frontends.   (line 134)
* margin <1>:                            Tooltip Frontends.   (line 154)
* minor-mode:                            Initial Setup.       (line   6)
* module:                                Structure.           (line   6)
* module <1>:                            Structure.           (line  10)
* navigate:                              Usage Basics.        (line  12)
* next backend:                          Backends Usage Basics.
                                                              (line  14)
* non-prefix matches:                    Terminology.         (line  10)
* package:                               Installation.        (line   6)
* package backends:                      Package Backends.    (line   6)
* pluggable:                             Structure.           (line   6)
* pop-up:                                Tooltip Frontends.   (line   6)
* prefix matches:                        Terminology.         (line  10)
* preview:                               Preview Frontends.   (line   6)
* quick start:                           Initial Setup.       (line   6)
* quick-access:                          Quick Access a Candidate.
                                                              (line   6)
* quit:                                  Usage Basics.        (line  20)
* quit <1>:                              Commands.            (line  30)
* search:                                Candidates Search.   (line   6)
* select:                                Usage Basics.        (line  12)
* select <1>:                            Commands.            (line  11)
* select <2>:                            Commands.            (line  16)
* snippet:                               Template Expansion.  (line   6)
* sort:                                  Candidates Post-Processing.
                                                              (line   6)
* stop:                                  Usage Basics.        (line  20)
* stop <1>:                              Commands.            (line  30)
* TAB:                                   Structure.           (line  26)
* Tab and Go:                            Structure.           (line  26)
* template:                              Template Expansion.  (line   6)
* third-party:                           Structure.           (line  10)
* third-party <1>:                       Troubleshooting.     (line  18)
* tooltip:                               Tooltip Frontends.   (line   6)
* troubleshoot:                          Troubleshooting.     (line   6)
* usage:                                 Usage Basics.        (line   6)



Tag Table:
Node: Top572
Node: Overview2000
Node: Terminology2408
Ref: Terminology-Footnote-13395
Node: Structure3601
Node: Getting Started5097
Node: Installation5375
Node: Initial Setup5758
Node: Usage Basics6604
Node: Commands7367
Ref: Commands-Footnote-19585
Node: Customization9752
Node: Customization Interface10224
Node: Configuration File10757
Node: Frontends15423
Node: Tooltip Frontends16392
Ref: Tooltip Frontends-Footnote-126761
Node: Preview Frontends26998
Ref: Preview Frontends-Footnote-128254
Node: Echo Frontends28381
Node: Candidates Search29914
Node: Filter Candidates31248
Node: Quick Access a Candidate32028
Node: Backends33646
Node: Backends Usage Basics34744
Ref: Backends Usage Basics-Footnote-135959
Node: Grouped Backends36043
Node: Package Backends37672
Node: Code Completion38601
Node: Text Completion40970
Node: File Name Completion45404
Node: Template Expansion46952
Node: Candidates Post-Processing47671
Node: Troubleshooting49148
Node: Index50821
Node: Key Index50984
Node: Variable Index52483
Node: Function Index56533
Node: Concept Index61014

End Tag Table


Local Variables:
coding: utf-8
End: