helm-deft
helm-deft copied to clipboard
A helm based emacs module to help search in a predetermined list of directories. Inspired by the deft module.
helm-deft
This is still very much experimental, even though I have been using it daily for more than a year.
Helm-deft is designed to find matching files in a defined list of directories helm-deft-dir-list and all sharing a common extension helm-deft-extension. Both these variables can be customized.
helm-deft is composed of three helm search sources
- file names: simple match of pattern vs. file name
- file match: shows file names of files where all of the individual patterns match anywhere in the file
- file contents: show the lines where the last word in the search pattern matches
Hope this is useful for anybody stumbling upon it at its current state of development.
Derek
Configuration
The configuration can also be done using the normal M-x customize-group
for the helm-deft
configuration group.
-
helm-deft-dir-list
: List of directories in which to search recursively for candidate files. This is either a simple list(setq helm-deft-dir-list '("~/Documents" "~/my-other-docs"))
or it can be given as an association list structured to contain group names and the respective directory list definitions.
(setq helm-deft-dir-list '(("group1" . ("dir1" "dir2" "dir3")) ("group2" . ("dir1" "dir4"))))
During the invocation one can change the directory group that is used for the underlying search
-
helm-deft-extension
: Defines file extension for identifying candidate files to be searched for.(setq helm-deft-extension "org")
Search options
If a search pattern is headed by a w:
prefix, the search will be constrained
for whole words for this pattern. So, the pattern
first w:second
will apply a search where "first" appears anywhere, while second must be a whole word. This allows to drill down especially for short words.
Additionally, the following key commands can be applied during the typing of the search
-
C-r
: Allows to "rotate" the words in the helm search string, e.g.pat1 pat2 pat3
becomespat2 pat3 pat1
. Useful, since the grep results in the file contents source are only shown based on the last word. - The following commands allow to narrow down the candidates list that
is used for the grep.
-
C-d
: Delete file under point from the candidates list (also works on multiple mark selection). -
C-s
: Allows to set the candidates list to the list of marked files. -
C-.
: Reset the search to the original list
-
-
C-,
: Allows to switch between directory groups if multiple search groups have been defined inhelm-deft-dir-list
.
Shortcomings
- The candidates for the matching files source are built after
the async grep process from the file contents source. The only
successful way I found up to now to have the matching files
source updated after the file contents source, was to introduce
a
delayed
attribute in the matching files source. Regrettably this also results in that source being displayed last. - I wrote this originally with the idea that I could profit from an async source. This is not true under the current implementation, so the async source is kind of useless for now. I have kept it currently out of lazyness.
- Occasionally, helm coughs up and diplays the matching files block multiple times.
Nonetheless, this is currently the fastest way for me to jump between tasks.