Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
marvel
GitHub Repository: marvel/qnf
Path: blob/master/elisp/auto-complete-1.3/etc/test.txt
990 views
1
-*- org -*-
2
3
* How to test
4
You can read this testcase document by following some rules.
5
6
- (Code) is a code you should evaluate for testing the fixture.
7
- (Expect) is a expected result of your test.
8
If no (Expect) is given, it means Emacs doesn't display any errors.
9
- (Assume) is a code you should evaluate before test.
10
11
If no sources you should use are not given in each fixture, we assumes that
12
you use following sources.
13
14
Code:
15
(defvar ac-source-test
16
'((candidates list "Foo" "FooBar" "Bar" "Baz" "LongLongLine")))
17
(defvar ac-source-action-test
18
'((candidates list "Action1" "Action2")
19
(action . (lambda () (message "Done!")))))
20
(setq ac-sources '(ac-source-test ac-source-action-test))
21
22
* Setup
23
24
** Load auto-complete
25
Code:
26
(require 'auto-complete)
27
(require 'auto-complete-config)
28
29
** Enable/disable auto-complete by M-x auto-complete-mode
30
31
** Use global-auto-complete-mode
32
Code:
33
(global-auto-complete-mode t)
34
35
Expect:
36
No errors. auto-complete-mode will be enabled automatically.
37
38
* Auto-completion
39
40
** Type some string at *scratch* buffer
41
Expect:
42
Menu contains words in the current buffer.
43
44
** Type some string at right of the window
45
Expect:
46
Menu will be shown in right-to-left direction without any window scrolling.
47
48
** Continue to type some string above case
49
Expect:
50
Menu will never be disrupted.
51
52
** Type some string at the right of window with truncate-lines enabled
53
Assume:
54
(setq truncate-lines t)
55
56
** Type some string at the bottom of window
57
Expect:
58
Menu will be shown in bottom-to-top direction without any window scrolling.
59
60
** Delete a character at the word
61
Expect:
62
Completion will be started.
63
64
** Type some string so that a menu overlaps the end of buffer that doesn't have newline at the end
65
Expect:
66
Menu will be shown correctly.
67
Newline at the end is not seen.
68
69
** Type some string with ac-auto-start nil
70
Assume:
71
(setq ac-auto-start nil)
72
73
Expect:
74
Completion will never be started automatically.
75
76
** Type some string with ac-auto-start t
77
Assume:
78
(setq ac-auto-start t)
79
80
Expect:
81
Completion will be started automatically if possible.
82
83
** Type 1 character with ac-auto-start 2
84
Assume:
85
(setq ac-auto-start 2)
86
87
Expect:
88
Completion will never be started automatically.
89
90
** Type 2 characters with ac-auto-start 2
91
Assume:
92
(setq ac-auto-start 2)
93
94
Expect:
95
Completion will be started automatically if possible.
96
97
** Type F
98
Expect:
99
Menu contains "Foo" and "FooBar" as candidates.
100
Inline completion appears and it contains "oo" as common-part.
101
102
** Type TAB while completion with ac-dwim disabled
103
Assume:
104
(setq ac-dwim nil)
105
106
Expect:
107
(a) If there is common-part of candidates, auto-complete expands it.
108
(b) If the prefix equals to the first of candidates, auto-complete selects next candidate.
109
(c) Othewise, auto-complete expands selected candidate.
110
111
** Type TAB while completion with ac-dwim enabled
112
Assume:
113
(setq ac-dwim t)
114
115
Expect:
116
(a) If there is common-part of candidates, auto-complete expands it.
117
(b) If only one candidate remains, or if it is done after selecting be ac-previous/ac-next,
118
auto-complete simulates ac-complete.
119
- If its candidate has an action, the action will be invoked. ("Action1" and "Action2" have an action)
120
- Expand its candidate.
121
(c) If the prefix equals to the first of candidates, auto-complete selects next candidate.
122
(d) Othewise, auto-complete expands selected candidate.
123
124
** Type RET while completion
125
Expect:
126
Completion will be done for selected candidate.
127
If its candidate has an action, the action will be invoked.
128
Use "Action" for the prefix for test.
129
130
* Configuration
131
132
** Change menu height
133
Code:
134
(setq ac-menu-height 20)
135
136
Expect:
137
Up to 20 candidates will be shown in a menu.
138
139
** Use trigger key facility
140
Code:
141
(ac-set-trigger-key "TAB")
142
143
Expect:
144
Now you can use TAB for auto-completion.
145
It is enabled only when
146
(a) After insertion/deletion command
147
(b) With prefix (C-u TAB)
148
Otherwise, it behaves as default.
149
Generally, it is used with ac-auto-start disabled.
150
151
** Use ac-mode-map
152
Code:
153
(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
154
155
Expect:
156
Now you can start auto-complete with typing M-TAB anywhere.
157
158
** Change default ac-sources
159
Code:
160
(setq-default ac-sources '(ac-source-words-in-all-buffer))
161
162
Expect:
163
Now default ac-sources has been changed for newly opened buffers.
164
165
* Builtin sources
166
167
** ac-source-words-in-buffer
168
Expect:
169
Candidates will be words in the current buffer.
170
171
** ac-source-words-in-all-buffer
172
Expect:
173
Candidates will be words in all buffer.
174
175
** ac-source-words-in-same-mode-buffers
176
Expect:
177
Candidates will be words for buffers which major-mode same to
178
the current buffer's one.
179
180
** ac-source-symbols
181
Expect:
182
Candidates will be all Emacs Lisp symbols.
183
184
** ac-source-abbrev
185
Expect:
186
Candidates will be abbreviations of local-abbrev-table and global-abbrev-table.
187
188
** ac-source-files-in-current-dir
189
Expect:
190
Candidates will be files contained by the current directory (default-directory).
191
192
** ac-source-filename
193
Expect:
194
Candidates will be absolute/relative file name.
195
This source will be executed when the prefix seems to be file name.
196
That is, the prefix contains slash (/) and a string between first to
197
last flash is a valid directory.
198
When ac-complete, this continues to complete if the prefix is a valid directory.
199
200
** ac-source-imenu
201
Expect:
202
Candidates will be a node of imenu tree.
203
204