summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorThe Flying Rapist <admin@nosuck.org>2015-10-24 03:28:37 -0400
committernfnty <git@nfnty.se>2017-02-01 00:30:38 +0100
commit9ce8839a6363d43f2d6f9ce74feb2c21ee4fed41 (patch)
tree87db4e84923b0115fa249dd3eafd475b079edd11
parentcc8f5270fdb52714c4606ac62eea0de9c6aac04a (diff)
downloadranger-9ce8839a6363d43f2d6f9ce74feb2c21ee4fed41.tar.gz
Add command for jumping to first non-directory/non-file
Fixes #409
-rw-r--r--doc/ranger.111
-rw-r--r--doc/ranger.pod9
-rw-r--r--doc/rifle.12
-rwxr-xr-xranger/config/commands.py44
-rw-r--r--ranger/config/rc.conf1
5 files changed, 65 insertions, 2 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 16c7256e..454ed9df 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.8.1" "2017-01-29" "ranger manual"
+.TH RANGER 1 "ranger-1.8.1" "2017-02-01" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -910,6 +910,7 @@ ranger.  For your convenience, this is a list of the \*(L"public\*(R" commands i
 \& flat level
 \& grep pattern
 \& help
+\& jump_non [\-r] [\-w]
 \& linemode linemodename
 \& load_copy_buffer
 \& map key command
@@ -1075,6 +1076,14 @@ Looks for a string in all marked files or directories.
 .IP "help" 2
 .IX Item "help"
 Provides a quick way to view ranger documentations.
+.IP "jump_non [\fI\-r\fR] [\fI\-w\fR]" 2
+.IX Item "jump_non [-r] [-w]"
+Jumps to first non-directory if highlighted file is a directory and vice versa.
+.Sp
+.Vb 2
+\& \-r    Jump in reverse order
+\& \-w    Wrap around if reaching end of filelist
+.Ve
 .IP "linemode \fIlinemodename\fR" 2
 .IX Item "linemode linemodename"
 Sets the linemode of all files in the current directory.  The linemode may be:
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 0a6bc2c4..a61ae657 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -928,6 +928,7 @@ ranger.  For your convenience, this is a list of the "public" commands including
  flat level
  grep pattern
  help
+ jump_non [-r] [-w]
  linemode linemodename
  load_copy_buffer
  map key command
@@ -1118,6 +1119,14 @@ Looks for a string in all marked files or directories.
 
 Provides a quick way to view ranger documentations.
 
+=item jump_non [I<-r>] [I<-w>]
+
+Jumps to first non-directory if highlighted file is a directory and vice versa.
+
+ -r    Jump in reverse order
+ -w    Wrap around if reaching end of filelist
+
+
 =item linemode I<linemodename>
 
 Sets the linemode of all files in the current directory.  The linemode may be:
diff --git a/doc/rifle.1 b/doc/rifle.1
index cc062f02..14b03794 100644
--- a/doc/rifle.1
+++ b/doc/rifle.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RIFLE 1"
-.TH RIFLE 1 "rifle-1.8.1" "2017-01-29" "rifle manual"
+.TH RIFLE 1 "rifle-1.8.1" "2017-02-01" "rifle manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index b200f500..a250f8a9 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -572,6 +572,50 @@ class delete(Command):
             self.fm.delete(files)
 
 
+class jump_non(Command):
+    """:jump_non [-r] [-w]
+
+    Jumps to first non-directory if highlighted file is a directory and vice versa.
+
+    Options:
+        `-r` Jump in reverse order
+        `-w` Wrap around if reaching end of filelist
+    """
+    @staticmethod
+    def _non(fobj, is_directory):
+        return fobj.is_directory if not is_directory else not fobj.is_directory
+
+    def execute(self):
+        reverse = False
+        wrap = False
+        for arg in self.args:
+            if arg == '-r':
+                reverse = True
+            elif arg == '-w':
+                wrap = True
+
+        tfile = self.fm.thisfile
+        passed = False
+        found_before = None
+        found_after = None
+        for fobj in self.fm.thisdir.files[::-1] if reverse else self.fm.thisdir.files:
+            if fobj.path == tfile.path:
+                passed = True
+                continue
+
+            if passed:
+                if self._non(fobj, tfile.is_directory):
+                    found_after = fobj.path
+                    break
+            elif not found_before and self._non(fobj, tfile.is_directory):
+                found_before = fobj.path
+
+        if found_after:
+            self.fm.select_file(found_after)
+        elif wrap and found_before:
+            self.fm.select_file(found_before)
+
+
 class mark_tag(Command):
     """:mark_tag [<tags>]
 
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 5de0b18f..e3cff565 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -336,6 +336,7 @@ map L     history_go 1
 map ]     move_parent 1
 map [     move_parent -1
 map }     traverse
+map )     jump_non
 
 map gh cd ~
 map ge cd /etc
/pre>
ec926027 ^
b0bf5321 ^
1228ec73 ^
363be37f ^
b24eb476 ^
363be37f ^
69e14325 ^
95b2a140 ^
1228ec73 ^

7da71d03 ^
0edf822f ^
ec99eb7a ^
07b54625 ^
7da71d03 ^
9fc64bbc ^
d8509b41 ^
b75e94b3 ^


07b54625 ^
9fc64bbc ^

b3899909 ^
49620728 ^
a7d70735 ^
6c96a437 ^
9f95c745 ^
795f5244 ^
1b76245c ^
795f5244 ^
35064671 ^
dc269891 ^
fca0ebbe ^
e74a2940 ^
6c96a437 ^
e74a2940 ^
0487a30e ^
dc269891 ^
fca0ebbe ^
59874868 ^





dcfca05e ^
f1a6f323 ^
d241c9c4 ^
827898fc ^
d241c9c4 ^

f1a6f323 ^
d241c9c4 ^
dcfca05e ^
d241c9c4 ^
9cf71627 ^
f404eb55 ^
59874868 ^









0487a30e ^
3eb81335 ^
59874868 ^

9fc64bbc ^
9d670bb5 ^
9fc64bbc ^
f404eb55 ^

9fc64bbc ^
6a7ff61c ^
49620728 ^
ccba6718 ^




e74a2940 ^




3c435756 ^
49620728 ^
2199940a ^
49620728 ^
d41955c1 ^
8eff7919 ^
ec926027 ^

49620728 ^
b2f699e1 ^




d41955c1 ^
795f5244 ^
ec926027 ^

49620728 ^
58a08ed3 ^



49620728 ^
d41955c1 ^
795f5244 ^
dcfca05e ^

49620728 ^
d41955c1 ^
795f5244 ^
ec926027 ^

49620728 ^
d41955c1 ^
95b2a140 ^


e5e9f7db ^



9a81d746 ^
f28f2636 ^
785a60fa ^
2429c65c ^
8aa4b664 ^

e5e9f7db ^

b39ceb27 ^
2186422c ^
db50f43a ^
07c594eb ^
e7f76736 ^
cea49fde ^
7fd01071 ^

cea49fde ^
6d6c37fe ^
cea49fde ^
6d6c37fe ^

2429c65c ^
60e11efc ^

e7f76736 ^
ae5f0b6f ^
b39ceb27 ^
2429c65c ^
df0f36fb ^
14d6f9f3 ^
6dd67576 ^

4cec4143 ^
2429c65c ^
e7f76736 ^
e5e9f7db ^

b39ceb27 ^
ae5f0b6f ^
0d3f30c2 ^
6573fe1f ^
6f69d5d9 ^




7858a06a ^
cea49fde ^
cea49fde ^
cea49fde ^

ae5f0b6f ^
e7f76736 ^
e7f76736 ^

026efa57 ^


838b1afc ^
026efa57 ^

838b1afc ^
026efa57 ^

267ebb59 ^
f78f92c5 ^
f28f2636 ^
e777ce0c ^
215cf3c2 ^
f78f92c5 ^


2c0583aa ^
f78f92c5 ^




2429c65c ^
9f78ec2d ^
2429c65c ^
9f78ec2d ^

267ebb59 ^
f5f4b698 ^
5ea70e95 ^
f5f4b698 ^

b2ec0969 ^
8c9e97ae ^
267ebb59 ^


9f78ec2d ^





2429c65c ^
9f78ec2d ^

6c96a437 ^
9f78ec2d ^
55fc43b7 ^
2429c65c ^
9f78ec2d ^





385ff136 ^

9f78ec2d ^
7284d503 ^

e5e9f7db ^
3473c63a ^
43b866d1 ^
fca0ebbe ^
ab6ed192 ^
a4ef18b1 ^
a26cc359 ^

43b866d1 ^
b24eb476 ^
6c96a437 ^
6700f9f2 ^

b291f85b ^

cae5461b ^


1cd2691b ^

43b866d1 ^
0c0bc3ae ^
9dcbec39 ^
0c0bc3ae ^

6b6dfb0c ^
18429d40 ^
43b866d1 ^
4588af97 ^
2b250717 ^
4588af97 ^

70179d1f ^
2b250717 ^
35064671 ^
70179d1f ^
43b866d1 ^
6c96a437 ^
6700f9f2 ^


b291f85b ^
cae5461b ^

c1a50c82 ^
b24eb476 ^
3c163ef7 ^
1211a3ab ^
c6034af3 ^
3076bab4 ^
b24eb476 ^
3c163ef7 ^
f4647409 ^





4ecab182 ^



b771d375 ^
f4647409 ^

1211a3ab ^
f48f6c14 ^
eaa75c87 ^
decaddb4 ^
70179d1f ^
3c163ef7 ^
1211a3ab ^
6c1376f8 ^
70179d1f ^


d41955c1 ^
af023b32 ^





a0fc38c9 ^

d41955c1 ^
78164bab ^

d41955c1 ^
78164bab ^


e5e9f7db ^
19695cc7 ^
e5e9f7db ^


4cec4143 ^
390f4097 ^





e5e9f7db ^

decaddb4 ^
1ead3562 ^
decaddb4 ^
192d59d3 ^

decaddb4 ^
acc4792d ^

d7494165 ^
fc55fea0 ^

1ead3562 ^
bc643692 ^
fc55fea0 ^
acc4792d ^
18429d40 ^
bc643692 ^
5f98a10c ^
1ead3562 ^
192d59d3 ^
18429d40 ^
bc643692 ^
6d2b1168 ^
9a81d746 ^
677fa104 ^


1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
192d59d3 ^
677fa104 ^
578327f1 ^
b2f699e1 ^










7d07cd1d ^
b2f699e1 ^






























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