There are always some commands that we use frequently, but not frequently enough to remember. Usually I record them into org files.
So, If I forget a command, I should go through the following steps:
- Found the org file
- Open the org file and find out the corresponding src-block
- Copy the code in the src-block, and then modify it according to the actual situation
That’s too much steps!!
That’s why I write this examples
package.
The idea is to treat headlines as examples and the codes in src-blocks as command templates.
Specifically, examples
will do following things
- List all the examples in org files to user for selection.
- Once user selected an example,
examples
will search corresponding src-blocks. - If there is only one src-block then the code will be expanded by yasnippet and inserted into current buffer, otherwise tell the user to select which src-block before expanding and inserting.
- setting
examples-default-org-files
The varialbe specified org files stored examples.
The default value is all the org files in
PATH-TO-EXAMPLES/examples/
directory - (Optional)setting
exampls-mode-lang-alist
This varialbe specified the correspondence between currect major-mode and the src-block language.
It is mainly used to reduce the amount of src-block selection. after all, if you’re in eshell, It is less likely to use C ++ code.
Defautly,
examples
only search those src-blocks which language is the same as current major-mode(removed the mode suffix). - execute
M-x examples