forked from excalamus/rg.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrgel.info
2507 lines (1951 loc) · 98.8 KB
/
rgel.info
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
This is rgel.info, produced by makeinfo version 6.8 from rgel.texi.
rg.el 2.3.0, Apr 03, 2023
David Landell
Copyright © 2019, David Landell
INFO-DIR-SECTION Emacs
START-INFO-DIR-ENTRY
* RG: (rgel.info). Search like a King with ripgrep in Emacs.
END-INFO-DIR-ENTRY
Generated by Sphinx 4.3.2.
File: rgel.info, Node: Top, Next: Usage, Up: (dir)
RG User Manual
**************
rg.el 2.3.0, Apr 03, 2023
David Landell
Copyright © 2019, David Landell
`rg.el' is an Emacs search package based on the ripgrep
(https://github.com/BurntSushi/ripgrep) command line tool. It allows
you to interactively create searches, doing automatic searches based on
the editing context, refining and modifying search results and much
more. It is also highly configurable to be able to fit different users’
needs.
Throughout this manual this emacs package will be referred to as `rg'
while the command line utility will be referred to as `ripgrep'.
If you are used to built-in Emacs ‘rgrep’ command, transitioning to `rg'
should be simple. `rg' provides a lot of extra features but the basics
are similar.
The big benefit of using `ripgrep' instead of `grep' as a backend is
speed. Especially when searching large source code repositories where
`ripgrep' really shines. Please read this blog post
(http://blog.burntsushi.net/ripgrep/) for some speed comparisons with
other tools.
* Menu:
* Usage::
* Configuration::
* Contribute::
* License::
* Index::
File: rgel.info, Node: Usage, Next: Configuration, Prev: Top, Up: Top
1 Usage
*******
* Menu:
* Installation::
* Searching::
* Results buffer::
* Search management::
* Multi line search::
File: rgel.info, Node: Installation, Next: Searching, Up: Usage
1.1 Installation
================
This version of `rg' is supported on GNU Emacs 26.1 or later on Linux
systems. It might work on older Emacsen and on other systems but such
configurations are not tested. Patches for other OS:es are welcome.
MELPA
.....
Packages are published on MELPA Stable (https://stable.melpa.org/#/rg)
and MELPA (http://melpa.org/#/rg). From within Emacs, run ‘M-x
package-install [RET] rg [RET]’ to install from those sources.
Enable default key bindings:
(rg-enable-default-bindings)
The above will enable the default key map ‘rg-menu’ under the default
prefix key ‘C-c s’.
Manual
......
Releases can alternatively be downloaded from GitHub
(https://github.com/dajva/rg.el/releases/latest) and installed manually.
Put all elisp files in main directory in your load path and ‘require’
the package in your init file.
(require 'rg)
(rg-enable-default-bindings)
You would also need to make sure all package requirements are met. For
this version these are:
- `wgrep' 2.1.10
- `transient' 0.3.0
- `emacs' 26.1
`rg' is using autoloaded symbols which means it’s also possible to defer
loading if you have autoloading setup. That usually comes out of the
box with ‘package-install’.
Lazy loading
............
For lazy loading you don’t want to call directly into the package during
startup. Use a setup similar to this instead:
(global-set-key (kbd "C-c s") #'rg-menu)
(with-eval-after-load 'rg
;; Your settings goes here.
)
If you don’t want to use the transient menu interface, the following is
needed to achieve lazy loading:
;; Workaround for emacs' lack of autoloaded keymaps.
;; This is essentially what use-package do.
(defun rg-autoload-keymap ()
(interactive)
(if (not (require 'rg nil t))
(user-error (format "Cannot load rg"))
(let ((key-vec (this-command-keys-vector)))
(global-set-key key-vec rg-global-map)
(setq unread-command-events
(mapcar (lambda (ev) (cons t ev))
(listify-key-sequence key-vec))))))
(global-set-key (kbd "C-c s") #'rg-autoload-keymap)
(with-eval-after-load 'rg
;; Your settings goes here.
)
wgrep
.....
This package use wgrep (https://github.com/mhayashi1120/Emacs-wgrep) for
editing capabilities in the rg results buffer. No setup is needed.
Isearch integration
...................
Optional *note isearch integration: 6. can be enabled to allow you to
extend isearch to trigger ripgrep searching. Enable it in your
configuration with:
(require 'rg-isearch)
(define-key isearch-mode-map "\M-sr" 'rg-isearch-menu)
For the evil use case where isearch-mode is exited after first search
hit, users would also want to add the binding to the ‘global-map’ or
similar.
Interaction with the `ripgrep' configuration file
.................................................
The `ripgrep' binary allows using a configuration file
(https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file)
to set default values for command line flags. This package requires
specific command line flags to function correctly and using a `ripgrep'
configuration may conflict with these requirements. Therefore the
configuration file is ignored by default. This can be changed by the
*note rg-ignore-ripgreprc: 7. setting.
Note: Using the `ripgrep' configuration file may break
functionality of this package if you are not careful.
File: rgel.info, Node: Searching, Next: Results buffer, Prev: Installation, Up: Usage
1.2 Searching
=============
Searching is done by invoking one of the different frontend commands.
This package is built around recursive search based on three parameters;
a single `directory', `file type' filter, and a search `pattern'. These
three parameters can interactively be selected or figured out
automatically by the package, depending on which command that is used.
The underlying `ripgrep' binary has the file type filter concept built
in. You have a high level of control over which files to search and
which to ignore. This is partly what makes it so fast, ignoring
uninteresting files.
In addition to the base parameters there are a lot of options that
control how a search is done. These are typically selected from the
*note rg-menu: a. interface.
* Menu:
* Case sensitivity::
* Interactive search::
* Project search::
* Do what I mean::
* Isearch search::
* File type aliases::
* The menu::
File: rgel.info, Node: Case sensitivity, Next: Interactive search, Up: Searching
1.2.1 Case sensitivity
----------------------
Considering case when searching is an important feature of any search
tool. This package gives you a lot of control over how to handle case
sensitive and case insensitive search. It can be forced to `on' or
`off' and set to `smart case'. The latter is similar to the `ripgrep'
‘--smart-case’ flag but is not using the flag directly. One thing to
note about this is that the case insensitive setting controls the
behavior when starting a new search. In the results buffer the setting
is fixed to `on' or `off' but can be toggled easily with a key binding.
See *note rg-ignore-case: c. customization for the details of the
configuration.
File: rgel.info, Node: Interactive search, Next: Project search, Prev: Case sensitivity, Up: Searching
1.2.2 Interactive search
------------------------
Two commands implements fully interactive search, where all the base
parameters are selected from the mini buffer.
-- ELisp Command: C-c s r (rg)
This command prompts for `query', `file type' and `directory' and
tries to suggest reasonable default values. The `query' string is
interpreted as a regular expression. Default for `query' is the
thing at point and for `directory' it is the current directory. If
the type of the currently visited file is recognized, the
corresponding *note file type alias: 10. is suggested as the `file
type' parameter.
Invoking this command with the `universal argument' will trigger
confirmation and potential modification of the *note full command
line: 11. that will invoke the `ripgrep' binary.
-- ELisp Command: C-c s t (rg-literal)
This command works in the same way as *note rg: f. but interprets
the `query' string literally and not as a regular expression.
Invoking this command with the `universal argument' will trigger
confirmation and potential modification of the *note full command
line: 11. that will invoke the `ripgrep' binary.
File: rgel.info, Node: Project search, Next: Do what I mean, Prev: Interactive search, Up: Searching
1.2.3 Project search
--------------------
A common scenario is to search through a whole project while visiting a
file in the project. This essentially means identifying the project
root and use that as the top `directory' when invoking the `ripgrep'
binary. `rg' supports several ways of identifying a project. Emacs’
major project packages are supported including projectile
(https://www.projectile.mx/en/latest/), find-file-in-project
(https://github.com/technomancy/find-file-in-project) and builtin
project.el
(https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/project.el).
If none of these are used, the fallback is Emacs’ ‘vc-backend’.
-- ELisp Command: C-c s p (rg-project)
Search in the current project. The `directory' is selected via one
of Emacs’ project packages while `query string' and `file type' are
prompted for. The `query string' is interpreted as a regular
expression.
File: rgel.info, Node: Do what I mean, Next: Isearch search, Prev: Project search, Up: Searching
1.2.4 Do what I mean
--------------------
The `DWIM' family of search commands tries to be smart by figure out the
search parameters from the context without prompting. Thanks to
`ripgrep’s' speed, this allows for new ways of searching by invoking a
dwim command and then `refine' the search from the results buffer.
These commands use the word (with the definition of word depending on
context) under cursor as the `query' string. The `file type' parameter
is taken from the type of the currently visited file. If the current
file type can not be identified all file types known to `ripgrep' are
used. The fallback can be customized with *note
rg-default-alias-fallback: 18. The `directory' parameter varies between
these commands.
-- ELisp Command: M-x rg-dwim-project-dir
Do a `DWIM' search in the current *note project: 14.
-- ELisp Command: M-x rg-dwim-current-dir
Do a `DWIM' search in the current directory.
-- ELisp Command: M-x rg-dwim-current-file
Do a `DWIM' search in the current file. The `current file' in this
context is actually a file `pattern' exactly matching the current
file name in a search starting from current directory. Most of the
time this means a single file but if there are multiple files with
the same name in a sub directory, those will be searched as well.
-- ELisp Command: C-c s d (rg-dwim)
This command combines all the `DWIM' commands to one. The default
search is in the *note project dir: 19. With one `universal
argument' *note current directory: 1a. is used and with double
`universal arguments' a *note file search: 1b. is done.
File: rgel.info, Node: Isearch search, Next: File type aliases, Prev: Do what I mean, Up: Searching
1.2.5 Isearch search
--------------------
Isearch integration is optional and need to be enabled explicitly in
your emacs configuration. See *note installation: 5. for more info.
This functionality is similar to emacs built in occur package but offers
some additional choices for the search and provides the full
functionality of the rg search result buffer. When enabled, the choosen
binding can be used from isearch to trigger a menu for extending the
isearch to do a ripgrep search in current file, current directory or
current project.
File: rgel.info, Node: File type aliases, Next: The menu, Prev: Isearch search, Up: Searching
1.2.6 File type aliases
-----------------------
File type aliases are used in `ripgrep' to filter out the files to
search in. The `ripgrep' binary comes with a default set of aliases
that can be extended or overridden from this package by customizing
*note rg-custom-type-aliases: 1f.
An alias is a mapping between a name and a list of glob patterns
(https://en.wikipedia.org/wiki/Glob_%2528programming%2529) matching the
files of interest. Selecting an alias when searching is done with
completing read of the defined aliases. It is also possible to enter a
custom glob pattern if there is no suitable alias defined for the file
type.
`rg' defines some internal aliases:
Name Meaning
--------------------------------------------------------------------------------------------------------------
`all' all defined types including *note rg-custom-type-aliases: 1f.
`everything' all files. No filtering on type is done.
`custom' used internally in this package for mapping custom glob patterns.
Warning: Do not use any of the internal aliases in *note
rg-custom-type-aliases: 1f. That would interfere with the package
internal usage.
File: rgel.info, Node: The menu, Prev: File type aliases, Up: Searching
1.2.7 The menu
--------------
The global *note prefix key: 21. may be bound to a transient prefix
command, which means that the key binding will popup a menu. This
package is using the same popup menu backend called transient
(https://magit.vc/manual/transient) as the magit
(https://magit.vc/manual/magit) package. If you are familiar with magit
this should feels like home.
The menu is mostly interesting when you want to give specific command
line flags to the `ripgrep' binary. When you just want to do a quick
search based on the defaults the menu basically acts as a normal keymap.
Pressing the ‘rg-menu’ *note prefix key: 21. will popup the menu where
command line flags can be selected before triggering the wanted search
function. The menu can be customized via the transient API as usual.
This package contains some shortcuts to directly add a new command to
the menu when defining the command via the *note rg-define-search: 22.
macro.
(rg-define-search rg-word
:format literal
:flags ("--word-regexp")
:menu ("Custom" "w" "Word"))
The ‘:menu’ keyword in the above invocation will trigger insertion of a
new menu item bound to key ‘w’ with description `Word'. The new menu
item will be put under the `Custom' group. This group is not available
in the original menu so it will be created.
The menu can be triggered from the *note results buffer: 23. with the
‘m’ key. The commands in the menu differs, depending on from where it’s
triggered but the available options are the same. The menu does not
show all options by default.
The visible options can be controlled by the transient suffix levels
documented here
(https://magit.vc/manual/transient/Enabling-and-Disabling-Suffixes.html#Enabling-and-Disabling-Suffixes).
To modify what is enabled at the default level 4 press ‘C-x l’ to enter
edit mode when the menu is visible. Then select the option by pressing
the key sequence that activates the option and choose the level 4 for
that option. It’s also possible to use the transient edit mode for
modifying the overall level of the menu to enable more options at once.
File: rgel.info, Node: Results buffer, Next: Search management, Prev: Searching, Up: Usage
1.3 Results buffer
==================
The results of a search is shown in the results buffer. This buffer
displays search parameters, the full command line and the output of the
`ripgrep' binary. It supports basic navigation between search results
editing of the file contents directly from the search buffer and also
modification of the current search. The results buffer is a modified
`compilation' buffer and some key bindings and functionality is
inherited from the parent and from `grep mode'.
* Menu:
* Navigation::
* Refine search::
* Full command line search::
* History navigation::
* Edit and apply (wgrep): Edit and apply wgrep.
File: rgel.info, Node: Navigation, Next: Refine search, Up: Results buffer
1.3.1 Navigation
----------------
Navigation works mostly as in grep/compilation buffers.
-- ELisp Command: M-n (compilation-next-error)
Move to next line with a match.
-- ELisp Command: M-p (compilation-previous-error)
Move to previous line with a match.
-- ELisp Command: n (next-error-no-select)
Move to next line with a match, show that file in other buffer and
highlight the match.
-- ELisp Command: p (previous-error-no-select)
Move to previous line with a match, show that file in other buffer
and highlight the match.
-- ELisp Command: M-N (rg-next-file)
Move to next file header if the results is grouped under a file
header (See *note rg-group-result: 2b.).
-- ELisp Command: M-P (rg-prev-file)
Move to previous file header if the results is grouped under a file
header (See *note rg-group-result: 2b.).
-- ELisp Command: } (compilation-next-file)
Move first match in previous file.
-- ELisp Command: { (compilation-previous-file)
Move last match in previous file.
-- ELisp Command: RET (compile-goto-error)
Visit match in file.
If *note rg-group-result: 2b. is enabled, the Imenu
(https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html)
facility is configured to jump across files.
File: rgel.info, Node: Refine search, Next: Full command line search, Prev: Navigation, Up: Results buffer
1.3.2 Refine search
-------------------
From the results buffer it’s easy to change the search parameters. Some
bindings toggle a flag while others allow you to interactively change
the *note base parameters: 9.
-- ELisp Command: d (rg-rerun-change-dir)
Interactively change search `directory'.
-- ELisp Command: f (rg-rerun-change-files)
Interactively change searched `file types'.
-- ELisp Command: t (rg-rerun-change-literal)
Interactively change `search string' interpret the string
literally.
-- ELisp Command: r (rg-rerun-change-regexp)
Interactively change `search string' interpret the string as a
regular expression.
Tip: *note rg-rerun-change-regexp: 34. and *note
rg-rerun-change-literal: 33. are used for switching between regular
expression and literal search. So for quick switching between
search modes with the same search string, just press the respective
key and then ‘RET’.
-- ELisp Command: g (rg-recompile)
Rerun the current search without changing any parameters.
-- ELisp Command: c (rg-rerun-toggle-case)
Toggle case sensitivity of search. The state of the flag is shown
in the `[case]' header field.
-- ELisp Command: i (rg-rerun-toggle-ignore)
Toggle if ignore files are respected. The state of the flag is
shown in the `[ign]' header field.
Tip: It is possible to create and bind your own toggle flags with
the macro *note rg-define-toggle: 38.
-- ELisp Command: m (rg-menu)
Fire up *note the menu: a. for full access to options and flags.
File: rgel.info, Node: Full command line search, Next: History navigation, Prev: Refine search, Up: Results buffer
1.3.3 Full command line search
------------------------------
Some search commands (See *note rg: f. or *note rg-literal: 12.) allow
you to edit the final command line before invoking the search by giving
a `universal argument'. This can be used to invoke features of the
`ripgrep' binary that is not supported in this package’s interface.
This could be specific flags, searching in multiple directories etc.
Note: Using full command line search will disable refinement of the
search from the result buffer.
File: rgel.info, Node: History navigation, Next: Edit and apply wgrep, Prev: Full command line search, Up: Results buffer
1.3.4 History navigation
------------------------
Each search result is stored in the search history, which is a per
results buffer property. History can be navigated back and forward, the
forward history is cleared when a new search is done.
-- ELisp Command: C-c < (rg-back-history)
Navigate back in history.
-- ELisp Command: C-c > (rg-forward-history)
Navigate forward in history.
Tip: The key bindings here are slightly inconvenient so invoking
this via *note the menu: a. by pressing ‘m b’ and ‘m w’ is more
ergonomic.
File: rgel.info, Node: Edit and apply wgrep, Prev: History navigation, Up: Results buffer
1.3.5 Edit and apply (wgrep)
----------------------------
The results buffer supports inline editing via the wgrep
(https://github.com/mhayashi1120/Emacs-wgrep) package. This is setup
automatically when `rg' is loaded.
-- ELisp Command: e (wgrep-change-to-wgrep-mode)
Make the search results editable by enabling ‘wgrep’ mode. When
done press ‘C-c C-c’ to commit your changes to the underlying files
or ‘C-c C-k’ to drop the changes.
File: rgel.info, Node: Search management, Next: Multi line search, Prev: Results buffer, Up: Usage
1.4 Search management
=====================
The result buffer is named ‘*rg*’ and `rg' reuse the same result buffer
for new searches. If you want to store a search while continuing doing
new searches there are two ways of doing that.
-- ELisp Command: s (rg-save-search)
Save the search buffer by renaming it to a unique new name. This
is available both outside and inside a result buffer. Outside of
the result buffer it’s bound to ‘C-c s s’.
If you want to keep all search buffers until manually killed you
can use this snippet in your init file.
(defadvice rg-run (before rg-run-before activate)
(rg-save-search))
-- ELisp Command: S (rg-save-search-as-name)
Save the search buffer and interactively give it a specific name.
This is available both outside and inside a result buffer. Outside
of the result buffer it’s bound to ‘C-c s S’.
The default buffer name can be customized with *note rg-buffer-name: 46.
This setting considers dir local variables and it’s even possible to use
a function to get a really dynamic setup.
Having a lot of search buffers floating around can easily get messy. To
help keeping this under control there is a search manager. The manager
is simply a modified ‘ibuffer’ that lists all the results buffers, shows
some data about the searches and make it possible to kill of some unused
etc.
-- ELisp Command: L (rg-list-searches)
Open the search manager. This is available both in result buffer
and globally bound to ‘C-c s l’.
-- ELisp Command: C-c s k (rg-kill-saved-searches)
Kill all saved searches except for the one that matches *note
rg-buffer-name: 46. This is available both in result buffer and
globally bound to ‘C-c s k’.
Warning: If you have a dynamic *note rg-buffer-name: 46. setup,
only one buffer that matches your current criteria (dir locals or
project for instance) will be kept. So be careful when killing
saved searches to avoid losing important search results.
File: rgel.info, Node: Multi line search, Prev: Search management, Up: Usage
1.5 Multi line search
=====================
By default, ripgrep does matching per line. The ‘--multiline’ flag can
be used for enabling matching over multiple lines. This flag is
available in the *note rg-menu: a. as an option. The ‘--multiline’ flag
does not match new line characters with the ‘.’ as one might expect
though. A separate flag is used to allow this, ‘--multiline-dotall’.
The casual user of multi line search commonly want this flag on by
default so it’s recommended to add this to *note rg-command-line-flags:
4b. to avoid having to trigger this flag manually from the menu.
See the ripgrep manual page for more info about the multi line flags.
File: rgel.info, Node: Configuration, Next: Contribute, Prev: Usage, Up: Top
2 Configuration
***************
* Menu:
* Customization::
* Faces::
* Configuration functions::
* Hooks::
* Configuration macros::
* Use with evil-mode::
* Customizing the menu::
File: rgel.info, Node: Customization, Next: Faces, Up: Configuration
2.1 Customization
=================
Customization is done via the Emacs customization system. The group
‘rg’ is the main group of the package.
M-x customize-group [RET] rg [RET]
-- ELisp Variable: rg-executable [(executable-find "rg")]
The `ripgrep' executable to use. Could be an absolute path or just
the base name if the executable is in the path. The default is
using ‘executable-find’ to locate the command. If you want to use
this package with tramp it might be better to set it to just “rg”
in order to let the OS find the binary where it’s invoked. From
Emacs 27.1, the tramp use case is by default handled automatically.
See *note rg-executable-per-connection: 51. for details.
-- ELisp Variable: rg-executable-per-connection [t]
This setting only has effect in Emacs 27.1 or later. Handle the
*note rg-executable: 50. automatically for different hosts if used
with tramp. ‘executable-find’ for “rg” binary will be invoked on
remote hosts to determine the path to ripgrep. The result is
stored per connection.
-- ELisp Variable: rg-custom-type-aliases [nil]
An association list that maps file type aliases to a space
delimited string with file globs. These are combined with the
`ripgrep' builtin file aliases.
Example:
(setq rg-custom-type-aliases
'(("foo" . "*.foo *.bar")
("baz" . "*.baz *.qux")))
You may also add lambdas to ‘rg-custom-type-aliases’ to add aliases
dynamically based on mode, directory, project, etc.
(add-to-list
'rg-custom-type-aliases
(lambda ()
(when (in-frontend-app)
(cons "ui" "*.js *.hbs *.json"))))
-- ELisp Variable: rg-prioritized-type-aliases [nil]
A list of aliases that are prioritized among ripgrep’s builtin
aliases when selecting the alias based on the buffer file name.
This list contains only the alias names and the order between the
items does not matter.
Example:
(setq rg-custom-type-aliases
'("cpp" "puppet"))
-- ELisp Variable: rg-default-alias-fallback ["everything"]
This setting controls the default alias used when no alias can be
recognized for the current buffer. ‘all’ or ‘everything’ are
reasonable values for this variable.
-- ELisp Variable: rg-command-line-flags [nil]
A list of command line flags that will be appended to the `ripgrep'
command line. Must either be a list of flags or a function that
returns a list of flags.
-- ELisp Variable: rg-group-result [t]
Controls the layout of the results buffer. If non ‘nil’, each file
name is displayed once and matches are grouped under that filename
instead of repeating the filename on each match. This is
essentially the layout of the ‘--no-heading’ `ripgrep' command line
flag.
-- ELisp Variable: rg-show-columns [nil]
Controls if column numbers are used in the search result.
-- ELisp Variable: rg-ignore-case [case-fold-search]
Setting that controls if case sensitive search is made or not. It
can essentially be `on', `off' or `smart'. The `smart' setting
will trigger an analyze of the search string and if it’s all lower
case, the search will be case `insensitive', otherwise it will be
case `sensitive'. The following values are valid:
- `case-fold-search' - A non nil value of ‘case-fold-search’
will trigger smart case behavior.
- `smart' - Smart case behavior.
- `force' - Always ignore case.
- `nil' - Always consider case.
-- ELisp Variable: rg-hide-command [t]
Hide most of command line by default. This is enabled by default
and can be set to ‘nil’ to show full command line. This can be
toggled in the results buffer by clicking on the command line.
-- ELisp Variable: rg-keymap-prefix ["C-c s"]
This variable sets the default prefix used for the global key
bindings. Note that ‘rg-enable-default-bindings’ needs to be
invoked for the bindings to be enabled.
-- ELisp Variable: rg-use-transient-menu [t]
Controls whether ‘rg-menu’ will be used by default or not. It’s
also possible to enable the menu explicitly with
(rg-enable-menu)
-- ELisp Variable: rg-show-header [t]
Controls if the search info header is shown in the result buffer.
This is enabled by default but can be disabled by setting this
variable to ‘nil’.
-- ELisp Variable: rg-buffer-name ["rg"]
Controls the name of the results buffer. It may be `string' or
`function'. This name will be surrounded by ‘*’ to yield the final
buffer name so if this setting is ‘foo’ the buffer name will be
‘*foo*’. One useful case of using it is to have separate result
buffers per project. One can set this variable in ‘dir-locals‘
file or set it to function.
Example, this function will set results buffer name based on
‘project-current‘:
(defun my-rg-buffer-name ()
(let ((p (project-current)))
(if p
(format "rg %s" (abbreviate-file-name (cdr p)))
"rg"))))
-- ELisp Variable: rg-ignore-ripgreprc [t]
Controls if the ripgreprc
(https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file)
file should be ignored or not. If ‘nil’, the config file will be
used, otherwise it will be ignored. The default is to ignore this
file in order to avoid that conflicting settings have impact on
this package’s behavior. Setting this to ‘nil’ may affect core
functionality of this package. Especially changing colors can
affect parsing of the output and result in a broken results buffer.
* Menu:
* Position numbers alignment::
File: rgel.info, Node: Position numbers alignment, Up: Customization
2.1.1 Position numbers alignment
--------------------------------
When operating `rg' in grouped output mode (*note rg-group-result: 2b.
is non nil), it’s possible to control how the line and column numbers
are displayed in the result buffer.
Example settings:
(setq rg-align-position-numbers t)
(setq rg-align-line-number-field-length 3)
(setq rg-align-column-number-field-length 3)
(setq rg-align-line-column-separator "#")
(setq rg-align-position-content-separator "|")
Will yield the following format:
File: matched_file.foo
1# 2|match1
888# 10|match2
-- ELisp Variable: rg-align-position-numbers [t]
Setting this to ‘t’ will align line and column numbers in columns
padded with white space.
-- ELisp Variable: rg-align-line-number-field-length [4]
Defines the length of the line number field.
-- ELisp Variable: rg-align-column-number-field-length [3]
Defines the length of the column number field.
-- ELisp Variable: rg-align-line-column-separator [" "]
Separator string used between line and column numbers. ‘nil’ means
use default separator from `ripgrep'.
-- ELisp Variable: rg-align-position-content-separator [" "]
Separator string used between the position numbers and matched
content. ‘nil’ means use default separator from `ripgrep'.
File: rgel.info, Node: Faces, Next: Configuration functions, Prev: Customization, Up: Configuration
2.2 Faces
=========
All faces are in the subgroup ‘rg-face’ of the main group ‘rg’.
M-x customize-group [RET] rg-face [RET]
* Menu:
* Results buffer: Results buffer<2>.
* Header line::
File: rgel.info, Node: Results buffer<2>, Next: Header line, Up: Faces
2.2.1 Results buffer
--------------------
-- ELisp Variable: rg-match-face [match]
Face used to highlight matches in result.
-- ELisp Variable: rg-error-face [compilation-error]
Face used to highlight errors when invoking `ripgrep'.
-- ELisp Variable: rg-context-face [shadow]
Face used to highlight context lines in `ripgrep' output when
‘--context-lines’ flag is used.
-- ELisp Variable: rg-info-face [compilation-info]
Face used to highlight general info in results buffer. For
instance the number of matches found.
-- ELisp Variable: rg-warning-face [compilation-warning]
Face used to highlight warnings in the `ripgrep' output.
-- ELisp Variable: rg-filename-face [rg-info-face]
Face used to highlight filenames in the output.
-- ELisp Variable: rg-file-tag-face [rg-info-face]
Face used for the ‘File:’ tag in grouped results output.
-- ELisp Variable: rg-line-number-face [compilation-line-number]
Face used on line numbers.
-- ELisp Variable: rg-column-number-face [compilation-column-number]
Face used on column numbers.
-- ELisp Variable: rg-match-position-face [default]
Face added to file positions. This is the start of a matching line
and depending on configuration may be, file name, column number and
line number.
File: rgel.info, Node: Header line, Prev: Results buffer<2>, Up: Faces
2.2.2 Header line
-----------------
-- ELisp Variable: rg-toggle-on-face [rg-file-tag-face]
Face used for flags that are toggled ‘on’.
-- ELisp Variable: rg-toggle-off-face [rg-error-face]
Face used for flags that are toggled ‘off’.
-- ELisp Variable: rg-literal-face [rg-filename-face]
Face used the on the ‘literal’ marker in the header line.
-- ELisp Variable: rg-regexp-face [compilation-line-number]
Face used the on the ‘regexp’ marker in the header line.
File: rgel.info, Node: Configuration functions, Next: Hooks, Prev: Faces, Up: Configuration
2.3 Configuration functions
===========================