Skip to content

Commit

Permalink
Add brief documentation on how to change the rg-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
dajva committed Sep 11, 2021
1 parent d59aad1 commit c1e04df
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion docs/configuration.org
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,46 @@
:PROPERTIES:
:CUSTOM_ID: customizing_the_menu
:END:
Please refer to the [[https://magit.vc/manual/transient/Modifying-Existing-Transients.html#Modifying-Existing-Transients][transient]] documentation for customizing the menu.
The menu can be modified from the emacs configuration file.

To add a new *switch* before the option triggered by =-n= at suffix
level 3:
#+BEGIN_SRC elisp
(transient-insert-suffix 'rg-menu "-n" '(3 "-o" "Only print matches" "--only-matching"))
#+END_SRC
To add a new *option* before the option triggered by =-g= at suffix
level 4:
#+BEGIN_SRC elisp
(transient-insert-suffix 'rg-menu "-g" '(4 "-f" "Pattern file" "--file="))
#+END_SRC
The === in =--file== triggers argument input for the flag.

To remove an item from the menu specify the trigger key in the
transient remove command.
For example, to remove the =Search hidden files= switch use the following:
#+BEGIN_SRC elisp
(transient-remove-suffix 'rg-menu "-h")
#+END_SRC

Please refer to the [[https://magit.vc/manual/transient/Modifying-Existing-Transients.html#Modifying-Existing-Transients][transient]] documentation for details on customizing the menu.

This package also adds a convenience function for appending new
*commands* to the menu in the groups at the bottom.

:FUNCTION:
#+BEGIN_SRC elisp :results value raw :exports results
(rg-function-info 'rg-menu-transient-insert)
#+END_SRC
This inserts a new command under =group= if it exists, otherwise a
new group is created. =key=, =description= and =command= is as for
the =transient-insert-suffix= function.

For example to insert a new command under =Search= group:
#+BEGIN_SRC elisp
(rg-menu-transient-insert "Search" "m" "My search" 'my-search-command)
#+END_SRC

It's usually better to use the =:menu= key of the [[func:rg-define-search]]
macro to define a search function and adding it to the menu in one go.
:END:

0 comments on commit c1e04df

Please sign in to comment.