-
Notifications
You must be signed in to change notification settings - Fork 0
/
ace-jump-helm-line-readme.txt
271 lines (206 loc) · 9.41 KB
/
ace-jump-helm-line-readme.txt
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
____________________
ACE-JUMP-HELM-LINE
Junpeng Qiu
____________________
Table of Contents
_________________
1 Setup
2 Usage
.. 2.1 Keys & UI
.. 2.2 Different Actions: move-only, persistent or select
.. 2.3 Automatic Idle Execution
.. 2.4 Line Hints Preview
3 Example settings
4 Demos(only showing the basic feature)
5 Similar Package
6 Acknowledgment
[[file:http://melpa.org/packages/ace-jump-helm-line-badge.svg]]
[[file:http://stable.melpa.org/packages/ace-jump-helm-line-badge.svg]]
*Ace-jump to a candidate in helm window.*
This package makes use of the `avy.el'.
[[file:http://melpa.org/packages/ace-jump-helm-line-badge.svg]]
http://melpa.org/#/ace-jump-helm-line
[[file:http://stable.melpa.org/packages/ace-jump-helm-line-badge.svg]]
http://stable.melpa.org/#/ace-jump-helm-line
1 Setup
=======
,----
| (add-to-list 'load-path "/path/to/ace-jump-helm-line.el")
| (require 'ace-jump-helm-line)
`----
You can use the following code to bind `ace-jump-helm-line' to a
key(say, C-'):
,----
| (eval-after-load "helm"
| '(define-key helm-map (kbd "C-'") 'ace-jump-helm-line))
`----
2 Usage
=======
When in a helm session, for example, after you call `helm-M-x', you
can use your key binding(for example, C-') to invoke
`ace-jump-helm-line'. See the following demos.
*Note*: Since *2016-02-19*, you can configure `ace-jump-helm-line' in
a similar way as `avy'. The old-fashioned variable
`ace-jump-helm-line-use-avy-style' is discarded now. There is no
effect by setting this variable(I dropped this variable because `avy'
has become much more configurable since I first developed this
package).
2.1 Keys & UI
~~~~~~~~~~~~~
You can customize following variables:
1. `ace-jump-helm-line-keys': the keys to be used for
`ace-jump-helm-line'. If you don't set this variable, `avy-keys'
will be used.
2. `ace-jump-helm-line-style': You can set the styles to be used for
`ace-jump-helm-line'. The values can be `pre', `at', `at-full',
`post', and `de-bruijn', the same as `avy-style'. If you don't set
this variable, `avy-style' will be used.
3. `ace-jump-helm-line-background': Whether you want to use a
background or not. The default value is `nil'.
For old version users: if you want to achieve the same effect of
`(setq ace-jump-helm-line-use-avy-style nil)', use the following
code:
,----
| (setq ace-jump-helm-line-keys (number-sequence ?a ?z))
| (setq ace-jump-helm-line-style 'at)
| (setq ace-jump-helm-line-background t)
`----
2.2 Different Actions: move-only, persistent or select
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can now specify the action that will be executed after the cursor
has been moved to the candidate. This is controlled by the value of
`ace-jump-helm-line-default-action'. Three different kinds of values
are available:
1. `nil' or `move-only': This is the default one. Just move the cursor
to the candidate and do nothing.
2. `persistent': After the cursor has been moved to the candidate,
execute the persistent action on that candidate.
3. `select': After the cursor has been moved to the candidate, select
the candidate and exit the helm session.
Thanks to `avy' 0.4.0, we can now switch the action after we see the
avy prompt. Three different keys can be used to switch the action:
1. `ace-jump-helm-line-move-only-key'
2. `ace-jump-helm-line-persistent-key'
3. `ace-jump-helm-line-select-key'
For example, if we have following settings:
,----
| (setq ace-jump-helm-line-default-action 'select)
| (setq ace-jump-helm-line-select-key ?e) ;; this line is not neeeded
| ;; Set the move-only and persistent keys
| (setq ace-jump-helm-line-move-only-key ?o)
| (setq ace-jump-helm-line-persistent-key ?p)
`----
Say after we invoke `ace-jump-helm-line', we can use f to jump to a
candidate. Since the default action is `select', the candidate will be
automatically selected and the helm session will be ended after the
cursor has been moved to it. But suddenly I change my mind and only
want to move to it. Instead of pressing f, I can press of where o is
defined by the `ace-jump-helm-line-move-only-key' and is used to
switch the action to `move-only'. Similarly, if I press pf, then the
persistent action on the candidate will be executed.
Note in this example, setting `ace-jump-helm-line-select-key' has no
effect because the default action is `select'. It makes no senses that
we need to have an extra key to switch to the `select' action. So if
your default action is `nil' or `move-only',
`ace-jump-helm-line-move-only-key' is not needed and
`ace-jump-helm-line-persistent-key' is not needed if your default
action is `persistent'. However, you're *safe* to set these variables
regardless of your default action since the variable corresponding to
your default action will just be ignored.
If you wonder why this feature is useful, here is an example: if you use
`helm-find-files' and set the default action to be `select', you can now
use `ace-jump-helm-line-persistent-key' to complete the directory name
instead of opening the directory in dired. This means you can use
`ace-jump-helm-line' until you finally find the target file.
For compatibility issues, there are also two identical pre-defined
commands: `ace-jump-helm-line-and-select' and
`ace-jump-helm-line-execute-action'. Their default action is to select
the candidate and exit the helm session. Now you can achieve the same
effect using `ace-jump-helm-line' by the following setting:
,----
| (setq ace-jump-helm-line-default-action 'select)
`----
2.3 Automatic Idle Execution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`ace-jump-helm-line' can be automatically executed if there is no
input after the user launches a helm command. The delay can be
specified by setting the variable `ace-jump-helm-line-idle-delay' in
seconds. The default value is 1.
Use the following code to enable this feature for a helm command, say,
`helm-mini':
,----
| (ace-jump-helm-line-idle-exec-add 'helm-mini)
`----
After adding this setting, `ace-jump-helm-line' will be automatically
triggerred if there is no input for `ace-jump-helm-line-idle-delay'
seconds after `helm-mini' is called.
To remove it, use:
,----
| (ace-jump-helm-line-idle-exec-remove 'helm-mini)
`----
Note this feature is *experimental*. Please file an issue if you find
any problems. As I couldn't find good documentation about adding hooks
to a helm command, the implementation is a simple yet dirty hack. And
don't try to set the value of `ace-jump-helm-line-idle-delay' to be
`nil'. It doesn't work.
2.4 Line Hints Preview
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can preview the line hints without invoking `ace-jump-helm-line' by
enabling `ace-jump-helm-line-autoshow-mode'. This is similar to `linum-mode'.
With `avy-style' set to `at-full', the result is shown below:
https://github.com/cute-jumper/ace-jump-helm-line/screencasts/autoshow.png
Or if you may prefer to show the hints using `linum-mode', you can set
`ace-jump-helm-line-autoshow-use-linum' to `t':
,----
| (setq ace-jump-helm-line-autoshow-use-linum t)
`----
The result:
https://github.com/cute-jumper/ace-jump-helm-line/screencasts/autoshow-linum.png
3 Example settings
==================
,----
| (eval-after-load "helm"
| '(define-key helm-map (kbd "C-'") 'ace-jump-helm-line))
| ;; or if using key-chord-mode
| ;; (eval-after-load "helm"
| ;; '(key-chord-define helm-map "jj" 'ace-jump-helm-line))
| (setq ace-jump-helm-line-style 'pre)
| (setq ace-jump-helm-line-background t)
| (setq ace-jump-helm-line-default-action 'select)
| (setq ace-jump-helm-line-select-key ?e) ;; this line is not neeeded
| ;; Set the move-only and persistent keys
| (setq ace-jump-helm-line-move-only-key ?o)
| (setq ace-jump-helm-line-persistent-key ?p)
| ;; enable idle execution for `helm-mini'
| (ace-jump-helm-line-idle-exec-add 'helm-mini)
| ;; enable hints preview
| (ace-jump-helm-line-autoshow-mode +1)
| ;; use `linum-mode' to show
| (setq ace-jump-helm-line-autoshow-mode-use-linum t)
`----
4 Demos(only showing the basic feature)
=======================================
The following demo are recorded in pre-0.4 version. It's a little
out-dated.
Use `avy' style to jump to a helm candidate:
[./screencasts/avy-jump-style.gif]
Or use a different style similar to `ace-jump-mode' (by setting the
values of `ace-jump-helm-line-keys', `ace-jump-helm-line-style' and
`ace-jump-helm-line-background'):
[./screencasts/ace-jump-mode-style.gif]
The new features after v0.4 are not recorded yet.:-(
5 Similar Package
=================
[This issue of Helm] has been solved by adding a new minor mode
`helm-linum-relative-mode' to `linum-relative'. You can take a look if
you don't like `avy' and want to find an alternative. As a heavy user
of `avy', I don't find the way that `helm-linum-relative-mode'
provides very appealing. Thanks to `avy', this package provides more
customizations and more consistent user experience for `avy' users.
[This issue of Helm] https://github.com/emacs-helm/helm/issues/1257
6 Acknowledgment
================
- Thank [Oleh Krehel] for the awesome [avy] package.
- Thank @hick for the original idea.
[Oleh Krehel] https://github.com/abo-abo/
[avy] https://github.com/abo-abo/avy